/**
 * Styles optimisés pour le chatbot PuppyFinder
 * Version 2.1 avec corrections d'alignement
 */

/* Import de la police Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@300;400;500;600;700&display=swap');

/* Variables CSS pour la personnalisation */
:root {
    --chatbot-primary: #3B82F6;
    --chatbot-secondary: #8B5CF6;
    --chatbot-success: #10B981;
    --chatbot-warning: #F59E0B;
    --chatbot-error: #EF4444;
    --chatbot-bg-light: #ffffff;
    --chatbot-bg-dark: #1F2937;
    --chatbot-text-light: #ffffff;
    --chatbot-text-dark: #ffffff;
    --chatbot-border-light: #E5E7EB;
    --chatbot-border-dark: #374151;
    --chatbot-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --chatbot-shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --chatbot-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --chatbot-font-primary: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --chatbot-font-secondary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Reset et styles de base */
* {
    box-sizing: border-box;
}

/* Styles de base du chatbot - Haute spécificité */
#puppyfinder-chatbot {
    font-family: var(--chatbot-font-primary) !important;
    line-height: 1.6 !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    color: var(--chatbot-text-light) !important;
    position: fixed !important;
    bottom: 1rem !important;
    right: 1rem !important;
    z-index: 9999 !important;
}

/* Bouton principal du chatbot - Corrections d'alignement */
#chatbot-toggle {
    position: relative !important;
    z-index: 1000 !important;
    transition: var(--chatbot-transition) !important;
    box-shadow: var(--chatbot-shadow) !important;
    font-family: var(--chatbot-font-primary) !important;
    font-weight: 600 !important;
    width: 4rem !important;
    height: 4rem !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%) !important;
    border: none !important;
    cursor: pointer !important;
    color: white !important;
}

/* Styles pour le logo dans le bouton */
#chatbot-toggle img {
    filter: brightness(0) invert(1) !important;
    transition: var(--chatbot-transition) !important;
    width: 1.5rem !important;
    height: 1.5rem !important;
    object-fit: contain !important;
}

#chatbot-toggle:hover img {
    transform: scale(1.1) !important;
    filter: brightness(0) invert(1) drop-shadow(0 0 4px rgba(255, 255, 255, 0.3)) !important;
}

#chatbot-toggle:hover {
    transform: scale(1.1) rotate(5deg) !important;
    box-shadow: var(--chatbot-shadow-lg) !important;
}

#chatbot-toggle:active {
    transform: scale(0.95) !important;
}

/* Indicateur de statut en ligne */
#chatbot-toggle .animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite !important;
    position: absolute !important;
    top: -0.25rem !important;
    right: -0.25rem !important;
    width: 0.75rem !important;
    height: 0.75rem !important;
    background-color: #10B981 !important;
    border-radius: 50% !important;
}

/* Fenêtre du chatbot - Corrections majeures */
#chatbot-window {
    position: absolute !important;
    bottom: 5rem !important;
    right: 0 !important;
    width: 20rem !important;
    height: 24rem !important;
    background: rgba(31, 41, 55, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(75, 85, 99, 0.5) !important;
    border-radius: 0.75rem !important;
    box-shadow: var(--chatbot-shadow-lg) !important;
    transition: var(--chatbot-transition) !important;
    font-family: var(--chatbot-font-primary) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    z-index: 9998 !important;
}

/* Header du chatbot - Alignement corrigé */
#chatbot-window .bg-gradient-to-r {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, var(--chatbot-secondary) 100%) !important;
    position: relative !important;
    overflow: hidden !important;
    padding: 1rem !important;
    border-radius: 0.75rem 0.75rem 0 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    min-height: 4rem !important;
}

#chatbot-window .bg-gradient-to-r::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%) !important;
    animation: shimmer 3s ease-in-out infinite !important;
}

/* Styles du header - Alignement des éléments */
#chatbot-window h3 {
    font-family: var(--chatbot-font-primary) !important;
    font-weight: 600 !important;
    font-size: 1.1rem !important;
    color: #ffffff !important;
    letter-spacing: -0.025em !important;
    margin: 0 !important;
}

