/* Chatbot MRE - Modern Professional Colors */
:root {
    --primary-blue: #4F46E5;
    --primary-green: #059669;
    --accent-gold: #F59E0B;
    --pure-white: #FFFFFF;
    --text-dark: #2D3748;
    --text-light: #718096;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    --shadow-hover: 0 15px 35px rgba(0, 0, 0, 0.2);
    --border-radius: 12px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
}

/* Bouton d'ouverture du chatbot */
.chatbot-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-green));
    color: var(--pure-white);
    border: none;
    border-radius: 50px;
    padding: 15px 25px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    z-index: 1000;
    font-weight: 600;
    font-size: 14px;
    /* Better touch targets for mobile */
    min-height: 44px;
    min-width: 44px;
}

.chatbot-button:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.chatbot-button:active {
    transform: translateY(-1px);
}

.chatbot-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-text {
    white-space: nowrap;
}

/* Animation du bouton */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.chatbot-button.pulse {
    animation: pulse 2s infinite;
}

/* Fenêtre du chatbot */
.chatbot-window {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 400px;
    height: 600px;
    background: var(--pure-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-hover);
    display: none;
    flex-direction: column;
    z-index: 1001;
    overflow: hidden;
    border: 2px solid var(--accent-gold);
}

.chatbot-window.open {
    display: flex;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header du chatbot */
.chatbot-header {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-green));
    color: var(--pure-white);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
}

.chatbot-avatar img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid var(--accent-gold);
    object-fit: cover;
}

.chatbot-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.chatbot-info p {
    margin: 5px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.chatbot-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: var(--pure-white);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background-color 0.2s;
    /* Better touch target for mobile */
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.chatbot-close:active {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Zone des messages */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
    /* Better mobile scrolling */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

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

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

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

/* Messages */
.message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.message.user-message {
    flex-direction: row-reverse;
}

.message-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.message-content {
    background: var(--pure-white);
    padding: 12px 16px;
    border-radius: var(--border-radius);
    max-width: 280px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.message.bot-message .message-content {
    border: 1px solid var(--accent-gold);
}

.message.user-message .message-content {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-green));
    color: var(--pure-white);
}

.message-content p {
    margin: 0 0 8px 0;
    line-height: 1.5;
    font-size: 14px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content ul li {
    margin-bottom: 4px;
    font-size: 13px;
}

/* Bulles de conversation avec queues */
.message.bot-message .message-content::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 15px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 8px 8px 0;
    border-color: transparent var(--accent-gold) transparent transparent;
}

.message.user-message .message-content::before {
    content: '';
    position: absolute;
    right: -8px;
    top: 15px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 0 8px 8px;
    border-color: transparent transparent transparent var(--primary-blue);
}

/* Boutons d'action dans les messages */
.action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.action-btn {
    background: var(--accent-gold);
    color: var(--text-dark);
    border: none;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    /* Better touch targets for mobile */
    min-height: 36px;
    min-width: 36px;
    touch-action: manipulation;
    white-space: nowrap;
}

.action-btn:hover {
    background: #ffed4e;
    transform: translateY(-1px);
}

.action-btn:active {
    transform: translateY(0);
}

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

.chatbot-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.chatbot-input-wrapper input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    outline: none;
    font-size: 16px; /* Prevent zoom on iOS */
    transition: border-color 0.2s;
    /* Better mobile input handling */
    -webkit-appearance: none;
    appearance: none;
    -webkit-border-radius: 25px;
}

.chatbot-input-wrapper input:focus {
    border-color: var(--accent-gold);
}

.chatbot-input-wrapper button {
    background: linear-gradient(135deg, var(--primary-blue), var(--primary-green));
    color: var(--pure-white);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    /* Better touch target for mobile */
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
}

.chatbot-input-wrapper button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chatbot-input-wrapper button:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(193, 39, 45, 0.3);
}

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

