/* Reset et variables CSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Couleurs principales */
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #16213e;
    --bg-hover: #2a2a3e;
    --text-primary: #ffffff;
    --text-secondary: #b4b4b4;
    --text-muted: #8e8ea0;
    --accent-primary: #10a37f;
    --accent-hover: #0d8f6f;
    --accent-secondary: #ff6b35;
    --new-chat-btn-bg: #10a37f;
    --new-chat-btn-bg-hover: #0d8f6f;
    --avatar-bg: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.25), transparent 55%),
        linear-gradient(135deg, rgba(47, 143, 70, 0.35), rgba(197, 57, 42, 0.35));
    --avatar-border: var(--border-color);
    --avatar-border-auth: var(--border-color);
    --avatar-border-width: 1px;
    --maple-summer: #2f8f46;
    --maple-gold: #f0b429;
    --maple-autumn: #c5392a;
    --border-color: #2d2d3a;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.2);
    
    /* Couleurs des plans */
    --free-color: #6b7280;
    --pro-color: #10a37f;
    --premium-color: #ff6b35;
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
    
    /* Espacements */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Rayons de bordure */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

/* Styles de base */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
    /* Use dynamic viewport height on mobile for better compatibility */
    height: 100dvh;
}

/* Layout principal */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 320px;
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 1000;
    /* Ensure footer is always visible */
    padding-bottom: 0;
}

/* Desktop collapsed behavior - only apply on larger screens */
@media (min-width: 769px) {
    .sidebar.collapsed {
        width: 0;
        overflow: hidden;
    }
}

.main-content {
    margin-left: 320px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.sidebar.collapsed + .main-content {
    margin-left: 0;
}

/* Header de la sidebar */
.sidebar-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.header-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
    flex: 1;
}

.logo i {
    font-size: 1.5rem;
}

.maple-icon {
    width: 2.6rem;
    height: 2.6rem;
    display: inline-block;
    background: url("logo-feuille.png") no-repeat center / contain;
}

.maple-icon--sm {
    width: 2.2rem;
    height: 2.2rem;
}

.maple-icon--lg {
    width: 4rem;
    height: 4rem;
}

.maple-icon--xl {
    width: 8rem;
    height: 8rem;
    display: block;
    margin: 0 auto var(--spacing-md);
}

.new-chat-btn {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--new-chat-btn-bg);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    justify-content: center;
}

.new-chat-btn:hover {
    background: var(--new-chat-btn-bg-hover);
    transform: translateY(-1px);
}

/* Historique des chats */
.chat-history {
    flex: 1;
    padding: var(--spacing-md);
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    margin-bottom: var(--spacing-xs);
    position: relative;
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent-primary);
}

.chat-item span {
    flex: 1;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.edit-title,
.delete-chat {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: var(--transition-fast);
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-item:hover .edit-title,
.chat-item:hover .delete-chat {
    opacity: 1;
}

.edit-title:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
}

.delete-chat:hover {
    background: var(--bg-hover);
    color: var(--accent-secondary);
}

/* Styles pour l'édition de titre */
.title-edit-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    margin: 0 0.5rem;
}

.title-edit-input {
    flex: 1;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
}

.title-save-btn,
.title-cancel-btn {
    padding: 0.25rem 0.5rem;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75rem;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.title-save-btn {
    background: var(--accent-primary);
    color: white;
}

.title-save-btn:hover {
    background: var(--accent-hover);
}

.title-cancel-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.title-cancel-btn:hover {
    background: var(--bg-hover);
}

/* Footer de la sidebar */
.sidebar-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0; /* Prevent footer from shrinking */
    margin-top: auto; /* Push footer to bottom */
}

.user-profile {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    cursor: pointer;
    min-height: 56px; /* Hauteur minimale pour éviter le rétrécissement */
}

.user-profile:hover {
    background: var(--bg-hover);
}

