/* ============================================
   CHATBOT POPUP - Version Complète
   ============================================ */

/* --- BOUTON D'OUVERTURE --- */
.chatbot-toggle {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.4);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.chatbot-toggle:hover {
    transform: scale(1.1) rotate(-8deg);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.6);
}

.chatbot-toggle:active {
    transform: scale(0.95);
}

.chatbot-toggle .notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 11px;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    animation: pulse-badge 2s infinite;
    box-shadow: 0 2px 10px rgba(255, 71, 87, 0.4);
}

@keyframes pulse-badge {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* --- POPUP PRINCIPAL --- */
.chatbot-popup {
    position: fixed;
    bottom: 110px;
    left: 30px;
    width: 420px;
    max-width: calc(100vw - 60px);
    height: 600px;
    max-height: calc(100vh - 180px);
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    animation: slideUp 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.chatbot-popup.active {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- HEADER --- */
.chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 18px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-content .chat-icon {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.header-content .header-text h3 {
    font-size: 16px;
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.header-content .header-text .status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ed573;
    animation: blink-dot 1.5s infinite;
}

@keyframes blink-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* --- MESSAGES --- */
.chatbot-messages {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    background: #f8f9fa;
}

.message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: messageSlide 0.3s ease;
}

.message.user {
    flex-direction: row-reverse;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.message.user .message-avatar {
    background: #2d3436;
}

.message-content {
    max-width: 75%;
    padding: 10px 16px;
    border-radius: 14px;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 14px;
}

.message.bot .message-content {
    background: white;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* --- INPUT --- */
.chatbot-input-area {
    background: white;
    border-top: 1px solid #e8e8e8;
    padding: 14px 18px 16px;
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

#chatbotInput {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid #e8e8e8;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
    background: #f8f9fa;
    font-family: inherit;
}

#chatbotInput:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

#chatbotInput::placeholder {
    color: #aaa;
}

#chatbotSend {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

#chatbotSend:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

#chatbotSend:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chatbot-footer {
    margin-top: 8px;
    text-align: center;
    color: #999;
    font-size: 11px;
}

.chatbot-footer i {
    margin-right: 5px;
    color: #667eea;
}

/* --- TYPING INDICATOR --- */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 8px 14px;
    background: white;
    border-radius: 14px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typingAnim 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnim {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* --- SCROLLBAR --- */
.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #5a6fd6;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
    .chatbot-popup {
        bottom: 90px;
        left: 15px;
        right: 15px;
        width: auto;
        max-width: none;
        height: 65vh;
        max-height: 65vh;
        border-radius: 18px;
    }
    
    .chatbot-toggle {
        bottom: 20px;
        left: 20px;
        width: 55px;
        height: 55px;
        font-size: 24px;
    }
    
    .header-content .header-text h3 {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .chatbot-popup {
        bottom: 80px;
        left: 10px;
        right: 10px;
        height: 60vh;
        max-height: 60vh;
        border-radius: 14px;
    }
    
    .chatbot-toggle {
        bottom: 15px;
        left: 15px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .message-content {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .chatbot-messages {
        padding: 12px;
    }
    
    .chatbot-input-area {
        padding: 10px 12px 12px;
    }
}

/* Animation d'entrée du header */
.chatbot-popup.active .chatbot-header {
    animation: headerSlide 0.5s ease;
}

@keyframes headerSlide {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}