/* Animation de frappe */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 8px 0;
    color: var(--text-light);
    font-size: 12px;
}

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

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--accent-gold);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Spinner de chargement */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--accent-gold);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Messages d'erreur */
.error-message {
    background: #fed7d7;
    color: #c53030;
    border: 1px solid #feb2b2;
    padding: 12px;
    border-radius: var(--border-radius);
    margin: 10px 0;
    font-size: 13px;
}

/* Cartoon Avatar Styles */
.cartoon-avatar, .cartoon-avatar-small {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--accent-gold);
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: all 0.3s ease;
    animation: avatarGlow 3s ease-in-out infinite alternate;
}

.cartoon-avatar {
    width: 56px;
    height: 56px;
}

.cartoon-avatar-small {
    width: 46px;
    height: 46px;
}

.cartoon-avatar:hover, .cartoon-avatar-small:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(79, 70, 229, 0.4);
}

@keyframes avatarGlow {
    0% {
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    }
    100% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    }
}

/* Responsive Design - Mobile First */
@media (max-width: 480px) {
    .chatbot-window {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        margin: 0;
        border-radius: 0;
        border: none;
        position: fixed;
    }
    
    .chatbot-button {
        bottom: 20px;
        right: 20px;
        padding: 12px 16px;
        border-radius: 30px;
    }
    
    .chatbot-text {
        display: none;
    }
    
    .chatbot-icon {
        width: 28px;
        height: 28px;
    }
    
    .chatbot-header {
        padding: 15px 20px;
        border-radius: 0;
    }
    
    .chatbot-avatar img {
        width: 40px;
        height: 40px;
    }
    
    .chatbot-info h3 {
        font-size: 14px;
    }
    
    .chatbot-info p {
        font-size: 11px;
    }
    
    .chatbot-messages {
        padding: 15px;
        gap: 12px;
    }
    
    .message-content {
        max-width: calc(100vw - 80px);
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .message-avatar img {
        width: 32px;
        height: 32px;
    }
    
    .chatbot-input-container {
        padding: 15px;
    }
    
    .chatbot-input-wrapper input {
        padding: 10px 14px;
        font-size: 13px;
        border-radius: 20px;
    }
    
    .chatbot-input-wrapper button {
        width: 40px;
        height: 40px;
    }
    
    .action-buttons {
        gap: 6px;
        margin-top: 10px;
    }
    
    .action-btn {
        padding: 6px 10px;
        font-size: 11px;
        border-radius: 16px;
    }
    
    .chatbot-close {
        top: 12px;
        right: 12px;
        padding: 8px;
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    .chatbot-window {
        width: 95vw;
        height: 85vh;
        bottom: 10px;
        right: 2.5vw;
        left: 2.5vw;
        margin: 0;
        max-width: none;
    }
    
    .chatbot-button {
        bottom: 20px;
        right: 20px;
        padding: 12px 18px;
    }
    
    .chatbot-messages {
        padding: 18px;
    }
    
    .message-content {
        max-width: calc(95vw - 100px);
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    .chatbot-window {
        width: 380px;
        height: 550px;
    }
    
    .message-content {
        max-width: 260px;
    }
}

/* Landscape mobile orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .chatbot-window {
        height: 100vh;
        width: 100vw;
    }
    
    .chatbot-header {
        padding: 10px 20px;
    }
    
    .chatbot-avatar img {
        width: 35px;
        height: 35px;
    }
    
    .chatbot-info h3 {
        font-size: 13px;
    }
    
    .chatbot-info p {
        font-size: 10px;
    }
    
    .chatbot-messages {
        padding: 10px 15px;
    }
    
    .chatbot-input-container {
        padding: 10px 15px;
    }
}

/* Boutons de feedback */
.feedback-buttons {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-light);
}

.feedback-btn {
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-btn:hover {
    background: #f7fafc;
    border-color: var(--accent-gold);
}

.feedback-btn.helpful:hover {
    background: #d4edda;
    border-color: #28a745;
}

.feedback-btn.not-helpful:hover {
    background: #f8d7da;
    border-color: #dc3545;
}