#chatbot-window p {
    font-family: var(--chatbot-font-secondary) !important;
    font-weight: 400 !important;
    color: rgba(255, 255, 255, 0.9) !important;
    margin: 0 !important;
    font-size: 0.75rem !important;
}

/* Zone des messages - Corrections de scroll et alignement */
#chatbot-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 1rem !important;
    background: rgba(31, 41, 55, 0.95) !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(156, 163, 175, 0.5) transparent !important;
    font-family: var(--chatbot-font-secondary) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 0.75rem !important;
}

#chatbot-messages::-webkit-scrollbar {
    width: 6px !important;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: transparent !important;
    border-radius: 3px !important;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.5) !important;
    border-radius: 3px !important;
    transition: background 0.3s ease !important;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.7) !important;
}

/* Bulles de messages - Alignement corrigé */
#chatbot-messages .max-w-xs {
    position: relative !important;
    word-wrap: break-word !important;
    hyphens: auto !important;
    font-family: var(--chatbot-font-secondary) !important;
    max-width: 75% !important;
}

/* Message utilisateur - Alignement à droite */
#chatbot-messages .flex.justify-end {
    justify-content: flex-end !important;
}

#chatbot-messages .flex.justify-end .max-w-xs {
    background: linear-gradient(135deg, var(--chatbot-primary) 0%, #2563EB 100%) !important;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.2) !important;
    color: #ffffff !important;
    border-radius: 1rem 1rem 0.25rem 1rem !important;
    padding: 0.75rem 1rem !important;
}

/* Message bot - Alignement à gauche */
#chatbot-messages .flex.justify-start {
    justify-content: flex-start !important;
}

#chatbot-messages .flex.justify-start .max-w-xs {
    background: rgba(55, 65, 81, 0.9) !important;
    box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1) !important;
    border: 1px solid rgba(75, 85, 99, 0.3) !important;
    color: #ffffff !important;
    border-radius: 1rem 1rem 1rem 0.25rem !important;
    padding: 0.75rem 1rem !important;
}

/* Styles des messages - Texte blanc forcé */
#chatbot-messages .text-sm {
    font-family: var(--chatbot-font-secondary) !important;
    font-weight: 400 !important;
    line-height: 1.6 !important;
    color: #ffffff !important;
    font-size: 0.875rem !important;
    margin: 0 !important;
}

#chatbot-messages .text-xs {
    font-family: var(--chatbot-font-secondary) !important;
    font-weight: 400 !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 0.75rem !important;
    margin: 0 !important;
    margin-top: 0.25rem !important;
}

/* Boutons de réponse rapide - Alignement corrigé */
#chatbot-messages .flex.flex-wrap {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
    margin-top: 0.75rem !important;
    justify-content: flex-start !important;
}

#chatbot-messages button {
    transition: var(--chatbot-transition) !important;
    border: 1px solid rgba(59, 130, 246, 0.3) !important;
    position: relative !important;
    overflow: hidden !important;
    font-family: var(--chatbot-font-secondary) !important;
    font-weight: 500 !important;
    color: #ffffff !important;
    background: rgba(59, 130, 246, 0.2) !important;
    padding: 0.5rem 1rem !important;
    border-radius: 9999px !important;
    font-size: 0.75rem !important;
    cursor: pointer !important;
    white-space: nowrap !important;
}

#chatbot-messages button::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: -100% !important;
    width: 100% !important;
    height: 100% !important;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent) !important;
    transition: left 0.5s ease !important;
}

#chatbot-messages button:hover::before {
    left: 100% !important;
}

#chatbot-messages button:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3) !important;
    background: rgba(59, 130, 246, 0.3) !important;
    color: #ffffff !important;
}

#chatbot-messages button:active {
    transform: translateY(0) !important;
}

/* Indicateur de frappe - Alignement corrigé */
#typing-indicator {
    animation: slideInLeft 0.3s ease-out !important;
    display: flex !important;
    justify-content: flex-start !important;
}

#typing-indicator .bg-gray-700 {
    background: rgba(55, 65, 81, 0.9) !important;
    padding: 0.75rem 1rem !important;
    border-radius: 1rem 1rem 1rem 0.25rem !important;
    border: 1px solid rgba(75, 85, 99, 0.3) !important;
}

