/**
 * Chatbot Styles - HostAura
 * Interface de chat flottante responsif et moderne
 */

/* Variables pour le chatbot */
:root {
    --chatbot-primary: var(--accent-color);
    --chatbot-primary-dark: var(--accent-color-dark);
    --chatbot-bg: var(--card-bg);
    --chatbot-text: var(--text-color);
    --chatbot-border: var(--border-color);
    --chatbot-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    --chatbot-shadow-hover: 0 12px 48px rgba(0, 0, 0, 0.18);
}

/* Conteneur principal du chatbot */
.chatbot-container {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 1400; /* Inférieur au thème toggle mais supérieur au contenu */
    font-family: 'Poppins', sans-serif;
}

/* Bulle du chatbot (bouton flottant) */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-dark));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--chatbot-shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.2);
    outline: none;
}

.chatbot-toggle:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: var(--chatbot-shadow-hover);
}

.chatbot-toggle.chatbot-active {
    background: linear-gradient(135deg, #ff6b6b, #ee5253);
    transform: rotate(90deg);
}

.chatbot-toggle i {
    font-size: 1.8rem;
    transition: transform 0.3s ease;
}

.chatbot-toggle.chatbot-active i::before {
    content: '\f00d'; /* Icône close */
}

/* Badge de notification */
.chatbot-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(255, 71, 87, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Fenêtre de chat */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    left: 0;
    width: 380px;
    height: 500px;
    background: var(--chatbot-bg);
    border-radius: 20px;
    box-shadow: var(--chatbot-shadow);
    transform: translateY(20px) scale(0.8);
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--chatbot-border);
    overflow: hidden;
}

.chatbot-window.chatbot-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* Header du chat */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-dark));
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.chatbot-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="20" cy="20" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="80" cy="40" r="0.5" fill="rgba(255,255,255,0.1)"/><circle cx="40" cy="80" r="1.5" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>') repeat;
    pointer-events: none;
}

.chatbot-info {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.chatbot-title h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.chatbot-status {
    font-size: 0.85rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chatbot-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4cd137;
    border-radius: 50%;
    display: inline-block;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.chatbot-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    position: relative;
    z-index: 1;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Zone des messages */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--background-color);
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: var(--chatbot-border);
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: var(--chatbot-primary);
}

/* Messages individuels */
.chatbot-message {
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(10px);
    animation: messageSlide 0.3s ease-out forwards;
}

.chatbot-message.message-animate {
    opacity: 1;
    transform: translateY(0);
}

@keyframes messageSlide {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    background: var(--chatbot-bg);
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 85%;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--chatbot-border);
}

.bot-message .message-content {
    background: linear-gradient(135deg, var(--chatbot-primary), var(--chatbot-primary-dark));
    color: white;
    margin-right: auto;
    border-bottom-left-radius: 6px;
}

.user-message {
    align-items: flex-end;
}

.user-message .message-content {
    background: var(--input-bg);
    color: var(--chatbot-text);
    margin-left: auto;
    border-bottom-right-radius: 6px;
}

.message-content p {
    margin: 0;
    line-height: 1.4;
    font-size: 0.9rem;
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-color-light);
    margin-top: 4px;
    opacity: 0.7;
}

.bot-message .message-time {
    text-align: left;
}

.user-message .message-time {
    text-align: right;
}

/* Actions rapides */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.quick-action {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 12px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    text-align: left;
    backdrop-filter: blur(10px);
}

.quick-action:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(4px);
}

/* Zone de saisie */
.chatbot-input-container {
    padding: 20px;
    background: var(--chatbot-bg);
    border-top: 1px solid var(--chatbot-border);
}

.chatbot-input {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chatbot-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--chatbot-border);
    border-radius: 25px;
    outline: none;
    font-size: 0.9rem;
    background: var(--input-bg);
    color: var(--chatbot-text);
    transition: all 0.3s ease;
    resize: none;
    font-family: 'Poppins', sans-serif;
}

.chatbot-input input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(var(--accent-color-rgb), 0.1);
}

.chatbot-input button {
    width: 40px;
    height: 40px;
    background: var(--chatbot-primary);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.chatbot-input button:hover {
    background: var(--chatbot-primary-dark);
    transform: scale(1.1);
}

.chatbot-input button:active {
    transform: scale(0.95);
}

/* Indicateur de frappe */
.chatbot-typing {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 8px 16px;
    background: var(--input-bg);
    border-radius: 18px;
    width: fit-content;
    border: 1px solid var(--chatbot-border);
}

.typing-indicator {
    display: flex;
    gap: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--chatbot-primary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.typing-text {
    font-size: 0.8rem;
    color: var(--text-color-light);
    font-style: italic;
}

/* Adaptations pour mobile */
@media (max-width: 768px) {
    .chatbot-container {
        bottom: 20px;
        left: 20px;
    }
    
    .chatbot-toggle {
        width: 50px;
        height: 50px;
        z-index: 1500; /* Plus élevé sur mobile */
    }
    
    .chatbot-toggle i {
        font-size: 1.5rem;
    }
    
    
    .chatbot-window {
        width: calc(100vw - 40px);
        max-width: 350px;
        height: 450px;
        bottom: 75px;
        left: 0;
    }
    
    .chatbot-notification {
        width: 20px;
        height: 20px;
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 20px);
        height: 400px;
        left: -10px;
    }
    
    .chatbot-messages {
        padding: 15px;
        gap: 12px;
    }
    
    .chatbot-input-container {
        padding: 15px;
    }
    
    .message-content {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    
    .quick-action {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}

/* Ajustements pour le thème sombre */
.dark-theme .chatbot-window {
    border-color: #333;
    background: #1a1a1a;
}

.dark-theme .chatbot-messages {
    background: var(--background-color);
}

.dark-theme .user-message .message-content {
    background: #2c2c2c;
    color: #e0e0e0;
    border-color: #444;
}

.dark-theme .chatbot-typing {
    background: #2c2c2c;
    border-color: #444;
}

/* Correction du chatbot-input-container pour le thème sombre */
.dark-theme .chatbot-input-container {
    background: #1a1a1a;
    border-top-color: #333;
}

.dark-theme .chatbot-input input {
    background: #2c2c2c;
    color: #e0e0e0;
    border-color: #444;
}

.dark-theme .chatbot-input input:focus {
    border-color: var(--chatbot-primary);
    box-shadow: 0 0 0 3px rgba(var(--accent-color-rgb), 0.2);
}

.dark-theme .chatbot-input input::placeholder {
    color: #888;
}


/* Ajustement du z-index quand le menu mobile est ouvert */
body.menu-open .chatbot-container {
    z-index: 999; /* Inférieur au menu mobile */
}


/* Animation d'entrée au chargement de la page */
.chatbot-container {
    animation: chatbotSlideIn 0.8s ease-out 1s both;
}

@keyframes chatbotSlideIn {
    from {
        transform: translateX(-100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Effet de hover pour l'ensemble du conteneur */
.chatbot-container:hover .chatbot-toggle {
    transform: translateY(-2px) scale(1.02);
}
