/* Reset et variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #000000;
    --bg-secondary: #111111;
    --bg-tertiary: #1a1a1a;
    --bg-quaternary: #222222;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-tertiary: #808080;
    --accent: #ffffff;
    --accent-hover: #e0e0e0;
    --border: #333333;
    --border-light: #444444;
    --shadow: rgba(0, 0, 0, 0.5);
    --success: #4caf50;
    --error: #f44336;
    --warning: #ff9800;
    --info: #2196f3;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

/* Container général */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    padding-top: 40px;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Formulaires d'authentification */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    min-height: 60vh;
}

.auth-form {
    background: var(--bg-secondary);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 400px;
    transition: all 0.3s ease;
}

.auth-form:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--shadow);
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-primary);
    font-size: 1.8rem;
    font-weight: 600;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    transition: all 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-quaternary);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--text-primary);
    border: none;
    border-radius: 8px;
    color: var(--bg-primary);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.switch-form {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
}

.switch-form a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.switch-form a:hover {
    color: var(--accent-hover);
}

/* Messages d'erreur et de succès */
.error-message,
.success-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 20px auto;
    max-width: 400px;
    text-align: center;
    font-weight: 500;
    font-size: 14px;
}

.error-message {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
}

.success-message {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

/* Utilitaires */
.hidden {
    display: none !important;
}

.model-popup:not(.hidden) {
    display: flex !important;
}

.currency-dropdown:not(.hidden) {
    display: block !important;
}

/* Layout Chat avec Sidebar */
.chat-layout {
    display: flex;
    height: 100vh;
    background: var(--bg-primary);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.sidebar-header h3 {
    color: var(--text-primary);
    font-size: 1.4rem;
    margin-bottom: 16px;
    text-align: center;
    font-weight: 600;
}

.header-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.new-chat-btn, .admin-btn {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
}

.new-chat-btn {
    background: var(--text-primary);
    color: var(--bg-primary);
}

.new-chat-btn:hover {
    background: var(--accent-hover);
}

.admin-btn {
    background: var(--bg-quaternary);
    color: var(--text-primary);
}

.admin-btn:hover {
    background: var(--border-light);
}

/* Wallet Info */
.wallet-info {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
}

.wallet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.wallet-info h4 {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.wallet-item {
    text-align: center;
}

.balance-display {
    font-size: 16px;
    font-weight: 600;
    color: var(--success);
    font-family: monospace;
}

/* Conversations List */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-item {
    padding: 12px;
    margin-bottom: 4px;
    background: var(--bg-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.conversation-item:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
}

.conversation-item.active {
    background: var(--bg-tertiary);
    border-color: var(--text-primary);
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.conversation-title {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.4;
    flex: 1;
    margin-right: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.delete-conversation {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
    flex-shrink: 0;
}

.delete-conversation:hover {
    background: var(--error);
    color: white;
}

.conversation-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.conversation-date {
    font-size: 11px;
    color: var(--text-tertiary);
}

.conversation-model {
    font-size: 10px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
}

.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logout-btn-small {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.logout-btn-small:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

/* Chat Interface */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-width: 0;
}

.chat-header {
    background: var(--bg-secondary);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h2 {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
}

.settings-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 500;
}

.settings-btn:hover {
    border-color: var(--border-light);
    background: var(--bg-quaternary);
}

.settings-btn svg {
    width: 16px;
    height: 16px;
}

/* Nouveau bouton sélecteur de modèles */
.model-selector-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.model-selector-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.model-selector-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 250px;
    max-width: 450px;
    gap: 8px;
}

.model-selector-btn:hover {
    border-color: var(--border-light);
    background: var(--bg-quaternary);
}

.current-model-display {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-arrow {
    font-size: 10px;
    transition: transform 0.2s ease;
}

.model-selector-btn.open .dropdown-arrow {
    transform: rotate(180deg);
}

.model-count-info {
    color: var(--text-tertiary);
    font-size: 11px;
    margin-top: 2px;
    line-height: 1.3;
}

.model-count-info a {
    color: var(--warning);
    text-decoration: none;
}

.model-count-info a:hover {
    text-decoration: underline;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Interface de bienvenue moderne */
.new-chat-welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 40px 20px;
}

.welcome-container {
    text-align: center;
    max-width: 650px;
    width: 100%;
}

.welcome-title {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 40px;
    letter-spacing: -0.02em;
}

.welcome-input-container {
    display: flex;
    justify-content: center;
    width: 100%;
}

.welcome-input-wrapper {
    position: relative;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 600px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.welcome-input-wrapper:focus-within {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.welcome-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    padding: 8px 0;
    outline: none;
}

.welcome-input::placeholder {
    color: var(--text-secondary);
    font-weight: 400;
}

.welcome-input-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tool-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
}

.tool-btn:hover {
    background: var(--bg-quaternary);
    color: var(--text-primary);
    transform: scale(1.05);
}

.tool-btn:disabled,
.tool-btn.disabled {
    color: var(--text-tertiary);
    cursor: not-allowed;
    opacity: 0.5;
}

.tool-btn:disabled:hover,
.tool-btn.disabled:hover {
    background: transparent;
    color: var(--text-tertiary);
    transform: none;
}

.tool-btn.send-btn-welcome {
    background: var(--text-primary);
    color: var(--bg-primary);
}

.tool-btn.send-btn-welcome:hover {
    background: var(--accent-hover);
    color: var(--bg-primary);
    transform: scale(1.05);
}

.tool-btn svg {
    width: 20px;
    height: 20px;
    stroke-width: 1.5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .welcome-title {
        font-size: 2rem;
        margin-bottom: 30px;
    }
    
    .welcome-input-wrapper,
    .modern-input-wrapper {
        margin: 0 10px;
        padding: 10px 16px;
        max-width: calc(100% - 20px);
    }
    
    .welcome-input,
    .modern-chat-input {
        font-size: 14px;
    }
    
    .tool-btn {
        width: 32px;
        height: 32px;
        padding: 6px;
    }
    
    .tool-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .chat-input-container {
        padding: 15px 10px;
    }
}

/* Anciens styles pour compatibilité */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.welcome-message h3 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-weight: 600;
}

.welcome-message p {
    font-size: 14px;
    line-height: 1.6;
}

/* Messages */
.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user {
    background: var(--bg-secondary);
    color: var(--text-primary);
    align-self: flex-end;
    border: 1px solid var(--border);
}

.message.assistant {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    align-self: flex-start;
    border: 1px solid var(--border);
}

.message-info {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-tertiary);
    border-top: 1px solid var(--border);
    padding-top: 6px;
}

.message-cost {
    color: var(--warning);
    font-weight: 600;
    background: rgba(255, 152, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.message-cost-free {
    color: var(--success);
    font-weight: 600;
    background: rgba(76, 175, 80, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Style pour l'affichage du modèle réellement utilisé avec Auto */
.message-info strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Indicateur de modèle actuel */
.active-model-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
}

.active-model-label {
    color: var(--text-tertiary);
    font-weight: 500;
}

.active-model-name {
    color: var(--text-primary);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Chat Input */
.chat-input-container {
    padding: 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

/* Cacher l'input principal quand l'interface de bienvenue est active */
.chat-container.has-welcome .chat-input-container {
    display: none;
}

/* Interface moderne pour le chat en conversation */
.modern-chat-form {
    width: 100%;
}

.modern-input-container {
    display: flex;
    justify-content: center;
    width: 100%;
}

.modern-input-wrapper {
    position: relative;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 800px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.modern-input-wrapper:focus-within {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.modern-chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    padding: 8px 0;
    outline: none;
    resize: none;
    min-height: 20px;
    max-height: 120px;
    line-height: 1.4;
}

.modern-chat-input::placeholder {
    color: var(--text-secondary);
    font-weight: 400;
}

.modern-input-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Anciens styles pour compatibilité */
.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 12px;
    transition: border-color 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--text-primary);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    resize: none;
    min-height: 20px;
    max-height: 120px;
    padding: 4px 0;
}

.chat-input:focus {
    outline: none;
}

.chat-input::placeholder {
    color: var(--text-tertiary);
}

.send-btn {
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover {
    background: var(--accent-hover);
}

.send-btn:disabled {
    background: var(--border);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

/* Model Popup */
.model-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    cursor: pointer;
}

.popup-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border);
    width: 100%;
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    box-shadow: 0 10px 40px var(--shadow);
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.header-left h3 {
    margin: 0 0 4px 0;
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 600;
}

.model-stats {
    font-size: 12px;
    color: var(--text-secondary);
}

.close-btn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

/* Current Model Display */
.current-model {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.current-model-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.current-model-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.current-model-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.current-model-provider {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-quaternary);
    padding: 2px 8px;
    border-radius: 4px;
}

.current-model-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.current-model-badge.free {
    background: var(--success);
    color: white;
}

.current-model-badge.paid {
    background: var(--warning);
    color: white;
}

/* Advanced Controls */
.advanced-controls {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.search-container {
    margin-bottom: 12px;
}

.search-container input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-quaternary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
}

.search-container input:focus {
    outline: none;
    border-color: var(--text-primary);
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.filter-row select {
    background: var(--bg-quaternary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
}

.filter-row select:focus {
    outline: none;
    border-color: var(--text-primary);
}

.quick-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.quick-filter {
    background: var(--bg-quaternary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.quick-filter:hover {
    border-color: var(--text-primary);
    background: var(--bg-secondary);
}

.quick-filter.active {
    background: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
}

/* Results Info */
.results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 12px;
}

.clear-filters {
    background: var(--error);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.2s ease;
}

.clear-filters:hover {
    background: #d32f2f;
}

/* Models Grid */
.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.model-card {
    position: relative;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.model-card:hover {
    border-color: var(--text-primary);
    background: var(--bg-quaternary);
}

.model-card.selected {
    border-color: var(--text-primary);
    background: var(--bg-quaternary);
    box-shadow: 0 0 0 1px var(--text-primary);
}

.selection-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--text-primary);
    color: var(--bg-primary);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

.model-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.model-name-section {
    flex: 1;
    margin-right: 8px;
}

.model-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 2px;
}

.model-id {
    font-size: 10px;
    color: var(--text-tertiary);
    font-family: monospace;
}

.model-badges {
    display: flex;
    gap: 4px;
    flex-direction: column;
    align-items: flex-end;
}

.provider-category {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.model-provider {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.model-category {
    font-size: 10px;
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.model-context {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}

.model-description {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
    margin-bottom: 8px;
}

.free-badge {
    background: var(--success);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

.cost-badge {
    background: var(--warning);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

.recommendation-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: var(--info);
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 9px;
    font-weight: 600;
}

/* Popup avancée de sélection de modèles */
.advanced-model-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.advanced-model-popup:not(.hidden) {
    display: flex !important;
}

.advanced-popup {
    max-width: 1000px;
    max-height: 90vh;
    width: 100%;
}

/* Section modèle actuel dans la popup */
.current-selection {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.current-selection-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.current-selection-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.selection-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.selection-provider {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-quaternary);
    padding: 2px 8px;
    border-radius: 4px;
}

.selection-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.selection-badge.free {
    background: var(--success);
    color: white;
}

.selection-badge.paid {
    background: var(--warning);
    color: white;
}

/* Filtres avancés */
.advanced-filters {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-bar input {
    width: 100%;
    padding: 12px 40px 12px 12px;
    background: var(--bg-quaternary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--text-primary);
}

.clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.clear-search:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

.filter-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-group select {
    background: var(--bg-quaternary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--text-primary);
}

.quick-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-filter-btn {
    background: var(--bg-quaternary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 18px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.quick-filter-btn:hover {
    border-color: var(--text-primary);
    background: var(--bg-secondary);
}

.quick-filter-btn.active {
    background: var(--text-primary);
    color: var(--bg-primary);
    border-color: var(--text-primary);
}

/* Container des modèles */
.models-container {
    max-height: 400px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
    padding-right: 4px;
}

/* Cartes de modèles avancées */
.advanced-model-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.advanced-model-card:hover {
    border-color: var(--text-primary);
    background: var(--bg-quaternary);
    transform: translateY(-1px);
}

.advanced-model-card.selected {
    border-color: var(--text-primary);
    background: var(--bg-quaternary);
    box-shadow: 0 0 0 1px var(--text-primary);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.model-info {
    flex: 1;
}

.model-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 4px;
}

.model-meta {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.provider-tag, .category-tag {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.provider-tag {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.category-tag {
    background: var(--bg-quaternary);
    color: var(--text-tertiary);
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.favorite-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-tertiary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: all 0.2s ease;
}

.favorite-btn:hover {
    border-color: var(--warning);
    color: var(--warning);
}

.favorite-btn.favorited {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}

.selected-indicator {
    background: var(--text-primary);
    color: var(--bg-primary);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

.card-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.price-badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.price-badge.free {
    background: var(--success);
    color: white;
}

.price-badge.paid {
    background: var(--warning);
    color: white;
}

.context-info {
    font-size: 11px;
    color: var(--text-tertiary);
}

.model-description {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: 8px;
}

/* Sync Notice */
.sync-notice {
    background: rgba(255, 152, 0, 0.1);
    border: 1px solid var(--warning);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
}

.sync-notice-content h4 {
    color: var(--warning);
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
}

.sync-notice-content p {
    color: var(--text-secondary);
    margin: 0 0 12px 0;
    font-size: 13px;
    line-height: 1.4;
}

.sync-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.sync-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.sync-btn.admin {
    background: var(--text-primary);
    color: var(--bg-primary);
}

.sync-btn.admin:hover {
    background: var(--accent-hover);
}

.sync-btn.user {
    background: var(--warning);
    color: white;
}

.sync-btn.user:hover {
    background: #e0a800;
}

.sync-btn.dismiss {
    background: var(--bg-quaternary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.sync-btn.dismiss:hover {
    background: var(--bg-tertiary);
}

/* Loading Animations */
.loading-message {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border) !important;
    animation: pulse 2s infinite;
}

.loading-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.typing-indicator {
    display: flex;
    gap: 3px;
    align-items: center;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-primary);
    border-radius: 50%;
    animation: typingDots 1.5s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

.loading-text {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 13px;
}

@keyframes typingDots {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.7;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.2);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(255, 255, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

/* Typing Effect */
.message-text {
    line-height: 1.5;
}

.message.assistant:not(.typing-complete) .message-text::after {
    content: '|';
    color: var(--text-primary);
    animation: blink 1s infinite;
    margin-left: 2px;
}

.message.assistant.typing-complete .message-text::after {
    display: none;
}

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

/* Markdown Styles */
.message.assistant h1,
.message.assistant h2,
.message.assistant h3,
.message.assistant h4,
.message.assistant h5,
.message.assistant h6 {
    color: var(--text-primary);
    margin: 12px 0 8px 0;
    font-weight: 600;
}

.message.assistant h1 { font-size: 1.4em; }
.message.assistant h2 { font-size: 1.3em; }
.message.assistant h3 { font-size: 1.2em; }
.message.assistant h4 { font-size: 1.1em; }
.message.assistant h5 { font-size: 1em; }
.message.assistant h6 { font-size: 0.9em; }

.message.assistant p {
    margin: 8px 0;
    line-height: 1.6;
    color: var(--text-primary);
}

.message.assistant ul,
.message.assistant ol {
    margin: 8px 0;
    padding-left: 20px;
    color: var(--text-primary);
}

.message.assistant li {
    margin: 4px 0;
    line-height: 1.4;
}

.message.assistant blockquote {
    border-left: 3px solid var(--border-light);
    margin: 12px 0;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 4px;
    color: var(--text-secondary);
    font-style: italic;
}

.message.assistant code {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    border: 1px solid var(--border);
}

.message.assistant pre {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
    overflow-x: auto;
}

.message.assistant pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: var(--text-primary);
    font-size: 0.85em;
    line-height: 1.4;
}

.message.assistant strong {
    color: var(--text-primary);
    font-weight: 700;
}

.message.assistant em {
    color: var(--text-secondary);
    font-style: italic;
}

.message.assistant a {
    color: var(--text-primary);
    text-decoration: underline;
    transition: opacity 0.2s ease;
}

.message.assistant a:hover {
    opacity: 0.8;
}

.message.assistant table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.message.assistant th,
.message.assistant td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    text-align: left;
}

.message.assistant th {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
}

.message.assistant td {
    background: var(--bg-tertiary);
}

.message.assistant hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
        order: 2;
    }

    .chat-container {
        order: 1;
        height: 60vh;
    }

    .conversations-list {
        max-height: 200px;
        overflow-y: auto;
    }

    .conversation-item {
        padding: 10px;
    }

    .conversation-title {
        font-size: 13px;
    }

    .popup-content {
        margin: 10px;
        padding: 16px;
        max-height: 90vh;
    }

    .models-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .filter-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .quick-filters {
        justify-content: center;
    }

    .current-model-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .input-wrapper {
        flex-direction: column;
        gap: 8px;
    }

    .send-btn {
        align-self: flex-end;
        width: auto;
        min-width: 80px;
    }

    .container {
        padding: 10px;
    }

    .auth-form {
        padding: 24px;
        margin: 10px;
    }

    .message {
        max-width: 95%;
        padding: 10px 12px;
        font-size: 13px;
    }

    .chat-messages {
        padding: 12px;
        gap: 12px;
    }

    .chat-input-container {
        padding: 12px;
    }

    .sidebar-header {
        padding: 16px;
    }

    .header-buttons {
        flex-direction: row;
        gap: 8px;
    }

    .new-chat-btn, .admin-btn {
        flex: 1;
        padding: 8px 12px;
        font-size: 13px;
    }

    .wallet-info {
        padding: 12px 16px;
    }

    .sidebar-footer {
        padding: 12px 16px;
    }

    .user-info {
        flex-direction: column;
        gap: 8px;
        align-items: stretch;
    }

    .logout-btn-small {
        width: 100%;
        text-align: center;
    }

    header h1 {
        font-size: 2.2rem;
    }

    .model-header {
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
    }

    .model-badges {
        flex-direction: row;
        align-items: flex-start;
    }
    
    .model-selector-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .model-selector {
        min-width: 200px;
        max-width: 100%;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .chat-layout {
        height: 100vh;
    }

    .sidebar {
        max-height: 35vh;
    }

    .chat-container {
        height: 65vh;
    }

    .message {
        max-width: 100%;
        padding: 8px 10px;
        font-size: 12px;
    }

    .chat-messages {
        padding: 8px;
        gap: 10px;
    }

    .input-wrapper {
        padding: 6px 8px;
    }

    .chat-input {
        font-size: 13px;
    }

    .send-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .popup-content {
        margin: 5px;
        padding: 12px;
    }

    .model-card {
        padding: 12px;
        min-height: 100px;
    }

    .advanced-controls {
        padding: 12px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
    }
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* Selection styling */
::selection {
    background: var(--text-primary);
    color: var(--bg-primary);
}

/* === STYLES DOSSIERS === */

/* Section des dossiers */
.folders-section {
    padding: 12px 8px;
    border-bottom: 1px solid var(--border);
    overflow: visible;
}

.folders-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 4px;
}

.folders-header h4 {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.folder-actions {
    display: flex;
    gap: 4px;
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 12px;
    font-weight: 600;
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-light);
    color: var(--text-primary);
    transform: scale(1.05);
}

.folder-menu-btn {
    transition: all 0.2s ease;
}

.folder-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    transform: scale(1.1) !important;
    color: var(--text-primary) !important;
}

/* Liste des dossiers */
.folders-list {
    margin-bottom: 8px;
}

.folder-item {
    margin-bottom: 4px;
    border-radius: 6px;
    overflow: visible;
    transition: all 0.2s ease;
}

.folder-item:hover {
    background: var(--bg-tertiary);
}

.folder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-primary);
    border: 1px solid transparent;
    border-radius: 6px;
}

.folder-header:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
}

.folder-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.folder-chevron {
    color: var(--text-tertiary);
    font-size: 10px;
    transition: transform 0.2s ease;
    width: 12px;
    text-align: center;
}

.folder-chevron.expanded {
    transform: rotate(90deg);
    color: var(--text-secondary);
}

.folder-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.folder-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
    flex: 1;
}

.folder-count {
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 400;
    margin-left: 4px;
}

.folder-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* Conversations dans les dossiers */
.folder-conversations {
    display: none;
    padding: 0 0 0 32px;
    margin-top: 4px;
}

.folder-conversation {
    margin-bottom: 2px;
    padding: 8px 10px;
    border-radius: 4px;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.folder-conversation:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
}

.folder-conversation.active {
    background: var(--bg-tertiary);
    border-color: var(--text-primary);
}

.folder-conversation .conversation-title {
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.folder-conversation .conversation-meta {
    font-size: 10px;
}

.folder-conversation .conversation-date,
.folder-conversation .conversation-model {
    color: var(--text-tertiary);
    font-size: 10px;
}

/* Section conversations sans dossier */
.no-folder-section {
    padding: 12px 8px;
    flex: 1;
    overflow-y: auto;
}

.no-folder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 0 4px;
}

.no-folder-header h4 {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Modal de création/modification de dossier */
.folder-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.folder-modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.folder-modal h3 {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
}

.folder-form .form-group {
    margin-bottom: 20px;
}

.folder-form label {
    display: block;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 14px;
}

.folder-form input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.folder-form input[type="text"]:focus {
    outline: none;
    border-color: var(--text-primary);
}

/* Palette de couleurs */
.color-palette {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.color-option.selected {
    transform: scale(1.15);
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.color-option.selected::after {
    content: '✓';
    color: white;
    font-weight: bold;
    font-size: 14px;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

/* Actions du modal */
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--bg-quaternary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-primary {
    padding: 10px 20px;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

/* === INTERFACE DES DOSSIERS === */

.folder-interface {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 40px 20px;
}

.folder-container {
    text-align: center;
    max-width: 900px;
    width: 100%;
}

.folder-header-main {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 40px;
}

.folder-title-container {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
}

.folder-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.folder-title {
    font-size: 2.5rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin: 0;
}

.folder-input-container {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 40px;
}

.folder-input-wrapper {
    position: relative;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 700px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.folder-input-wrapper:focus-within {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.1);
}

.folder-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 16px;
    padding: 8px 0;
    outline: none;
}

.folder-input::placeholder {
    color: var(--text-secondary);
    font-weight: 400;
}

.folder-input-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

.folder-conversations-history {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    max-width: 100%;
}

.folder-conversation-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    position: relative;
}

.folder-conversation-card:hover {
    border-color: var(--text-primary);
    background: var(--bg-quaternary);
    transform: translateY(-2px);
}

.folder-conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.folder-conversation-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: 8px;
}

.folder-conversation-delete {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 16px;
    flex-shrink: 0;
}

.folder-conversation-delete:hover {
    background: var(--error);
    color: white;
    transform: scale(1.1);
}

.folder-conversation-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.folder-conversation-date {
    color: var(--text-tertiary);
}

.folder-conversation-model {
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
}

/* === MENUS DÉROULANTS DES DOSSIERS === */

.folder-menu-container {
    position: relative;
}

.folder-dropdown-menu {
    position: fixed;
    background: rgba(34, 34, 34, 0.95);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    min-width: 140px;
    padding: 6px 0;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    opacity: 0;
    transform: translateY(-8px) scale(0.9);
    transition: all 0.15s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    pointer-events: none;
    will-change: transform, opacity;
}

.folder-dropdown-menu:not(.hidden) {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.folder-dropdown-menu .dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all 0.1s ease;
    white-space: nowrap;
    border-radius: 4px;
    margin: 0 2px;
}

.folder-dropdown-menu .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(2px);
}

.folder-dropdown-menu .dropdown-item.delete-item {
    color: var(--error);
}

.folder-dropdown-menu .dropdown-item.delete-item:hover {
    background: rgba(244, 67, 54, 0.1);
}

.folder-dropdown-menu .dropdown-item i {
    font-size: 12px;
    width: 14px;
}

/* Responsive pour l'interface des dossiers */
@media (max-width: 768px) {
    .folder-title {
        font-size: 2rem;
    }
    
    .folder-header-main {
        margin-bottom: 30px;
    }
    
    .folder-input-wrapper {
        margin: 0 10px;
        padding: 10px 16px;
        max-width: calc(100% - 20px);
    }
    
    .folder-input {
        font-size: 14px;
    }
    
    .folder-conversations-history {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* Styles globaux pour les icônes monocouleur */
.tool-btn svg,
.btn-icon svg,
i.fas, i.far, i.fab {
    color: currentColor;
    fill: currentColor;
}

/* Style des boutons d'icônes */
.btn-icon,
.tool-btn {
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid transparent;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.btn-icon:hover,
.tool-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border);
    color: var(--text-primary);
}

.btn-icon:disabled,
.tool-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Memory Modal Styles */
.memory-modal-content {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.memory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.memory-header h3 {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin: 0;
}

.memory-settings {
    margin-bottom: 24px;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 8px;
}

.setting-info {
    flex: 1;
}

.setting-label {
    display: block;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 4px;
}

.setting-description {
    color: var(--text-secondary);
    font-size: 0.9em;
    line-height: 1.4;
}

/* Toggle Switch Styles - Mode sombre */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #666; /* Gris foncé pour être visible sur fond noir */
    transition: .4s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #2196F3; /* Bleu quand activé */
}

input:focus + .toggle-slider {
    box-shadow: 0 0 1px #2196F3;
}

input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* Memory Stats */
.memory-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: 8px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-bottom: 4px;
}

.stat-value {
    color: var(--text-primary);
    font-size: 1.5em;
    font-weight: 600;
}

/* Memory Actions */
.memory-actions {
    margin-bottom: 20px;
}

.memory-actions .btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.memory-actions .btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

/* Memory List */
.memory-list {
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.memory-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.memory-empty i {
    font-size: 3em;
    margin-bottom: 16px;
    display: block;
    opacity: 0.5;
}

.memory-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.memory-item:hover {
    border-color: var(--border-light);
    background: var(--bg-tertiary);
}

.memory-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
}

.memory-item-content {
    flex: 1;
    color: var(--text-primary);
    line-height: 1.5;
}

.memory-item-actions {
    display: flex;
    gap: 8px;
}

.memory-item-actions button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.memory-item-actions button:hover {
    background: var(--bg-quaternary);
    color: var(--text-primary);
}

.memory-item-actions button.delete:hover {
    background: rgba(244, 67, 54, 0.1);
    color: var(--error);
}

.memory-item-actions button i {
    font-size: 14px;
}

/* Modal actif */
.folder-modal.active {
    display: flex !important;
}

/* User menu */
.user-balance-info {
    padding: 12px;
}

.balance-display-main {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    margin-bottom: 8px;
}

.balance-display-main i {
    color: var(--text-secondary);
}

.balance-amount {
    color: var(--success);
    font-family: monospace;
    font-weight: 600;
}

.user-menu-container {
    position: relative;
}

.user-avatar-bubble {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-avatar-bubble:hover {
    background: var(--bg-quaternary);
    border-color: var(--border-light);
}

.user-avatar-bubble i {
    font-size: 20px;
    color: var(--text-primary);
}

.user-dropdown-menu {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-width: 200px;
    box-shadow: 0 4px 20px var(--shadow);
    z-index: 1000;
}

.user-dropdown-menu.hidden {
    display: none;
}

.dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.user-info-dropdown {
    text-align: right;
}

.user-email {
    color: var(--text-secondary);
    font-size: 0.9em;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0;
}

.dropdown-items {
    padding: 8px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    width: 100%;
    text-align: left;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
}

.dropdown-item i {
    width: 20px;
    text-align: center;
    color: var(--text-secondary);
}

.dropdown-item.logout-item:hover {
    background: rgba(244, 67, 54, 0.1);
    color: var(--error);
}

.dropdown-item.logout-item:hover i {
    color: var(--error);
}

/* Corrections des icônes existantes */
.new-chat-btn,
.admin-btn,
.settings-btn,
.model-selector-btn {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Unifier le style de tous les boutons avec icônes */
button i.fas,
button i.far,
button svg {
    color: currentColor;
}

/* Styles pour les notifications de mémoire */
.notification {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Fix pour les boutons de modification/suppression qui ne s'affichaient pas */
.memory-item-actions {
    opacity: 1 !important;
    visibility: visible !important;
} 

/* === AMÉLIORATION INTERFACE MOBILE === */

/* Sidebar mobile améliorée */
@media (max-width: 768px) {
    /* Layout principal mobile */
    .chat-layout {
        flex-direction: column;
        height: 100vh;
        position: relative;
    }

    /* Sidebar mobile - mode drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: var(--bg-secondary);
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
        overflow-y: auto;
        border-right: 1px solid var(--border);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* Overlay pour fermer la sidebar */
    .mobile-sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .mobile-sidebar-overlay.show {
        display: block;
        opacity: 1;
    }

    /* Header mobile */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .menu-toggle {
        background: transparent;
        border: none;
        color: var(--text-primary);
        font-size: 24px;
        padding: 8px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        transition: all 0.2s ease;
    }

    .menu-toggle:hover {
        background: var(--bg-tertiary);
    }

    .mobile-title {
        font-size: 18px;
        font-weight: 600;
        color: var(--text-primary);
        flex: 1;
        text-align: center;
    }

    .mobile-actions {
        display: flex;
        gap: 8px;
    }

    /* Chat container adapté */
    .chat-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: 100vh;
        width: 100%;
    }

    /* Messages optimisés mobile */
    .chat-messages {
        flex: 1;
        overflow-y: auto;
        padding: 12px;
        padding-bottom: 80px; /* Espace pour l'input fixe */
        -webkit-overflow-scrolling: touch;
    }

    .message {
        max-width: 85%;
        font-size: 15px;
        padding: 12px 16px;
        margin-bottom: 12px;
    }

    .message.user {
        margin-left: auto;
        border-radius: 18px 18px 4px 18px;
    }

    .message.assistant {
        margin-right: auto;
        border-radius: 18px 18px 18px 4px;
    }

    /* Input mobile fixe en bas */
    .chat-input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        padding: 12px;
        border-top: 1px solid var(--border);
        z-index: 100;
    }

    .modern-input-wrapper {
        display: flex;
        align-items: flex-end;
        gap: 8px;
        background: var(--bg-primary);
        border-radius: 24px;
        padding: 8px 8px 8px 16px;
        border: 1px solid var(--border);
    }

    .modern-chat-input {
        flex: 1;
        background: transparent;
        border: none;
        color: var(--text-primary);
        font-size: 16px;
        line-height: 1.5;
        padding: 8px 0;
        max-height: 100px;
        resize: none;
    }

    /* Boutons d'outils mobile */
    .modern-input-tools {
        display: flex;
        gap: 4px;
        align-items: center;
    }

    .tool-btn {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--bg-tertiary);
        border: 1px solid var(--border);
        transition: all 0.2s ease;
    }

    .tool-btn:active {
        transform: scale(0.95);
    }

    .tool-btn.send-btn-welcome {
        background: var(--accent);
        border-color: var(--accent);
    }

    /* Welcome screen mobile */
    .welcome-container {
        padding: 20px;
        text-align: center;
    }

    .welcome-title {
        font-size: 28px;
        margin-bottom: 30px;
    }

    .welcome-input-wrapper {
        background: var(--bg-secondary);
        border-radius: 24px;
        padding: 12px;
        margin: 0 auto;
        max-width: 400px;
    }

    .welcome-input {
        font-size: 16px;
        padding: 12px;
    }

    /* Sidebar content mobile */
    .sidebar-header {
        padding: 20px;
        background: var(--bg-tertiary);
        border-bottom: 1px solid var(--border);
    }

    .sidebar-header h3 {
        font-size: 24px;
        margin-bottom: 16px;
    }

    .header-buttons {
        display: flex;
        gap: 8px;
    }

    .new-chat-btn,
    .admin-btn {
        flex: 1;
        padding: 12px;
        font-size: 14px;
        border-radius: 8px;
    }

    /* Conversations mobile */
    .conversations-list {
        padding: 8px;
        max-height: none;
    }

    .conversation-item {
        padding: 14px;
        margin-bottom: 6px;
        border-radius: 10px;
        background: var(--bg-primary);
    }

    .conversation-item:active {
        transform: scale(0.98);
    }

    .conversation-title {
        font-size: 15px;
        line-height: 1.4;
    }

    .conversation-meta {
        margin-top: 6px;
    }

    .conversation-date {
        font-size: 12px;
    }

    .conversation-model {
        font-size: 11px;
        padding: 3px 8px;
    }

    /* Folders mobile */
    .folders-section {
        padding: 12px 8px;
        flex-shrink: 0;
    }

    .folder-item {
        margin-bottom: 6px;
    }
    
    /* Content scrollable sur mobile */
    .no-folder-section {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
    }

    .folder-header {
        padding: 12px;
        border-radius: 10px;
    }

    .folder-name {
        font-size: 15px;
    }

    /* Footer mobile */
    .sidebar-footer {
        padding: 16px;
        background: var(--bg-tertiary);
        border-top: 1px solid var(--border);
    }

    .user-balance-info {
        text-align: center;
    }

    .balance-display-main {
        justify-content: center;
        padding: 12px;
        background: var(--bg-primary);
        border-radius: 10px;
        margin-bottom: 12px;
    }

    .balance-amount {
        font-size: 18px;
    }

    /* User menu mobile */
    .user-dropdown-menu {
        bottom: auto;
        top: 100%;
        right: 50%;
        transform: translateX(50%);
        margin-top: 8px;
        width: 250px;
    }
    
    /* Header mobile - menu utilisateur */
    .mobile-header .user-dropdown-menu {
        position: fixed;
        top: 60px;
        right: 10px;
        left: auto;
        transform: none;
        width: 250px;
        max-width: calc(100vw - 20px);
    }

    /* Popups mobile */
    .advanced-model-popup .popup-content {
        margin: 10px;
        padding: 20px;
        max-height: 85vh;
        overflow-y: auto;
        border-radius: 16px;
    }

    .popup-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .close-btn {
        position: absolute;
        top: 12px;
        right: 12px;
        font-size: 28px;
        width: 40px;
        height: 40px;
    }

    /* Filters mobile */
    .main-filters {
        padding: 16px;
        border-radius: 12px;
    }

    .filter-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group select {
        width: 100%;
        padding: 12px;
        font-size: 16px;
        border-radius: 8px;
    }

    /* Quick filters mobile */
    .quick-filters {
        padding: 0 16px;
    }

    .quick-filter-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }

    .quick-filter-btn {
        padding: 10px 16px;
        font-size: 13px;
        border-radius: 20px;
    }

    /* Models container mobile */
    .models-container {
        padding: 12px;
        gap: 12px;
    }

    .advanced-model-card {
        padding: 16px;
        border-radius: 12px;
        margin-bottom: 12px;
    }

    .model-title {
        font-size: 16px;
    }

    .model-meta {
        margin-top: 8px;
    }

    /* Memory modal mobile */
    .memory-modal-content {
        margin: 20px;
        padding: 20px;
        max-height: 80vh;
        border-radius: 16px;
    }

    .memory-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
    }

    .memory-header h3 {
        font-size: 20px;
    }

    .memory-item {
        padding: 12px;
        margin-bottom: 8px;
        border-radius: 10px;
    }

    /* Folder modal mobile */
    .folder-modal-content {
        margin: 20px;
        padding: 20px;
        border-radius: 16px;
    }

    .color-palette {
        grid-template-columns: repeat(6, 1fr);
        gap: 8px;
    }

    .color-option {
        width: 40px;
        height: 40px;
    }

    /* Notifications mobile */
    .notification,
    .drag-notification {
        top: auto;
        bottom: 100px;
        right: 16px;
        left: 16px;
        max-width: none;
        border-radius: 12px;
        padding: 16px;
        font-size: 14px;
    }

    /* Hide desktop elements */
    .chat-header {
        display: none;
    }

    /* Scroll performance */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    /* Safe area for iOS */
    .chat-input-container {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

} /* Fin du @media (max-width: 768px) */

/* Paysage mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 50%;
        max-width: 400px;
    }

    .chat-messages {
        padding-bottom: 70px;
    }

    .chat-input-container {
        padding: 8px;
    }

    .modern-input-wrapper {
        padding: 6px 6px 6px 12px;
    }

    .tool-btn {
        width: 36px;
        height: 36px;
    }
}

/* Très petits écrans */
@media (max-width: 380px) {
    .mobile-title {
        font-size: 16px;
    }

    .welcome-title {
        font-size: 24px;
    }

    .message {
        font-size: 14px;
        padding: 10px 14px;
    }

    .conversation-title {
        font-size: 14px;
    }

    .folder-name {
        font-size: 14px;
    }

    .quick-filter-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .advanced-model-card {
        padding: 14px;
    }

    .model-title {
        font-size: 15px;
    }
}

/* Support du dark mode système */
@media (prefers-color-scheme: light) {
    /* Possibilité d'ajouter un thème clair ici */
}

/* Animations mobile */
@media (max-width: 768px) {
    .conversation-item,
    .folder-item,
    .advanced-model-card {
        transition: transform 0.1s ease, background-color 0.2s ease;
    }

    /* Désactiver les animations complexes sur mobile pour les performances */
    .typing-indicator,
    .loading-message {
        animation: none;
    }

    .typing-dot {
        animation: pulse 1s ease-in-out infinite;
    }
}

/* Accessibilité mobile */
@media (max-width: 768px) {
    /* Augmenter les zones de tap */
    button,
    .conversation-item,
    .folder-item,
    .tool-btn,
    .dropdown-item {
        min-height: 44px;
    }

    /* Améliorer le contraste */
    .message {
        font-weight: 400;
    }

    /* Focus visible */
    button:focus,
    input:focus,
    textarea:focus,
    select:focus {
        outline: 2px solid var(--accent);
        outline-offset: 2px;
    }
}

/* Header mobile - caché par défaut sur desktop */
.mobile-header {
    display: none;
}

.mobile-sidebar-overlay {
    display: none;
}

/* Styles pour le solde et avatar mobile */
.mobile-balance {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-tertiary);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-primary);
}

.mobile-balance i {
    color: var(--accent);
    font-size: 14px;
}

.mobile-balance-amount {
    font-weight: 600;
    font-size: 13px;
}

.mobile-user-avatar {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.mobile-user-avatar:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.05);
}

.mobile-user-avatar i {
    font-size: 18px;
}

@media (max-width: 768px) {
    /* Layout principal mobile */
    .chat-layout {
        flex-direction: column;
        height: 100vh;
        position: relative;
    }

    /* Sidebar mobile - mode drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: var(--bg-secondary);
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
        overflow-y: auto;
        border-right: 1px solid var(--border);
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* Overlay pour fermer la sidebar */
    .mobile-sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .mobile-sidebar-overlay.show {
        display: block;
        opacity: 1;
    }

    /* Header mobile */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .menu-toggle {
        background: transparent;
        border: none;
        color: var(--text-primary);
        font-size: 24px;
        padding: 8px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        transition: all 0.2s ease;
    }

    .menu-toggle:hover {
        background: var(--bg-tertiary);
    }

    .mobile-title {
        font-size: 18px;
        font-weight: 600;
        color: var(--text-primary);
        flex: 1;
        text-align: center;
    }

    .mobile-actions {
        display: flex;
        gap: 8px;
    }

    /* Chat container adapté */
    .chat-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        height: 100vh;
        width: 100%;
    }

    /* Messages optimisés mobile */
    .chat-messages {
        flex: 1;
        overflow-y: auto;
        padding: 12px;
        padding-bottom: 80px; /* Espace pour l'input fixe */
        -webkit-overflow-scrolling: touch;
    }

    .message {
        max-width: 85%;
        font-size: 15px;
        padding: 12px 16px;
        margin-bottom: 12px;
    }

    .message.user {
        margin-left: auto;
        border-radius: 18px 18px 4px 18px;
    }

    .message.assistant {
        margin-right: auto;
        border-radius: 18px 18px 18px 4px;
    }

    /* Input mobile fixe en bas */
    .chat-input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        padding: 12px;
        border-top: 1px solid var(--border);
        z-index: 100;
    }

    .modern-input-wrapper {
        display: flex;
        align-items: flex-end;
        gap: 8px;
        background: var(--bg-primary);
        border-radius: 24px;
        padding: 8px 8px 8px 16px;
        border: 1px solid var(--border);
    }

    .modern-chat-input {
        flex: 1;
        background: transparent;
        border: none;
        color: var(--text-primary);
        font-size: 16px;
        line-height: 1.5;
        padding: 8px 0;
        max-height: 100px;
        resize: none;
    }