.avatar {
    width: 40px;
    height: 40px;
    min-width: 40px; /* Empêcher le rétrécissement */
    min-height: 40px;
    background: var(--avatar-bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.125rem;
    overflow: hidden; /* Prevent avatar image overflow */
    border: var(--avatar-border-width) solid var(--avatar-border);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
    background-clip: padding-box;
    flex-shrink: 0;   /* Keep fixed size in flex containers */
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Crop to circle without distortion */
    display: block;
}

.user-info {
    flex: 1;
    min-width: 0; /* Permet au texte de se tronquer proprement */
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.username {
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px; /* Limite la largeur pour éviter le débordement */
}

.plan-badge {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    text-transform: uppercase;
    display: inline-block;
    width: fit-content;
}

.plan-badge.free {
    background: rgba(107, 114, 128, 0.2);
    color: var(--free-color);
}

.plan-badge.pro {
    background: rgba(16, 163, 127, 0.2);
    color: var(--pro-color);
}

.plan-badge.premium {
    background: rgba(255, 107, 53, 0.2);
    color: var(--premium-color);
}

.upgrade-btn {
    background: none;
    border: none;
    color: var(--accent-secondary);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    flex-shrink: 0; /* Empêcher le bouton de rétrécir */
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upgrade-btn:hover {
    background: var(--bg-hover);
    transform: scale(1.1);
}

/* Header principal */
.header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    grid-template-areas: "left center right";
    align-items: center;
    column-gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
}

/* Sidebar toggle button in sidebar header */
.sidebar .sidebar-toggle {
    margin-right: var(--spacing-sm);
}

/* Header toggle button - mobile specific styling */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
        height: calc(100vh - 80px); /* Reduce height to account for Samsung navigation bar */
        height: calc(100dvh - 80px);
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        bottom: 80px; /* Position above Samsung navigation bar */
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* Ensure user profile content is fully visible on mobile */
    .user-profile {
        padding: var(--spacing-sm) var(--spacing-md);
        min-height: 60px;
        /* Extra padding for safe area */
        padding-bottom: var(--spacing-lg);
    }

    .user-info {
        min-width: 0;
        flex: 1;
    }

    .username {
        font-size: 0.8rem;
        max-width: 120px;
        margin-bottom: 2px;
    }

    .plan-badge {
        font-size: 0.7rem;
        padding: 1px 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100px;
    }
}

/* Model selector and header actions - apply to all screen sizes */
.model-selector select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.model-selector select:hover {
    border-color: var(--accent-primary);
}

.model-selector {
    grid-area: center;
    justify-self: center;
}

.header-actions {
    grid-area: right;
    display: flex;
    gap: var(--spacing-sm);
    justify-self: end;
}

#headerSidebarToggle {
    grid-area: left;
    justify-self: start;
}

.action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Container de chat */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
    position: relative;
}

/* Écran d'accueil */
.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: var(--spacing-lg);
    text-align: center;
    box-sizing: border-box;
}

.welcome-content {
    max-width: 600px;
    width: 100%;
}

.welcome-logo {
    margin-bottom: var(--spacing-xl);
}

.welcome-logo .maple-icon {
    margin-bottom: var(--spacing-md);
    display: block;
}

.welcome-logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
}

.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-xl);
}

.suggestion-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    text-align: left;
}

.suggestion-card:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
}

.suggestion-card i {
    font-size: 1.25rem;
    color: var(--accent-primary);
    min-width: 20px;
}

.suggestion-card span {
    font-weight: 500;
}

/* Messages */
.messages {
    max-width: 800px;
    margin: 0 auto;
    padding-bottom: var(--spacing-xl);
}

.message {
    margin-bottom: var(--spacing-lg);
    display: flex;
    gap: var(--spacing-md);
    animation: fadeInUp 0.3s ease;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    flex-shrink: 0;
    border: var(--avatar-border-width) solid var(--avatar-border);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    background-clip: padding-box;
}

.message.user .message-avatar {
    background: linear-gradient(145deg, #ff6b35, #d94a1f);
    color: white;
}

.message.assistant .message-avatar {
    background: var(--avatar-bg);
    color: white;
}

.message-content {
    flex: 1;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    border: 1px solid var(--border-color);
    position: relative;
}

.message-error .message-content {
    border-color: rgba(255, 99, 99, 0.45);
    background: linear-gradient(160deg, rgba(255, 99, 99, 0.08), rgba(255, 99, 99, 0.02));
}

.error-card {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: var(--spacing-md);
    align-items: start;
    color: var(--text-primary);
}

.error-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 700;
    background: rgba(255, 99, 99, 0.2);
    color: #ff6b6b;
    border: 1px solid rgba(255, 99, 99, 0.45);
    box-shadow: 0 6px 14px rgba(255, 99, 99, 0.2);
}

.error-card__title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.error-card__detail {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    word-break: break-word;
}

.error-card__hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}

[data-theme="light"] .message-error .message-content {
    background: linear-gradient(160deg, rgba(255, 99, 99, 0.15), rgba(255, 99, 99, 0.05));
    border-color: rgba(255, 99, 99, 0.35);
}

[data-theme="light"] .error-card__icon {
    background: rgba(255, 99, 99, 0.15);
    color: #c0392b;
    border-color: rgba(255, 99, 99, 0.35);
}

.message.user .message-content {
    background: var(--accent-primary);
    color: white;
}

.message-actions {
    display: flex;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
    opacity: 0.2;
    transition: var(--transition-fast);
}

.message:hover .message-actions {
    opacity: 1;
}

.message-action {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--spacing-xs);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.message-action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Better visibility for message actions on user messages (green background) */
.message.user .message-action {
    color: rgba(255, 255, 255, 0.7);
}

.message.user .message-action:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

/* Zone de saisie */
.input-area {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    /* Ensure input area is visible on mobile browsers */
    padding-bottom: max(var(--spacing-lg), env(safe-area-inset-bottom));
    padding-bottom: max(var(--spacing-lg), constant(safe-area-inset-bottom));
}