#typing-indicator .flex.space-x-1 {
    display: flex !important;
    gap: 0.25rem !important;
}

#typing-indicator .animate-bounce {
    animation: typingBounce 1.4s ease-in-out infinite !important;
    width: 0.5rem !important;
    height: 0.5rem !important;
    background-color: #60A5FA !important;
    border-radius: 50% !important;
}

#typing-indicator .animate-bounce:nth-child(2) {
    animation-delay: 0.2s !important;
}

#typing-indicator .animate-bounce:nth-child(3) {
    animation-delay: 0.4s !important;
}

/* Zone de saisie - Alignement corrigé */
#chatbot-window .border-t {
    border-top: 1px solid rgba(75, 85, 99, 0.5) !important;
    padding: 1rem !important;
    background: rgba(31, 41, 55, 0.95) !important;
    border-radius: 0 0 0.75rem 0.75rem !important;
}

#chatbot-window .flex.space-x-2 {
    display: flex !important;
    gap: 0.5rem !important;
    align-items: center !important;
}

#chatbot-input {
    flex: 1 !important;
    transition: var(--chatbot-transition) !important;
    border: 2px solid transparent !important;
    font-family: var(--chatbot-font-secondary) !important;
    font-weight: 400 !important;
    color: #ffffff !important;
    background: rgba(55, 65, 81, 0.8) !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: 0.5rem !important;
    font-size: 0.875rem !important;
    outline: none !important;
}

#chatbot-input::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
    font-family: var(--chatbot-font-secondary) !important;
    font-weight: 400 !important;
}

#chatbot-input:focus {
    border-color: var(--chatbot-primary) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
    transform: translateY(-1px) !important;
    background: rgba(55, 65, 81, 1) !important;
    color: #ffffff !important;
}

/* Bouton d'envoi - Alignement corrigé */
#chatbot-send {
    transition: var(--chatbot-transition) !important;
    position: relative !important;
    overflow: hidden !important;
    font-family: var(--chatbot-font-secondary) !important;
    font-weight: 500 !important;
    background: var(--chatbot-primary) !important;
    color: white !important;
    padding: 0.5rem 1rem !important;
    border-radius: 0.5rem !important;
    border: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 2.5rem !important;
    height: 2.5rem !important;
}

#chatbot-send::before {
    content: '' !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 0 !important;
    height: 0 !important;
    background: rgba(255, 255, 255, 0.3) !important;
    border-radius: 50% !important;
    transform: translate(-50%, -50%) !important;
    transition: width 0.3s ease, height 0.3s ease !important;
}

#chatbot-send:hover::before {
    width: 100% !important;
    height: 100% !important;
}

#chatbot-send:hover {
    background: #2563EB !important;
}

#chatbot-send:active {
    transform: scale(0.95) !important;
}

/* Compteur de caractères - Alignement corrigé */
#char-count {
    transition: color 0.3s ease !important;
    font-family: var(--chatbot-font-secondary) !important;
    font-weight: 400 !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 0.75rem !important;
    text-align: right !important;
    margin-top: 0.25rem !important;
}

#char-count.text-red-500 {
    animation: pulse 1s ease-in-out !important;
    color: #EF4444 !important;
}

/* Suggestions de chiots - Alignement corrigé */
#chatbot-messages .space-y-2 {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem !important;
    margin-top: 0.75rem !important;
}

#chatbot-messages .bg-gray-700 {
    background: rgba(55, 65, 81, 0.9) !important;
    border: 1px solid rgba(75, 85, 99, 0.3) !important;
    border-radius: 0.75rem !important;
    padding: 0.75rem !important;
    transition: var(--chatbot-transition) !important;
}

#chatbot-messages .bg-gray-700:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1) !important;
    border-color: var(--chatbot-primary) !important;
    background: rgba(55, 65, 81, 1) !important;
}

#chatbot-messages .flex.items-center.space-x-3 {
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
}

#chatbot-messages .w-12.h-12 {
    width: 3rem !important;
    height: 3rem !important;
    background: rgba(75, 85, 99, 0.5) !important;
    border-radius: 0.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
}

