/* ============================================================================
   EDUQUE MOI STUDIO - Styles v2.2 (Final, Mobile App Focus)
   Design moderne et accessible avec thème clair/sombre
   ============================================================================ */

:root {
    /* Variables de base (Thème Clair par défaut) */
    --bg-app: #f3f4f6;
    --bg-sidebar: #ffffff;
    --bg-panel: #f9fafb;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: rgba(79, 70, 229, 0.1);
    --secondary: #10b981;
    --secondary-light: rgba(16, 185, 129, 0.1);
    --accent: #8b5cf6;
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --msg-user: #e0e7ff;
    --msg-ai: #ffffff;
    --transition: all 0.2s ease;
    
    /* Variable pour la hauteur dynamique sur mobile (iOS fix) */
    --app-height: 100vh;
}

[data-theme="dark"] {
    --bg-app: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-panel: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #475569;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-light: rgba(99, 102, 241, 0.15);
    --secondary-light: rgba(16, 185, 129, 0.15);
    --danger-light: rgba(239, 68, 68, 0.15);
    --msg-user: #3730a3;
    --msg-ai: #1e293b;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* ============================================================================
   RESET & BASE
   ============================================================================ */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

*:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

*:focus:not(:focus-visible) {
    outline: none;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
    transition: var(--transition);
}

/* ============================================================================
   LAYOUT PRINCIPAL (Desktop View)
   ============================================================================ */

.app-container {
    display: flex;
    height: 100%;
    width: 100%;
}

/* Elements Mobile par défaut : Cachés sur Desktop */
.mobile-header, 
.mobile-bottom-nav,
.sidebar-overlay,
.close-sidebar-btn {
    display: none;
}

/* Classes pour masquer/afficher selon le contexte */
.desktop-only {
    display: block;
}

/* ============================================================================
   SIDEBAR (Desktop View)
   ============================================================================ */

.sidebar {
    width: 320px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 10;
    flex-shrink: 0;
    transition: var(--transition);
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--bg-sidebar);
    position: sticky;
    top: 0;
    z-index: 5;
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo i {
    font-size: 1.4rem;
}

.header-actions {
    display: flex;
    gap: 5px;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 6px;
}

.sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================================================
   PANELS & CARDS
   ============================================================================ */

.config-panel {
    background: var(--bg-panel);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.hidden {
    display: none !important;
}

.divider {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}

/* User Info */
.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.user-badge i {
    font-size: 1.5rem;
    color: var(--primary);
}

.credits-display {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.credit-pill {
    flex: 1;
    background: var(--bg-app);
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.credit-pill span {
    font-size: 1.2rem;
    font-weight: 700;
    display: block;
}

.credit-pill small {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.credit-pill.premium {
    border-color: var(--secondary);
    background: var(--secondary-light);
}

.credit-pill.premium span {
    color: var(--secondary);
}

.sub-status {
    font-size: 0.85rem;
    text-align: center;
    color: var(--text-muted);
    padding: 8px;
    background: var(--bg-app);
    border-radius: 6px;
}

/* ============================================================================
   NAVIGATION MODES (Desktop)
   ============================================================================ */

.nav-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.nav-item {
    background: var(--bg-panel);
    padding: 14px 10px;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--bg-app);
    color: var(--text-main);
    transform: translateY(-2px);
}

.nav-item.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.nav-item i {
    font-size: 1.3rem;
}

/* ============================================================================
   FORM CONTROLS
   ============================================================================ */

.control-group {
    margin-bottom: 14px;
}

.control-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group label i {
    font-size: 0.85rem;
}

input, select, textarea {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-app);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition);
}

input:hover, select:hover, textarea:hover {
    border-color: var(--text-muted);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-with-icon input {
    padding-left: 38px;
}

.row-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.model-info {
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--bg-app);
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

.model-info small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.model-info i {
    margin-right: 4px;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

button {
    cursor: pointer;
    border: none;
    font-family: inherit;
    font-weight: 500;
    transition: var(--transition);
}

.btn-full {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-xs {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 14px;
    border-radius: 8px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 10px;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-panel);
    color: var(--primary);
}

.btn-icon.primary {
    background: var(--primary);
    color: white;
}

.btn-icon.primary:hover {
    background: var(--primary-hover);
}

.btn-send {
    background: var(--primary);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.btn-send:active {
    transform: scale(0.95);
}

.primary {
    background: var(--primary);
    color: white;
}

.primary:hover {
    background: var(--primary-hover);
}

.secondary {
    background: var(--bg-panel);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.secondary:hover {
    background: var(--bg-app);
    border-color: var(--primary);
}

.danger {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.danger:hover {
    background: var(--danger);
    color: white;
}

.w-100 {
    width: 100%;
}

/* ============================================================================
   SHOP PANEL
   ============================================================================ */

.shop-panel {
    background: var(--bg-panel);
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-top: 8px;
}

.shop-panel h5 {
    margin-bottom: 10px;
    color: var(--text-main);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.shop-select {
    margin-bottom: 8px;
}

/* ============================================================================
   MAIN CHAT AREA (Desktop View)
   ============================================================================ */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-app);
    min-width: 0;
}

.chat-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
    width: 100%;
}

.chat-area::-webkit-scrollbar {
    width: 8px;
}

.chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    margin: auto;
    max-width: 600px;
    padding: 40px 20px;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.welcome-icon i {
    font-size: 2.5rem;
    color: var(--primary);
}

.welcome-message h1 {
    color: var(--text-main);
    margin-bottom: 10px;
    font-size: 1.8rem;
}

.welcome-message p {
    color: var(--text-muted);
    font-size: 1rem;
}

.capabilities {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.capabilities span {
    background: var(--bg-sidebar);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
}

.capabilities span i {
    color: var(--primary);
}

/* ============================================================================
   MESSAGES
   ============================================================================ */

.message {
    max-width: 80%;
    padding: 16px 20px;
    border-radius: 18px;
    line-height: 1.7;
    position: relative;
    animation: messageIn 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    align-self: flex-end;
    background: var(--msg-user);
    color: var(--text-main);
    border-bottom-right-radius: 6px;
}

.ai-message {
    align-self: flex-start;
    background: var(--msg-ai);
    color: var(--text-main);
    border-bottom-left-radius: 6px;
    border: 1px solid var(--border);
}

.message .content {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message .content h1,
.message .content h2,
.message .content h3 {
    margin: 16px 0 8px;
    color: var(--text-main);
}

.message .content h1:first-child,
.message .content h2:first-child,
.message .content h3:first-child {
    margin-top: 0;
}

.message .content p {
    margin: 8px 0;
}

.message .content ul,
.message .content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message .content li {
    margin: 4px 0;
}

.message .content pre {
    background: var(--bg-app);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border);
}

.message .content code {
    background: var(--bg-app);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Fira Code', 'Monaco', monospace;
    font-size: 0.9em;
}

.message .content pre code {
    background: transparent;
    padding: 0;
}

.message .content a {
    color: var(--primary);
    text-decoration: none;
}

.message .content a:hover {
    text-decoration: underline;
}

.message .content blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--text-muted);
    font-style: italic;
}

.message img,
.message video,
.message audio {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 12px;
    border: 1px solid var(--border);
    display: block;
}

.message img {
    cursor: pointer;
    transition: var(--transition);
}

.message img:hover {
    transform: scale(1.02);
}

.msg-files {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.message-actions {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    justify-content: flex-start;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-actions button {
    background: var(--bg-app);
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.message-actions button:hover {
    color: var(--primary);
    border-color: var(--primary);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Generation Status */
.generation-status {
    text-align: center;
    padding: 20px;
}

.generation-status p {
    margin: 10px 0 5px;
    color: var(--text-main);
}

.generation-status small {
    color: var(--text-muted);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-app);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ============================================================================
   COMPOSER AREA (Desktop View)
   ============================================================================ */

.composer-area {
    padding: 16px 24px 20px;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-bar {
    display: flex;
    align-items: flex-end;
    background: var(--bg-panel);
    padding: 8px;
    border-radius: 28px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.input-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

#userInput {
    border: none;
    background: transparent;
    padding: 10px 12px;
    resize: none;
    max-height: 150px;
    min-height: 44px;
    flex: 1;
    font-size: 0.95rem;
}

#userInput:focus {
    box-shadow: none;
}

#userInput::placeholder {
    color: var(--text-muted);
}

.pinned-files {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.pinned-file {
    background: var(--bg-panel);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.pinned-file i:first-child {
    color: var(--primary);
}

.pinned-file i:last-child {
    color: var(--text-muted);
    transition: color 0.2s;
}

.pinned-file i:last-child:hover {
    color: var(--danger);
}

.footer-info {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.footer-info .footer-credits {
    /* Cache l'info crédit sur Desktop, elle est dans le panneau user */
    display: none; 
}

/* ============================================================================
   MODALS
   ============================================================================ */

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: var(--bg-sidebar);
    padding: 28px;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: modalIn 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-content.large-modal {
    max-width: 800px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-content h2 {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
}

.modal-content h2 i {
    color: var(--primary);
}

.close {
    float: right;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    transition: color 0.2s;
}

.close:hover {
    color: var(--danger);
}

/* Prompt Library Grid */
.prompt-grid {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 20px;
    flex: 1;
    overflow: hidden;
    margin-top: 10px;
}

.category-list,
.prompt-items-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
}

.category-list li,
.prompt-items-list li {
    padding: 12px 14px;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 6px;
    transition: var(--transition);
}

.category-list li:hover,
.prompt-items-list li:hover {
    background: var(--bg-panel);
}

.category-list li.active {
    background: var(--primary);
    color: white;
}

.prompt-items-list li {
    border: 1px solid var(--border);
}

.prompt-items-list li:hover {
    border-color: var(--primary);
}

.prompt-items-list li strong {
    display: block;
    margin-bottom: 4px;
}

/* ============================================================================
   HISTORY LIST
   ============================================================================ */

.history-list {
    margin-top: 8px;
}

.history-list h5 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-item {
    font-size: 0.85rem;
}

/* ============================================================================
   NOTIFICATIONS
   ============================================================================ */

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 20px;
    border-radius: 10px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 400px;
}

.notification i {
    font-size: 1.2rem;
}

.notification.success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.notification.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.notification.warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.notification.info {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============================================================================
   IMAGE FULLSCREEN OVERLAY & LIBRARY
   ============================================================================ */

.image-fullscreen {
    animation: fadeIn 0.2s ease;
    position: fixed; inset: 0; background: rgba(0,0,0,0.9); 
    display: flex; align-items: center; justify-content: center; 
    z-index: 9999; cursor: pointer;
}

.image-fullscreen img {
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.library-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
}


/* ============================================================================
   RESPONSIVE MOBILE (MODE APP)
   ============================================================================ */

@media (max-width: 768px) {
    
    /* 1. Layout Global & Fix iOS */
    body {
        overscroll-behavior-y: none;
        position: fixed;
        width: 100%;
        height: var(--app-height); /* Utilise la variable calculée par JS */
        overflow: hidden;
    }

    .app-container {
        flex-direction: column;
        height: 100%;
        width: 100vw;
        overflow: hidden;
    }
    
    /* Maintien la police de base pour les inputs sur mobile pour éviter le zoom iOS */
    input, textarea, select {
        font-size: 1rem !important; 
    }
    
    /* Cache les éléments Desktop */
    .sidebar {
        width: 0; /* Masque la sidebar principale */
        border-right: none;
    }
    .desktop-only {
        display: none !important;
    }
    .header-actions {
        display: none;
    }

    /* FIX: Alignement horizontal des actions dans le header mobile */
    .header-actions-mobile {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 10px; 
    }



    /* 2. Header Mobile Fixe */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 60px;
        padding: 0 16px;
        background: var(--bg-sidebar);
        border-bottom: 1px solid var(--border);
        flex-shrink: 0;
        z-index: 50;
    }

    .mobile-header .logo {
        font-size: 1.1rem;
    }

    /* 3. Sidebar transformée en Drawer (Tiroir) */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 80%; 
        max-width: 300px;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-header {
        justify-content: space-between;
    }
    
    .close-sidebar-btn {
        display: flex;
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
        backdrop-filter: blur(2px);
    }
    
    .sidebar-overlay.open {
        opacity: 1;
        pointer-events: auto;
    }
    
    .sidebar-scroll {
        padding: 12px;
    }
    
    /* Cacher la scrollbar du tiroir sur mobile */
    .sidebar-scroll::-webkit-scrollbar {
        width: 0;
        background: transparent;
    }

    /* 4. Main Content (FIX: Assurer un bon flex flow) */
    .main-content {
        padding-top: 60px; /* Espace pour le header mobile */
        padding-bottom: 60px; /* Espace pour la barre du bas */
        height: 100%;
        overflow: hidden;
        display: flex; /* Assurer que c'est une colonne flex */
        flex-direction: column;
    }

    /* FIX: Défilement de la zone de chat */
    .chat-area {
        flex-grow: 1; /* Prend l'espace maximal */
        padding: 12px;
        overflow-y: auto; /* Permet le défilement */
        -webkit-overflow-scrolling: touch;
        padding-bottom: 120px; /* Espace pour éviter que le composer n'obstrue le dernier message */
    }
    
    /* FIX: Ajustement du message de bienvenue */
    .welcome-message {
        text-align: center;
        margin: auto; /* Centrage vertical et horizontal */
        max-width: 100%;
        padding: 20px 10px; /* Réduire le padding */
        box-sizing: border-box;
    }
    
    .welcome-message h1 {
        font-size: 1.5rem;
    }
    
    .quick-start {
        margin-top: 20px;
        display: block; /* S'assurer qu'il est visible s'il n'est pas caché ailleurs */
    }
    
    .quick-start > div {
        flex-wrap: wrap; /* Assurer que les boutons s'ajustent */
    }
    
    /* Les capacités sont déjà configurées avec flex-wrap dans le CSS général, mais on s'assure de l'ajustement */
    .capabilities span {
        font-size: 0.75rem;
        padding: 6px 10px;
    }


    /* 5. Zone de saisie (Composer) */
    .composer-area {
        position: fixed;
        bottom: 60px; /* Juste au dessus de la nav bar */
        left: 0;
        right: 0;
        background: var(--bg-sidebar); 
        border-top: 1px solid var(--border);
        padding: 10px 12px;
        z-index: 40;
    }
    
    .input-bar {
        border-radius: 22px;
        padding: 6px;
        box-shadow: none; 
    }
    
    .btn-send {
        width: 38px;
        height: 38px;
    }
    
    .btn-icon {
        width: 38px;
        height: 38px;
        padding: 8px;
    }
    
    #userInput {
        min-height: 38px;
        padding: 8px 10px;
    }

    /* 6. Barre de Navigation du Bas (Bottom Nav) */
    .mobile-bottom-nav {
        display: grid;
        grid-template-columns: repeat(5, 1fr); /* 4 modes + 1 pour les crédits */
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 60px;
        background: var(--bg-sidebar);
        border-top: 1px solid var(--border);
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 100;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .nav-item-mobile {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: var(--text-muted);
        font-size: 0.65rem;
        gap: 2px;
        transition: all 0.2s;
        border-top: 2px solid transparent;
        margin-top: -2px; 
        padding-top: 4px;
    }
    
    .nav-item-mobile:nth-last-child(1) {
        /* Styles spécifiques pour l'indicateur de crédits */
        color: var(--secondary);
    }

    .nav-item-mobile i {
        font-size: 1.1rem;
        margin-bottom: 2px;
    }

    .nav-item-mobile.active {
        color: var(--primary);
        border-top-color: var(--primary);
    }
    
    .prompt-grid {
        grid-template-columns: 1fr;
    }
    
    .category-list {
        display: flex;
        overflow-x: auto;
        gap: 8px;
        padding-bottom: 10px;
    }
    
    .category-list li {
        white-space: nowrap;
        margin-bottom: 0;
    }
}
/* --- DANS LA SECTION MOBILE (max-width: 768px) --- */
    
    /* Force les actions à être toujours visibles sur mobile */
    .message-actions {
        opacity: 1 !important;
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px dashed var(--border);
        display: flex;
        gap: 12px;
    }

    /* Agrandir un peu les zones de clic sur mobile */
    .message-actions button {
        padding: 8px 12px; 
        background: rgba(0,0,0,0.03); /* Fond léger pour les distinguer */
    }
/* ============================================================================
   RESPONSIVE PETIT MOBILE
   ============================================================================ */
@media (max-width: 480px) {
    .mobile-bottom-nav {
        /* Réduit la hauteur pour maximiser l'écran */
        height: 55px; 
    }
    .composer-area {
        bottom: 55px;
        padding: 8px 10px;
    }
    .main-content {
        padding-bottom: 55px;
    }
    .modal-content {
        padding: 15px;
        margin: 10px;
    }
    .notification {
        left: 10px;
        right: 10px;
        max-width: none;
    }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .sidebar,
    .composer-area,
    .mobile-header,
    .mobile-bottom-nav,
    .message-actions,
    .modal {
        display: none !important;
    }
    
    .main-content {
        width: 100%;
        padding-top: 0;
        padding-bottom: 0;
    }
    
    .message {
        max-width: 100%;
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}