/* Mobile input area positioning - raise it higher for better visibility */
@media (max-width: 768px) {
    .input-area {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100; /* Lower z-index to not interfere with sidebar */
        /* Add safe area padding for mobile browsers */
        padding-bottom: max(var(--spacing-lg), env(safe-area-inset-bottom));
        padding-bottom: max(var(--spacing-lg), constant(safe-area-inset-bottom));
        /* Force input area to stay visible */
        transition: bottom 0.3s ease;
        /* Ensure it's always above typical keyboard heights */
        margin-bottom: 0;
    }

    /* Adjust chat container to account for fixed input area */
    .chat-container {
        padding-bottom: calc(var(--spacing-lg) * 3 + 60px); /* Space for input area */
    }

    /* When viewport height changes (keyboard opens), adjust position using top instead of transform */
    @media (max-height: 600px) {
        .input-area {
            bottom: auto;
            top: calc(100vh - 180px); /* Position from top instead of bottom */
            z-index: 1000; /* Higher z-index only when keyboard is open */
        }
    }

    @media (max-height: 500px) {
        .input-area {
            bottom: auto;
            top: calc(100vh - 240px); /* Adjust for smaller screens */
            z-index: 1000;
        }
    }

    @media (max-height: 400px) {
        .input-area {
            bottom: auto;
            top: calc(100vh - 300px); /* Adjust for very small screens */
            z-index: 1000;
        }
    }
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: var(--spacing-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-sm);
    transition: var(--transition-fast);
}

.input-container:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, 0.1);
}

#messageInput {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 200px;
    padding: var(--spacing-sm) var(--spacing-sm);
}

#messageInput::placeholder {
    color: var(--text-muted);
}

.send-btn {
    background: var(--accent-primary);
    border: none;
    color: white;
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.send-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
}

.input-footer {
    max-width: 800px;
    margin: var(--spacing-sm) auto 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Modales */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: modalSlideIn 0.3s ease;
}

/* Settings modal - single column layout */
#settingsModal .modal-content {
    max-width: 700px;
    width: 85vw;
}

#settingsModal .modal-body {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    max-height: 70vh;
    overflow-y: auto;
}

#settingsModal .settings-section {
    margin-bottom: var(--spacing-lg);
}

/* Responsive settings modal */
@media (max-width: 768px) {
    #settingsModal .modal-content {
        width: 95vw;
        max-width: none;
    }

    #settingsModal .modal-body {
        padding: var(--spacing-md);
        gap: var(--spacing-md);
        max-height: 80vh;
    }

    /* Stack labels above inputs on mobile */
    #settingsModal .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-xs);
    }

    #settingsModal .setting-item label {
        width: 100%;
        margin-right: 0 !important;
        justify-content: flex-start;
    }

    #settingsModal .setting-item select,
    #settingsModal .setting-item input {
        width: 100% !important;
    }
}

/* Cookie preferences modal */
#cookiePreferencesModal .modal-body p {
    padding-left: var(--spacing-md);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--spacing-lg);
}

/* Cartes de tarification */
.pricing-cards {
    display: flex;
    gap: var(--spacing-lg);
    justify-content: center;
    align-items: stretch;
}

/* Desktop: horizontal layout */
@media (min-width: 769px) {
    .pricing-cards {
        flex-direction: row;
        max-width: 1200px;
        margin: 0 auto;
    }
    
    .pricing-card {
        flex: 1;
        min-width: 320px;
        max-width: 420px;
    }
}

/* Mobile: vertical layout (will be adjusted later) */
@media (max-width: 768px) {
    .pricing-cards {
        flex-direction: column;
        align-items: center;
    }
    
    .pricing-card {
        width: 100%;
        max-width: 400px;
    }
}

.pricing-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    position: relative;
    transition: var(--transition);
}

.pricing-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.pricing-card.popular {
    border-color: var(--pro-color);
    box-shadow: 0 0 20px rgba(16, 163, 127, 0.2);
}

.popular-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--pro-color);
    color: white;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.plan-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.plan-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.price {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.price span {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 400;
}

.features {
    list-style: none;
    margin-bottom: var(--spacing-xl);
}

.features li {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    font-size: 0.875rem;
}

.features i {
    color: var(--accent-primary);
    font-size: 0.75rem;
}

.plan-btn {
    width: 100%;
    padding: var(--spacing-md);
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.plan-btn:not(.current) {
    background: var(--accent-primary);
    color: white;
}

.plan-btn:not(.current):hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.plan-btn.current {
    background: var(--bg-hover);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Paramètres */
.settings-section {
    margin-bottom: var(--spacing-xl);
}

.settings-section h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--accent-primary);
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md) 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
}

.setting-item select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
}