#chatbot-messages .flex-1 {
    flex: 1 !important;
    min-width: 0 !important;
}

#chatbot-messages .font-semibold.text-sm {
    font-weight: 600 !important;
    font-size: 0.875rem !important;
    color: #ffffff !important;
    margin: 0 !important;
    margin-bottom: 0.25rem !important;
}

#chatbot-messages .text-xs.text-gray-300 {
    font-size: 0.75rem !important;
    color: rgba(255, 255, 255, 0.7) !important;
    margin: 0 !important;
    margin-bottom: 0.25rem !important;
}

#chatbot-messages .text-xs.text-blue-400 {
    font-size: 0.75rem !important;
    color: #60A5FA !important;
    font-weight: 600 !important;
    margin: 0 !important;
}

/* Boutons d'action du header - Alignement corrigé */
#chatbot-minimize,
#chatbot-close {
    transition: var(--chatbot-transition) !important;
    border-radius: 50% !important;
    color: #ffffff !important;
    background: transparent !important;
    border: none !important;
    padding: 0.25rem !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 1.5rem !important;
    height: 1.5rem !important;
}

#chatbot-minimize:hover,
#chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: scale(1.1) !important;
    color: #ffffff !important;
}

/* Animations personnalisées */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Responsive design - Corrections majeures */
@media (max-width: 640px) {
    #puppyfinder-chatbot {
        bottom: 0.5rem !important;
        right: 0.5rem !important;
    }
    
    #chatbot-window {
        width: calc(100vw - 1rem) !important;
        height: 80vh !important;
        right: 0 !important;
        bottom: 4rem !important;
        left: 0.5rem !important;
    }
    
    #chatbot-toggle {
        width: 3.5rem !important;
        height: 3.5rem !important;
    }
    
    #chatbot-toggle img {
        width: 1.25rem !important;
        height: 1.25rem !important;
    }
    
    #chatbot-messages {
        padding: 0.75rem !important;
    }
    
    #chatbot-messages .max-w-xs {
        max-width: 85% !important;
    }
}

@media (max-width: 480px) {
    #chatbot-window {
        width: calc(100vw - 0.5rem) !important;
        right: 0.25rem !important;
        left: 0.25rem !important;
        height: 75vh !important;
    }
    
    #chatbot-messages {
        padding: 0.5rem !important;
    }
    
    #chatbot-messages .max-w-xs {
        max-width: 90% !important;
    }
    
    #chatbot-window .border-t {
        padding: 0.75rem !important;
    }
}

/* États cachés */
#chatbot-window.hidden {
    display: none !important;
}

#chatbot-toggle.hidden {
    display: none !important;
}

/* États d'animation */
#chatbot-window.scale-95 {
    transform: scale(0.95) !important;
}

#chatbot-window.opacity-0 {
    opacity: 0 !important;
}

#chatbot-window.scale-100 {
    transform: scale(1) !important;
}

#chatbot-window.opacity-100 {
    opacity: 1 !important;
}

/* Support des préférences de réduction de mouvement */
@media (prefers-reduced-motion: reduce) {
    #puppyfinder-chatbot *,
    #puppyfinder-chatbot *::before,
    #puppyfinder-chatbot *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .animate-fade-in {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    
    .animate-bounce {
        animation: none !important;
    }
}

/* Effets de focus pour l'accessibilité */
#chatbot-toggle:focus,
#chatbot-send:focus,
#chatbot-input:focus,
#chatbot-messages button:focus {
    outline: 2px solid var(--chatbot-primary) !important;
    outline-offset: 2px !important;
}

/* Styles pour les liens dans les messages */
#chatbot-messages a {
    color: #60A5FA !important;
    text-decoration: underline !important;
    font-weight: 500 !important;
}

#chatbot-messages a:hover {
    color: #93C5FD !important;
}

/* Styles pour les éléments en gras et italique */
#chatbot-messages strong,
#chatbot-messages b {
    font-weight: 600 !important;
    color: #ffffff !important;
}

#chatbot-messages em,
#chatbot-messages i {
    font-style: italic !important;
    color: #ffffff !important;
}