.danger-btn {
    background: var(--accent-secondary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.danger-btn:hover {
    background: #e55a2b;
    transform: translateY(-1px);
}

.billing-btn {
    width: auto;
    padding: var(--spacing-sm) var(--spacing-md);
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.billing-btn i {
    font-size: 0.85em;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    body {
        font-size: 0.95rem;
    }

    .main-content {
        margin-left: 0;
    }

    /* Make chat history more readable on mobile by fitting more items */
    .chat-history {
        padding: var(--spacing-sm);
    }

    .chat-item {
        padding: var(--spacing-xs) var(--spacing-sm);
        gap: var(--spacing-xs);
    }

    .chat-item span {
        font-size: 0.75rem;
    }
}

/* Extra small screens - reduce sidebar width */
@media (max-width: 480px) {
    body {
        font-size: 0.9rem;
    }

    .sidebar {
        width: 85vw; /* Use viewport width instead of fixed pixels */
        max-width: 320px; /* Cap maximum width */
        transform: translateX(-100%); /* Ensure sidebar is hidden on very small screens */
        transition: transform 0.3s ease;
        /* Ensure sidebar doesn't get cut off by mobile navigation */
        height: 100dvh;
        bottom: 0;
    }

    .sidebar.active {
        transform: translateX(0); /* Slide in when active on very small screens */
    }

    /* Make user profile more compact on very small screens */
    .user-profile {
        padding: var(--spacing-xs) var(--spacing-sm);
        min-height: 50px;
        gap: var(--spacing-xs);
    }

    .avatar {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
        font-size: 0.875rem;
    }

    .username {
        font-size: 0.75rem;
        max-width: 100px;
        margin-bottom: 1px;
    }

    .plan-badge {
        font-size: 0.625rem;
        padding: 1px 3px;
        max-width: 80px;
    }

    .upgrade-btn {
        width: 28px;
        height: 28px;
    }

    /* Extra compact chat list on very small screens */
    .chat-item span {
        font-size: 0.7rem;
    }

    .suggestion-cards {
        grid-template-columns: 1fr;
    }

    .pricing-cards {
        grid-template-columns: 1fr;
    }

    .modal-content {
        margin: var(--spacing-md);
        max-width: calc(100vw - 2rem);
    }

    /* Mobile welcome logo fix */
    .welcome-logo .maple-icon {
        width: 6rem;
        height: 6rem;
        margin-bottom: var(--spacing-md);
    }

    /* Mobile input footer spacing */
    .input-footer {
        padding: 0 var(--spacing-sm);
        justify-content: space-between;
        align-items: flex-start;
        font-size: 0.625rem;
        max-width: calc(100vw - 2rem);
        margin: 0 auto;
        gap: var(--spacing-md);
        flex-wrap: wrap;
    }

    .input-footer .character-count {
        text-align: left;
        flex: 0 0 auto;
        white-space: nowrap;
        margin-right: auto;
        order: 1;
    }

    .input-footer .model-info {
        text-align: right;
        flex: 0 0 auto;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-left: auto;
        max-width: 60%;
        order: 2;
    }

    /* Mobile input text size */
    #messageInput {
        font-size: 0.8rem;
    }
}

/* Scrollbar personnalisée */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* États de chargement - 3 points qui grossissent et rapetissent */
.loading {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: var(--spacing-sm) 0;
    vertical-align: middle;
    position: relative;
}

/* Premier point */
.loading::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: loading-dot 1.4s ease-in-out infinite both;
    animation-delay: 0s;
}

/* Deuxième point */
.loading::after {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: loading-dot 1.4s ease-in-out infinite both;
    animation-delay: 0.2s;
}

/* Troisième point - créé avec un span à l'intérieur */
.loading .dot {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: loading-dot 1.4s ease-in-out infinite both;
    animation-delay: 0.4s;
}

/* Enhanced loading visibility for message content */
.message-content .loading {
    margin: var(--spacing-md) 0;
    display: inline-flex;
}

.message-content .loading::before,
.message-content .loading::after,
.message-content .loading .dot {
    background: var(--accent-primary);
}

/* Loading in user messages (green background) */
.message.user .message-content .loading::before,
.message.user .message-content .loading::after,
.message.user .message-content .loading .dot {
    background: rgba(255, 255, 255, 0.9);
}

/* Animation des points - grossissement et changement de couleur */
@keyframes loading-dot {
    0% {
        transform: scale(0.8);
        background-color: var(--accent-primary);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        background-color: var(--accent-hover);
        opacity: 1;
    }
    100% {
        transform: scale(0.8);
        background-color: var(--accent-primary);
        opacity: 0.5;
    }
}

/* Animation pour les messages utilisateur */
.message.user .message-content .loading::before,
.message.user .message-content .loading::after,
.message.user .message-content .loading .dot {
    animation-name: loading-dot-user;
}

@keyframes loading-dot-user {
    0% {
        transform: scale(0.8);
        background-color: rgba(255, 255, 255, 0.6);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        background-color: rgba(255, 255, 255, 0.9);
        opacity: 1;
    }
    100% {
        transform: scale(0.8);
        background-color: rgba(255, 255, 255, 0.6);
        opacity: 0.5;
    }
}

/* Animation de rotation pour compatibilité */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Effet de frappe avec brillance */
.typing-char {
    display: inline-block;
    opacity: 0;
    animation: shine 0.6s ease-out forwards;
    text-shadow: 0 0 8px rgba(16, 163, 127, 0.3);
}

@keyframes shine {
    0% {
        opacity: 0;
        text-shadow: 0 0 8px rgba(16, 163, 127, 0.3);
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        text-shadow: 0 0 20px rgba(16, 163, 127, 0.8), 0 0 30px rgba(16, 163, 127, 0.6);
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        text-shadow: 0 0 8px rgba(16, 163, 127, 0.3);
        transform: scale(1);
    }
}

/* Links in messages - Enhanced visibility */
.message-content a {
    color: var(--accent-primary);
    text-decoration: underline;
    text-decoration-color: var(--accent-primary);
    text-underline-offset: 2px;
    transition: var(--transition-fast);
    font-weight: 500;
}

.message-content a:hover {
    color: var(--accent-hover);
    text-decoration-color: var(--accent-hover);
    text-shadow: 0 0 8px rgba(16, 163, 127, 0.3);
}

.message-content a:visited {
    color: #8b5cf6; /* Purple for visited links */
    text-decoration-color: #8b5cf6;
}

.message-content a:visited:hover {
    color: #7c3aed;
    text-decoration-color: #7c3aed;
    text-shadow: 0 0 8px rgba(139, 92, 246, 0.3);
}

/* Links in user messages (on green background) */
.message.user .message-content a {
    color: rgba(255, 255, 255, 0.95);
    text-decoration-color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
}

.message.user .message-content a:hover {
    color: #ffffff;
    text-decoration-color: #ffffff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

.message.user .message-content a:visited {
    color: rgba(255, 255, 255, 0.85);
    text-decoration-color: rgba(255, 255, 255, 0.7);
}

.message.user .message-content a:visited:hover {
    color: rgba(255, 255, 255, 0.95);
    text-decoration-color: rgba(255, 255, 255, 0.8);
}

/* Code syntax highlighting */
pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    overflow-x: auto;
    margin: var(--spacing-md) 0;
    position: relative;
    box-shadow: var(--shadow-light);
}

/* Enhanced code blocks with header */
pre code {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-primary);
    display: block;
}

/* Inline code */
code {
    background: var(--bg-tertiary);
    padding: 3px 6px;
    border-radius: var(--radius-sm);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.875rem;
    color: var(--accent-primary);
    border: 1px solid var(--border-color);
}

/* Code block styling with language indicator */
pre::before {
    content: 'Code';
    position: absolute;
    top: 0;
    right: 0;
    background: var(--accent-primary);
    color: white;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 500;
    border-bottom-left-radius: var(--radius-sm);
    border-top-right-radius: var(--radius-md);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Language-specific styling */
pre[data-language="python"]::before,
pre:has(code:contains("python"))::before {
    content: 'Python';
    background: #3776ab;
}

pre[data-language="javascript"]::before,
pre:has(code:contains("javascript"))::before {
    content: 'JavaScript';
    background: #f7df1e;
    color: #000;
}

pre[data-language="html"]::before,
pre:has(code:contains("html"))::before {
    content: 'HTML';
    background: #e34f26;
}

pre[data-language="css"]::before,
pre:has(code:contains("css"))::before {
    content: 'CSS';
    background: #1572b6;
}

/* Enhanced visual distinction for code blocks */
.message-content pre {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-tertiary) 100%);
    border-left: 4px solid var(--accent-primary);
    box-shadow: 
        0 2px 8px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Copy button for code blocks */
pre {
    position: relative;
}

pre:hover::after {
    content: '📋';
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0.7;
    transition: var(--transition-fast);
    z-index: 10;
}

pre:hover::after:hover {
    opacity: 1;
    background: var(--bg-hover);
}

/* Copy success feedback for code blocks */
pre.copy-success::after {
    content: var(--copy-feedback, '✓') !important;
    opacity: 1 !important;
    background: var(--accent-primary) !important;
    color: white !important;
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(16, 163, 127, 0.3);
}

/* Enhanced copy button interaction */
pre::after {
    transition: all 0.2s ease;
}

pre:hover::after {
    content: '📋';
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0.7;
    transition: var(--transition-fast);
    z-index: 10;
}

/* Thème clair (optionnel) */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --bg-hover: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: #dee2e6;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.05);
    --avatar-border-width: 2px;
}

/* Links in light theme */
[data-theme="light"] .message-content a {
    color: #0066cc;
    text-decoration-color: #0066cc;
}

[data-theme="light"] .message-content a:hover {
    color: #004499;
    text-decoration-color: #004499;
    text-shadow: 0 0 8px rgba(0, 100, 153, 0.3);
}

[data-theme="light"] .message-content a:visited {
    color: #6b46c1;
    text-decoration-color: #6b46c1;
}

[data-theme="light"] .message-content a:visited:hover {
    color: #553c9a;
    text-decoration-color: #553c9a;
    text-shadow: 0 0 8px rgba(107, 70, 193, 0.3);
}

/* Links in user messages in light theme (still on green background) */
[data-theme="light"] .message.user .message-content a {
    color: rgba(255, 255, 255, 0.95);
    text-decoration-color: rgba(255, 255, 255, 0.8);
    font-weight: 600;
}

[data-theme="light"] .message.user .message-content a:hover {
    color: #ffffff;
    text-decoration-color: #ffffff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

/* Auth Modal Styles */
.auth-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.auth-modal.active {
    display: flex;
}

.auth-modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    max-width: 450px;
    width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: modalSlideIn 0.3s ease;
}

.auth-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.auth-modal-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.auth-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.auth-close-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.auth-modal-body {
    padding: var(--spacing-xl);
}

.auth-welcome {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.auth-logo {
    margin-bottom: var(--spacing-md);
}

.auth-logo .maple-icon {
    width: 3rem;
    height: 3rem;
}

.auth-welcome p {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.5;
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.auth-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    text-decoration: none;
}

.auth-btn.primary {
    background: var(--accent-primary);
    color: white;
}

.auth-btn.primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.auth-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.auth-btn.secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: var(--spacing-lg) 0;
    text-align: center;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.auth-divider span {
    padding: 0 var(--spacing-md);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.auth-social-buttons {
    margin-bottom: var(--spacing-xl);
}

.auth-btn.google {
    background: #ffffff;
    color: #3c4043;
    border: 1px solid #dadce0;
    transition: var(--transition-fast);
}

.auth-btn.google:hover {
    background: #f8f9fa;
    border-color: #c4c7c5;
    transform: translateY(-1px);
    box-shadow: 0 1px 3px rgba(60, 64, 67, 0.3);
}

.google-icon {
    flex-shrink: 0;
}

.auth-features {
    border-top: 1px solid var(--border-color);
    padding-top: var(--spacing-lg);
}

.feature-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.feature-item:last-child {
    margin-bottom: 0;
}

.feature-item i {
    color: var(--accent-primary);
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

/* Usage Limit Modal Styles */
.usage-limit-content {
    text-align: center;
}

.usage-icon {
    margin-bottom: var(--spacing-lg);
}

.usage-icon i {
    font-size: 3rem;
    color: var(--accent-secondary);
}

.usage-limit-content p {
    font-size: 1.125rem;
    margin-bottom: var(--spacing-lg);
    color: var(--text-primary);
}

.usage-stats {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.usage-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
    font-size: 0.875rem;
}

.usage-stat-item:last-child {
    margin-bottom: 0;
}

.usage-stat-label {
    color: var(--text-secondary);
}

.usage-stat-value {
    color: var(--text-primary);
    font-weight: 500;
}

.upgrade-suggestion {
    border-top: 1px solid var(--border-color);
    padding-top: var(--spacing-lg);
}

.upgrade-suggestion p {
    font-size: 1rem;
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
}

/* User Profile Updates for Auth */
.user-profile.authenticated .username {
    color: var(--accent-primary);
}

.user-profile.authenticated .avatar {
    border: var(--avatar-border-width) solid var(--avatar-border-auth);
}

/* Loading States */
.auth-btn.loading {
    position: relative;
    color: transparent;
}

.auth-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Responsive Auth Modal */
@media (max-width: 480px) {
    .auth-modal-content {
        margin: var(--spacing-md);
        max-width: calc(100vw - 2rem);
    }
    
    .auth-modal-body {
        padding: var(--spacing-lg);
    }
    
    .auth-buttons {
        gap: var(--spacing-sm);
    }
    
    .auth-btn {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: 0.875rem;
    }
}

/* Professional Table Styles for Messages */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--spacing-md) 0;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.message-content table thead {
    background: var(--accent-primary);
    color: white;
}

.message-content table thead th {
    padding: var(--spacing-md) var(--spacing-sm);
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--accent-hover);
}

.message-content table tbody tr {
    transition: var(--transition-fast);
    border-bottom: 1px solid var(--border-color);
}

.message-content table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.message-content table tbody tr:hover {
    background: var(--bg-hover);
    transform: scale(1.001);
}

.message-content table tbody tr:last-child {
    border-bottom: none;
}

.message-content table td {
    padding: var(--spacing-sm) var(--spacing-sm);
    vertical-align: top;
    line-height: 1.5;
    color: var(--text-primary);
}

.message-content table th {
    position: relative;
}

/* Table cell alignment classes */
.message-content table .text-center {
    text-align: center;
}

.message-content table .text-right {
    text-align: right;
}

.message-content table .text-left {
    text-align: left;
}

/* Numeric columns styling */
.message-content table td:has(+ td):last-child,
.message-content table td[data-type="number"] {
    text-align: right;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
    font-weight: 500;
}

/* Special styling for user messages (green background) */
.message.user .message-content table {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.message.user .message-content table thead {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.message.user .message-content table thead th {
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

.message.user .message-content table tbody tr {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.message.user .message-content table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.05);
}

.message.user .message-content table tbody tr:hover {
    background: rgba(255, 255, 255, 0.15);
}

.message.user .message-content table td {
    color: rgba(255, 255, 255, 0.95);
}

/* Responsive table design */
@media (max-width: 768px) {
    .message-content table {
        font-size: 0.75rem;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        scrollbar-width: thin;
        scrollbar-color: var(--border-color) transparent;
    }
    
    .message-content table::-webkit-scrollbar {
        height: 6px;
    }
    
    .message-content table::-webkit-scrollbar-track {
        background: var(--bg-secondary);
        border-radius: 3px;
    }
    
    .message-content table::-webkit-scrollbar-thumb {
        background: var(--border-color);
        border-radius: 3px;
    }
    
    .message-content table::-webkit-scrollbar-thumb:hover {
        background: var(--text-muted);
    }
    
    .message-content table thead th,
    .message-content table td {
        padding: var(--spacing-xs) var(--spacing-sm);
        min-width: 80px;
    }
}

/* Table with borders variant */
.message-content table.bordered {
    border: 2px solid var(--border-color);
}

.message-content table.bordered th,
.message-content table.bordered td {
    border: 1px solid var(--border-color);
}

.message.user .message-content table.bordered {
    border-color: rgba(255, 255, 255, 0.3);
}

.message.user .message-content table.bordered th,
.message.user .message-content table.bordered td {
    border-color: rgba(255, 255, 255, 0.2);
}

/* Compact table variant */
.message-content table.compact {
    margin: var(--spacing-sm) 0;
}

.message-content table.compact thead th,
.message-content table.compact td {
    padding: var(--spacing-xs) var(--spacing-sm);
}

/* Striped table variant */
.message-content table.striped tbody tr:nth-child(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.message.user .message-content table.striped tbody tr:nth-child(odd) {
    background: rgba(255, 255, 255, 0.08);
}

/* Light theme table adjustments */
[data-theme="light"] .message-content table {
    background: #ffffff;
    border-color: #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .message-content table thead {
    background: var(--accent-primary);
}

[data-theme="light"] .message-content table tbody tr {
    border-bottom-color: #dee2e6;
}

[data-theme="light"] .message-content table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

[data-theme="light"] .message-content table tbody tr:hover {
    background: #e9ecef;
}

[data-theme="light"] .message-content table td {
    color: var(--text-primary);
}

/* Professional Content Styling for Messages */

/* Headings in messages */
.message-content h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin: var(--spacing-lg) 0 var(--spacing-md) 0;
    line-height: 1.3;
    border-bottom: 2px solid var(--accent-primary);
    padding-bottom: var(--spacing-sm);
    position: relative;
}

.message-content h1::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-secondary), var(--accent-primary));
    border-radius: 1px;
}

.message-content h2 {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: var(--spacing-lg) 0 var(--spacing-sm) 0;
    line-height: 1.4;
    position: relative;
    padding-left: var(--spacing-md);
}

.message-content h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 20px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 2px;
}

.message-content h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: var(--spacing-md) 0 var(--spacing-sm) 0;
    line-height: 1.4;
}

.message-content h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-primary);
    margin: var(--spacing-md) 0 var(--spacing-xs) 0;
    line-height: 1.4;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.875rem;
}

/* Lists in messages */
.message-content ol,
.message-content ul {
    margin: var(--spacing-md) 0;
    padding-left: var(--spacing-xl);
    line-height: 1.6;
}

.message-content ol {
    counter-reset: custom-counter;
    list-style: none;
    padding-left: 0;
}

.message-content ol li {
    counter-increment: custom-counter;
    position: relative;
    margin-bottom: var(--spacing-sm);
    padding-left: var(--spacing-xl);
    line-height: 1.6;
}

.message-content ol li::before {
    content: counter(custom-counter);
    position: absolute;
    left: 0;
    top: 0;
    background: var(--accent-primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: var(--shadow-light);
}

.message-content ul li {
    position: relative;
    margin-bottom: var(--spacing-sm);
    padding-left: var(--spacing-md);
    line-height: 1.6;
}

.message-content ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.6em;
    width: 6px;
    height: 6px;
    background: var(--accent-primary);
    border-radius: 50%;
    transform: translateY(-50%);
}

/* Nested lists */
.message-content ol ol,
.message-content ul ul,
.message-content ol ul,
.message-content ul ol {
    margin: var(--spacing-xs) 0;
    padding-left: var(--spacing-lg);
}

.message-content ul ul li::before {
    background: var(--accent-secondary);
    width: 4px;
    height: 4px;
}

.message-content ol ol li::before {
    background: var(--accent-secondary);
    font-size: 0.625rem;
    width: 20px;
    height: 20px;
}

/* Enhanced code styling */
.message-content code {
    background: var(--bg-primary);
    color: var(--accent-primary);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    font-weight: 500;
    letter-spacing: 0.25px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-content pre code {
    background: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    color: var(--text-primary);
    font-weight: 400;
    letter-spacing: 0;
}

/* Code blocks with syntax highlighting simulation */
.message-content pre {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-tertiary) 100%);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-primary);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin: var(--spacing-md) 0;
    overflow-x: auto;
    position: relative;
    box-shadow: 
        var(--shadow-light),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
    line-height: 1.5;
}

.message-content pre::before {
    content: 'Code';
    position: absolute;
    top: 0;
    right: 0;
    background: var(--accent-primary);
    color: white;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border-bottom-left-radius: var(--radius-sm);
    border-top-right-radius: var(--radius-md);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Inter', sans-serif;
}

/* Blockquotes */
.message-content blockquote {
    margin: var(--spacing-md) 0;
    padding: var(--spacing-md) var(--spacing-lg);
    border-left: 4px solid var(--accent-primary);
    background: var(--bg-tertiary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-style: italic;
    color: var(--text-secondary);
    position: relative;
}

.message-content blockquote::before {
    content: '"';
    position: absolute;
    top: -10px;
    left: var(--spacing-md);
    font-size: 3rem;
    color: var(--accent-primary);
    opacity: 0.3;
    font-family: serif;
    line-height: 1;
}

/* Paragraphs */
.message-content p {
    margin: var(--spacing-sm) 0;
    line-height: 1.7;
    color: var(--text-primary);
}

.message-content p:first-child {
    margin-top: 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Strong and emphasis */
.message-content strong {
    font-weight: 600;
    color: var(--accent-primary);
}

.message-content em {
    font-style: italic;
    color: var(--accent-secondary);
}

/* Horizontal rules */
.message-content hr {
    border: none;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
    margin: var(--spacing-lg) 0;
}

/* Special styling for user messages */
.message.user .message-content h1,
.message.user .message-content h2,
.message.user .message-content h3,
.message.user .message-content h4 {
    color: rgba(255, 255, 255, 0.95);
}

.message.user .message-content h1 {
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

.message.user .message-content h1::after {
    background: rgba(255, 255, 255, 0.5);
}

.message.user .message-content h2::before {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.6));
}

.message.user .message-content ol li::before {
    background: rgba(255, 255, 255, 0.8);
    color: var(--accent-primary);
}

.message.user .message-content ul li::before {
    background: rgba(255, 255, 255, 0.8);
}

.message.user .message-content code {
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.2);
}

.message.user .message-content pre {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    border-left-color: rgba(255, 255, 255, 0.5);
}

.message.user .message-content pre::before {
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
}

.message.user .message-content blockquote {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.8);
}

.message.user .message-content strong {
    color: rgba(255, 255, 255, 0.95);
}

.message.user .message-content em {
    color: rgba(255, 255, 255, 0.85);
}

/* Light theme adjustments */
[data-theme="light"] .message-content h1 {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

[data-theme="light"] .message-content h2,
[data-theme="light"] .message-content h3 {
    color: #1a1a1a;
}

[data-theme="light"] .message-content code {
    background: #f8f9fa;
    color: var(--accent-primary);
    border-color: #e9ecef;
}

[data-theme="light"] .message-content pre {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-color: #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .message-content blockquote {
    background: #f8f9fa;
    color: #6c757d;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .message-content {
        font-size: 0.85rem;
        padding: var(--spacing-md);
    }

    .message-content p,
    .message-content ol,
    .message-content ul {
        font-size: 0.85rem;
    }

    .message-content h1 {
        font-size: 1.25rem;
    }
    
    .message-content h2 {
        font-size: 1.05rem;
    }

    .message-content h3 {
        font-size: 0.98rem;
    }

    .message-content h4 {
        font-size: 0.9rem;
    }
    
    .message-content ol,
    .message-content ul {
        padding-left: var(--spacing-lg);
    }
    
    .message-content ol li {
        padding-left: var(--spacing-lg);
    }
    
    .message-content ol li::before {
        width: 20px;
        height: 20px;
        font-size: 0.625rem;
    }
    
    .message-content pre {
        padding: var(--spacing-md);
        font-size: 0.75rem;
    }

    .message-content table thead th {
        font-size: 0.7rem;
    }
}

@media (max-width: 480px) {
    .message-content {
        font-size: 0.8rem;
    }

    .message-content p,
    .message-content ol,
    .message-content ul {
        font-size: 0.8rem;
    }

    .message-content h1 {
        font-size: 1.1rem;
    }

    .message-content h2 {
        font-size: 0.95rem;
    }

    .message-content h3 {
        font-size: 0.9rem;
    }

    .message-content h4 {
        font-size: 0.82rem;
    }

    .message-content table thead th {
        font-size: 0.65rem;
    }
}

/* Print styles */
@media print {
    .message-content h1,
    .message-content h2,
    .message-content h3,
    .message-content h4 {
        color: #000 !important;
        break-after: avoid;
    }

    .message-content pre,
    .message-content blockquote {
        break-inside: avoid;
        background: #f8f9fa !important;
        border-color: #dee2e6 !important;
    }

    .message-content ol li::before,
    .message-content ul li::before {
        background: #000 !important;
    }
}

/* ===========================================
   ANIMATION D'ATTENTE ÉLÉGANTE (STYLE CHATGPT)
   =========================================== */

/* Conteneur principal simple */
.progress-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) 0;
    min-height: 2rem;
}

/* Conteneur du texte avec frappe */
.progress-text-container {
    display: flex;
    align-items: center;
    gap: 1px;
    min-height: 1.2em;
}

/* Texte qui se tape */
.progress-text {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: nowrap;
}

/* Curseur clignotant */
.progress-cursor {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--accent-primary);
    animation: blink 1s infinite;
    margin-left: 1px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Points animés comme ChatGPT */
.progress-dots {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-top: var(--spacing-xs);
}

.progress-dots .dot {
    width: 4px;
    height: 4px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite both;
}

.progress-dots .dot.delay-1 {
    animation-delay: 0.2s;
}

.progress-dots .dot.delay-2 {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Animation d'entrée douce */
.progress-container {
    animation: fadeInSmooth 0.3s ease-out;
}

@keyframes fadeInSmooth {
    0% {
        opacity: 0;
        transform: translateY(5px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .progress-text {
        font-size: 0.8rem;
    }

    .progress-cursor {
        font-size: 0.8rem;
    }

    .progress-dots .dot {
        width: 3px;
        height: 3px;
    }
}

.google-auth-btn:hover {
    background: #f8f9fa;
}

.cta-button {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.cta-button.cta-upgrade {
    box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
}

.cta-button.cta-upgrade:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 53, 0.4);
}

.cta-button.cta-auth {
    box-shadow: 0 4px 15px rgba(16, 163, 127, 0.3);
}

.cta-button.cta-auth:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 163, 127, 0.4);
}
