/* =========================================================
   1. CONFIGURATION DES THÈMES & VARIABLES
   ========================================================= */

:root { 
    --primary: #FF0000; 
    --primary-hover: #cc0000;
    --bg: #f3f4f6; 
    --container-bg: #ffffff; 
    --card: #ffffff; 
    --text: #111827; 
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --input-bg: #f9fafb;
    --shadow: rgba(0, 0, 0, 0.08);
    --intro-accent: #3b82f6;
    --conclusion-accent: #10b981;
    --gemini-accent: #d97706;
    --accent-green: #2ba640;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 76px;
}

body.dark-theme {
    --bg: #0a0a0a;
    --container-bg: #121212;
    --card: #1a1a1a; 
    --text: #f3f4f6; 
    --text-muted: #9ca3af;
    --border: #2d2d2d;
    --input-bg: #1f1f1f;
    --shadow: rgba(0, 0, 0, 0.5);
    --intro-accent: #3b82f6;
    --conclusion-accent: #22c55e;
    --gemini-accent: #fbbf24;
    --primary: #ef4444;
    --primary-hover: #dc2626;
    --accent-green: #22c55e;
}

body.neon-theme {
    --bg: #070415; 
    --container-bg: rgba(16, 11, 36, 0.65); 
    --card: rgba(23, 16, 51, 0.75); 
    --text: #ffffff; 
    --text-muted: #a59fc1;
    --border: rgba(139, 92, 246, 0.3); 
    --input-bg: rgba(10, 7, 24, 0.8);
    --shadow: rgba(192, 38, 211, 0.25);
    --primary: #d946ef; 
    --primary-hover: #c026d3;
    --intro-accent: #0ea5e9; 
    --conclusion-accent: #a855f7; 
    --gemini-accent: #0ea5e9;
    --accent-green: #10b981;
}

/* =========================================================
   2. BASE, SCROLLBARS ET DECORATIONS EXCLUSIVES NÉON
   ========================================================= */
*, *::before, *::after {
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

body { 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
    background-color: var(--bg); 
    color: var(--text); 
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

body.neon-theme::before,
body.neon-theme::after {
    content: ''; position: fixed; border-radius: 50%; filter: blur(120px); z-index: -1; pointer-events: none;
    animation: floatNebula 20s ease-in-out infinite alternate;
}
body.neon-theme::before { top: -10%; left: -10%; width: 60vw; height: 60vw; background: radial-gradient(circle, rgba(139, 92, 246, 0.15), transparent 60%); }
body.neon-theme::after { bottom: -10%; right: -10%; width: 50vw; height: 50vw; background: radial-gradient(circle, rgba(14, 165, 233, 0.12), transparent 60%); animation-delay: -10s; }

@keyframes floatNebula {
    0% { transform: translate(0, 0); }
    100% { transform: translate(5%, 10%); }
}

body.neon-theme .service-card,
body.neon-theme .container,
body.neon-theme .app-sidebar,
body.neon-theme .settings-popover,
body.neon-theme .modal-content,
body.neon-theme .chat-container,
body.neon-theme .history-item {
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

body.neon-theme button[type="submit"],
body.neon-theme .btn-download,
body.neon-theme .wall-cta {
    background: linear-gradient(135deg, #d946ef, #8b5cf6) !important;
    border: none !important; color: white !important;
    box-shadow: 0 4px 15px rgba(217, 70, 239, 0.4) !important;
}
body.neon-theme button[type="submit"]:hover,
body.neon-theme .btn-download:hover,
body.neon-theme .wall-cta:hover {
    background: linear-gradient(135deg, #c026d3, #7c3aed) !important;
    box-shadow: 0 8px 25px rgba(217, 70, 239, 0.6) !important;
}

* { scrollbar-width: thin; scrollbar-color: rgba(107, 114, 128, 0.4) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(107, 114, 128, 0.4); border-radius: 10px; transition: background 0.3s ease; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

#globalRecordingBadge {
    display: none; position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    background-color: var(--primary); color: white; padding: 10px 24px; border-radius: 30px;
    font-weight: bold; font-size: 14px; z-index: 10000; box-shadow: 0 4px 15px rgba(255, 0, 0, 0.4);
    align-items: center; gap: 12px; cursor: pointer; transition: background-color 0.2s;
}
#globalRecordingBadge:hover { background-color: var(--primary-hover); }
.pulsing-dot { width: 10px; height: 10px; background-color: white; border-radius: 50%; display: inline-block; animation: pulse 1.5s infinite; }

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(255, 255, 255, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

#docRewriteOptions {
    animation: fadeIn 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   2.bis POPUP INSTALLATION PWA PERSONNALISÉE & INTERACTIVE
   ========================================================= */
.pwa-install-popup {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 10005;
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (min-width: 640px) {
    .pwa-install-popup {
        left: auto;
        right: 20px;
        width: 380px;
    }
}

.pwa-install-card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 10px 30px var(--shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.pwa-install-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    position: relative;
}

.pwa-logo-wrapper {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.pwa-prompt-logo {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    object-fit: cover;
}

.pwa-prompt-text h3 {
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: bold;
    color: var(--text);
}

.pwa-prompt-text p {
    margin: 0;
    font-size: 12.5px;
    color: var(--text-muted);
    line-height: 1.4;
}

.pwa-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    position: absolute;
    top: -5px;
    right: -5px;
    line-height: 1;
}

.pwa-close-btn:hover {
    color: var(--text);
}

.pwa-install-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
}

.pwa-btn-later {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.pwa-btn-later:hover {
    background-color: var(--input-bg);
}

.pwa-btn-install {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.pwa-btn-install:hover {
    background-color: var(--primary-hover);
}

.pwa-badge-icon {
    width: 24px;
    height: 24px;
    background-image: url('/pwa_icon.svg');
    background-size: contain;
    background-repeat: no-repeat;
}

/* =========================================================
   BOUTON D'INSTALLATION DE LA SIDEBAR
   ========================================================= */
.sidebar-pwa-install-btn {
    display: none; /* Caché par défaut, géré en JS */
    background-color: rgba(139, 92, 246, 0.1) !important;
    border-color: rgba(139, 92, 246, 0.2) !important;
}

.sidebar-pwa-install-btn:hover {
    background-color: rgba(139, 92, 246, 0.2) !important;
}

/* =========================================================
   3. STRUCTURE DU LAYOUT ET SIDEBAR
   ========================================================= */
.app-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-width);
    background: var(--container-bg); border-right: 1px solid var(--border);
    z-index: 9999; display: flex; flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible; box-shadow: 2px 0 10px rgba(0,0,0,0.02);
}
.app-sidebar.collapsed { width: var(--sidebar-collapsed-width); }

.main-content-wrapper {
    margin-left: var(--sidebar-width); padding: 0 30px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column; min-height: 100vh;
}
.main-content-wrapper.collapsed { margin-left: var(--sidebar-collapsed-width); }

.sidebar-header { display: flex; flex-direction: row !important; align-items: center; justify-content: space-between; padding: 20px; height: 76px; border-bottom: 1px solid transparent; overflow: hidden; }
.sidebar-logo { font-size: 1.4rem; margin: 0; white-space: nowrap; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 10px; }
.sidebar-logo span { color: var(--primary); }
.sidebar-toggle { background: transparent; border: none; font-size: 1.5rem; color: var(--text); cursor: pointer; padding: 5px; border-radius: 8px; display: flex; align-items: center; justify-content: center; transition: background 0.2s; }
.sidebar-toggle:hover { background: var(--input-bg); }

.sidebar-nav { flex-grow: 1; overflow-y: auto; padding: 15px 0; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-item { display: flex; align-items: center; gap: 16px; padding: 12px 20px; color: var(--text); font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: all 0.2s; white-space: nowrap; margin: 0 12px; border-radius: 12px; border: 1px solid transparent; overflow: hidden; }
.sidebar-item:hover { background: var(--input-bg); }
.sidebar-item.active { background: rgba(99, 102, 241, 0.1); color: var(--primary); border-color: rgba(99, 102, 241, 0.2); }
.sidebar-icon { font-size: 1.3rem; display: flex; justify-content: center; width: 24px; flex-shrink: 0; }
.sidebar-text { opacity: 1; transition: opacity 0.2s; }

.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; padding-bottom: 10px; display: flex; flex-direction: column; gap: 4px; position: relative; }
.sidebar-profile { display: flex; align-items: center; gap: 12px; padding: 12px 20px; margin: 10px 12px 0 12px; border-radius: 12px; cursor: pointer; transition: background 0.2s; border: 1px solid var(--border); background: var(--input-bg); overflow: hidden; }
.sidebar-profile:hover { border-color: var(--primary); }
.profile-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), #c084fc); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; color: white; font-weight: bold; }
.profile-info { display: flex; flex-direction: column; white-space: nowrap; overflow: hidden; }
.profile-name { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.profile-status { font-size: 0.75rem; color: var(--text-muted); font-weight: 500;}

.settings-popover { position: absolute; bottom: 75px; left: 15px; width: 230px; background: var(--container-bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); z-index: 10001; display: flex; flex-direction: column; padding: 8px; transform-origin: bottom left; animation: popoverFadeIn 0.2s ease; }
@keyframes popoverFadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
.app-sidebar.collapsed .settings-popover { left: 70px; bottom: 60px; }
.settings-popover-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; color: var(--text); font-size: 0.9rem; font-weight: 500; cursor: pointer; border-radius: 8px; transition: background 0.2s; text-decoration: none; }
.settings-popover-item:hover { background: var(--input-bg); }

.app-sidebar.collapsed .sidebar-text { opacity: 0; visibility: hidden; width: 0; margin: 0; padding: 0; overflow: hidden; }
.app-sidebar.collapsed .sidebar-item { justify-content: center; padding: 12px; }
.app-sidebar.collapsed .sidebar-logo { display: none; }
.app-sidebar.collapsed .sidebar-header { justify-content: center; }
.app-sidebar.collapsed .sidebar-profile { padding: 12px; justify-content: center; border-color: transparent; background: transparent; }
.app-sidebar.collapsed .sidebar-profile:hover { background: var(--input-bg); }

/* =========================================================
   4. EN-TÊTE ET ACTIONS
   ========================================================= */
.header-area { overflow: visible !important; display: flex; justify-content: space-between; align-items: center; padding-top: 12px; margin-bottom: 10px; }
.mobile-burger-btn { display: none; background: transparent; border: none; font-size: 1.8rem; color: var(--text); cursor: pointer; padding: 0; line-height: 1; }

.btn-header-wall {
    background-color: rgba(245, 158, 11, 0.1); color: #d97706; border: 1px solid #fbbf24;
    padding: 8px 16px; border-radius: 20px; font-weight: 700; font-size: 13px;
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer; transition: all 0.2s ease;
}
.btn-header-wall:hover { background-color: #fbbf24; color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3); }

.btn-header-donate {
    background-color: #ef4444; color: #fff; border: none;
    padding: 8px 16px; border-radius: 20px; font-weight: 700; font-size: 13px;
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer; transition: all 0.2s ease; box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
}
.btn-header-donate:hover { background-color: #dc2626; transform: translateY(-1px); box-shadow: 0 6px 15px rgba(239, 68, 68, 0.4); }

@media (min-width: 769px) { .header-area h1 { display: none; } }

/* =========================================================
   5. CONTENEURS, INPUTS ET BOUTONS
   ========================================================= */
.container { background-color: var(--container-bg); padding: 30px; border-radius: 16px; border: 1px solid var(--border); box-shadow: 0 4px 20px var(--shadow); margin: 0 0 30px 0; width: 100%; }
.row { display: flex; gap: 20px; margin-bottom: 20px; flex-wrap: wrap; }
.col { flex: 1; min-width: 200px; display: flex; flex-direction: column; }
label { margin-bottom: 8px; font-weight: bold; color: var(--text-muted); font-size: 14px; }
input, select, textarea { padding: 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text); font-size: 16px; width: 100% !important; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }
.page input, .page select, .page textarea { width: auto !important; }

.checkbox-group { display: flex; flex-direction: column; gap: 10px; background: var(--input-bg); padding: 15px; border-radius: 8px; border: 1px solid var(--border); }
.checkbox-item { display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--text); }
.checkbox-item input { cursor: pointer; width: 18px; height: 18px; accent-color: var(--primary); flex-shrink: 0; }

summary::-webkit-details-marker { display: none; }
summary { outline: none; display: flex; justify-content: space-between; align-items: center; font-weight: bold; font-size: 13.5px; color: var(--text); user-select: none; cursor: pointer; }

.quota-widget { margin-top: 12px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.quota-header { display: flex; justify-content: space-between; align-items: center; font-weight: bold; font-size: 12.5px; margin-bottom: 12px; color: var(--text-muted); }
.quota-bars { display: flex; flex-direction: column; gap: 12px; }
.quota-bar-container { display: flex; flex-direction: column; gap: 5px; }
.quota-bar-labels { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--text-muted); font-weight: 500; }
.quota-bar-bg { background: var(--card); height: 6px; border-radius: 3px; overflow: hidden; width: 100%; }
.quota-bar-fill { background-color: var(--intro-accent); height: 100%; border-radius: 3px; width: 0%; transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s; }

button[type="submit"], .btn-download { background-color: var(--primary); color: #ffffff; font-weight: bold; padding: 14px; border: none; border-radius: 30px; cursor: pointer; font-size: 16px; width: 100%; box-shadow: 0 4px 10px var(--shadow); display: flex; align-items: center; justify-content: center; gap: 8px; }
button[type="submit"]:hover:not(:disabled), .btn-download:hover { background-color: var(--primary-hover); }
button[type="submit"]:disabled { background-color: #555 !important; color: #aaa !important; box-shadow: none !important; cursor: not-allowed; }

#loading { display: none; text-align: center; margin-top: 20px; font-style: italic; color: var(--text-muted); font-size: 1.1em; }
.loading-doc { display: none; text-align: center; margin-top: 15px; font-style: italic; color: var(--text-muted); }
#results, #audioResults, #docResults { margin-top: 40px; display: none; }

/* JAUGE DONS */
.donation-slider { -webkit-appearance: none; width: 100%; height: 8px; border-radius: 4px; background: var(--border); outline: none; margin: 15px 0 5px 0; transition: background 0.1s ease; }
.donation-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); cursor: pointer; box-shadow: 0 0 10px rgba(59, 130, 246, 0.4), 0 2px 4px rgba(0,0,0,0.2); transition: transform 0.1s ease; border: 2px solid #fff; }
.donation-slider::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); cursor: pointer; box-shadow: 0 0 10px rgba(59, 130, 246, 0.4), 0 2px 4px rgba(0,0,0,0.2); transition: transform 0.1s ease; border: 2px solid #fff; }
input[type=number].no-spinners::-webkit-inner-spin-button, input[type=number].no-spinners::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number].no-spinners { -moz-appearance: textfield; }
.donation-labels span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.donation-labels span:first-child { transform: translateX(0); }
.donation-labels span:last-child { transform: translateX(-100%); }

/* =========================================================
   6. DASHBOARD & CARTES (STYLE PAR DÉFAUT PC)
   ========================================================= */
.hub-hero {
    display: flex; align-items: center; justify-content: space-between; gap: 30px;
    margin: 0 0 40px 0; padding: 40px; border-radius: 24px;
    background: var(--container-bg); border: 1px solid var(--border);
    position: relative; overflow: hidden; box-shadow: 0 10px 30px var(--shadow); width: 100%;
}
.hub-hero-content { flex: 1; z-index: 2; }
.hub-hero h2 { font-size: 2.8rem; font-weight: 900; margin: 10px 0; color: var(--text); letter-spacing: -1px; }
.hub-hero p { font-size: 1.1rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 25px; max-width: 500px; }
.hub-hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.hub-hero-graphic { position: relative; width: 320px; height: 220px; display: none; }
@media (min-width: 900px) { .hub-hero-graphic { display: block; } }

.glass-panel { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 220px; height: 140px; background: rgba(255, 255, 255, 0.05); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,0.2); border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 15px; z-index: 2; }
.glow-orb { position: absolute; border-radius: 50%; filter: blur(50px); z-index: 1; }
.glow-orb.red { background: #d946ef; width: 180px; height: 180px; top: -30px; left: -30px; }
.glow-orb.blue { background: #0ea5e9; width: 160px; height: 160px; bottom: -30px; right: -30px; }
body:not(.neon-theme) .glow-orb.red { background: rgba(239, 68, 68, 0.4); }
body:not(.neon-theme) .glow-orb.blue { background: rgba(59, 130, 246, 0.3); }

.services-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px; margin: 0 0 40px 0; width: 100%;
}
.service-card {
    background-color: var(--container-bg); border: 1px solid var(--border); border-radius: 16px;
    cursor: pointer; position: relative; box-shadow: 0 4px 15px var(--shadow);
    transition: transform .25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow .25s ease, border-color .25s;
    display: flex; flex-direction: column; overflow: hidden; padding: 0; min-height: 280px;
}
.service-card:hover { transform: translateY(-6px); border-color: var(--text-muted); box-shadow: 0 15px 35px -10px var(--shadow); }
.interactive-card { transition: transform .25s ease, box-shadow .25s ease; }
.interactive-card:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(0,0,0,0.18); }
.academy-answer-btn {
    background: #0f172a;
    border: 1px solid rgba(148, 163, 184, 0.18);
    color: #cbd5e1;
    text-align: left;
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 0.82rem;
    font-weight: 700;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    cursor: pointer;
    display: block;
    width: 100%;
}
.academy-answer-btn:hover {
    background: rgba(148, 163, 184, 0.08);
    color: #fff;
    transform: translateY(-1px);
}
.card-image { height: 140px; display: flex; align-items: center; justify-content: center; position: relative; border-bottom: 1px solid var(--border); }
.card-image i { font-size: 4rem; color: white; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.3)); }
.card-content { padding: 20px; display: flex; flex-direction: column; flex-grow: 1; }
.service-action-link { font-size: 0.8rem; font-weight: 700; color: var(--primary); margin-top: 15px; display: inline-flex; align-items: center; gap: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.service-card:hover .service-action-link { padding-left: 5px; }

.nav-back-bar { display: flex; justify-content: flex-start; margin-bottom: 25px; }
.btn-back {
    background-color: var(--container-bg); border: 1px solid var(--border); color: var(--text);
    padding: 8px 18px; border-radius: 30px; font-size: 14px; font-weight: bold; cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px;
}
.btn-back:hover { border-color: var(--primary); color: var(--primary); }

/* =========================================================
   7. MODALES (STYLES STANDARDISÉS)
   ========================================================= */
.modal { display: none; position: fixed; z-index: 11000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.75); backdrop-filter: blur(4px); overflow-y: auto; }
.modal-content { background-color: var(--container-bg); margin: 10% auto; padding: 30px; border: 1px solid var(--border); width: 90%; max-width: 520px; border-radius: 16px; color: var(--text); box-shadow: 0 10px 30px var(--shadow); position: relative; animation: slideUp 0.3s ease-out; }
.close-modal { color: var(--text-muted); position: absolute; top: 15px; right: 20px; font-size: 28px; font-weight: bold; cursor: pointer; transition: color 0.2s; }
.close-modal:hover { color: var(--primary); }
.modal-title { color: var(--primary); font-size: 1.5rem; font-weight: 700; margin-top: 0; margin-bottom: 15px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }

.doc-section { margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 15px; }
.doc-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.doc-section h4 { color: var(--text); margin-top: 0; font-size: 1.15rem; display: flex; align-items: center; gap: 8px; font-weight: bold; }
.doc-section p, .doc-section ul { font-size: 14px; line-height: 1.6; color: var(--text-muted); }
.doc-section ul { padding-left: 20px; }
.doc-section li { margin-bottom: 8px; }

/* =========================================================
   8. MUR DES DONATEURS (GAMIFIÉ ET ANIMÉ)
   ========================================================= */
.wall-container { max-width: 1000px; margin: 0 auto; padding: 12px 16px; }
.badge-premium { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 30px; font-size: 0.85rem; font-weight: 600; color: var(--text-muted); margin-bottom: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); backdrop-filter: blur(5px); }
.wall-title { font-size: 2.8rem; font-weight: 900; letter-spacing: -0.04em; margin: 0 0 12px 0; background: linear-gradient(135deg, #ffffff 0%, #a1a1aa 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); }
body:not(.dark-theme):not(.neon-theme) .wall-title { background: linear-gradient(135deg, #111 0%, #666 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.wall-subtitle { color: var(--text-muted); font-size: 1.05rem; max-width: 600px; margin: 0 auto 20px auto; line-height: 1.6; }

.donor-wall-stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0 30px; justify-content: center; }
.stat-pill { background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 10px 20px; display: inline-flex; align-items: center; gap: 8px; font-size: 0.95rem; color: var(--text); box-shadow: 0 4px 15px rgba(0,0,0,0.15); white-space: nowrap; transition: transform 0.2s; }
.stat-pill:hover { transform: translateY(-2px); border-color: var(--primary); }
.stat-pill span:first-child { font-size: 18px; line-height: 1; }
.stat-pill strong { font-weight: 800; color: var(--text); letter-spacing: -.2px; }

.tiers-legend { background: rgba(24, 24, 27, 0.4); border: 1px solid var(--border); border-radius: 20px; padding: 20px; margin-bottom: 30px; text-align: center; backdrop-filter: blur(10px); }
.legend-title { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 15px 0; font-weight: 800; }
.legend-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.legend-item { display: flex; align-items: center; gap: 8px; background: var(--container-bg); padding: 8px 14px; border-radius: 12px; border: 1px solid var(--border); transition: all 0.2s; cursor: default; }
.legend-item:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.legend-amount { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }

.wall-cta { display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: linear-gradient(135deg, var(--primary), var(--primary-hover)); color: #fff; font-weight: 800; font-size: 1.05rem; padding: 16px 32px; border-radius: 999px; border: none; cursor: pointer; box-shadow: 0 8px 25px rgba(239, 68, 68, 0.4); transition: all .2s ease; margin: 10px auto 35px; text-transform: uppercase; letter-spacing: 0.5px; }
.wall-cta:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 12px 35px rgba(239, 68, 68, 0.5); }

.donors-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; perspective: 1000px; }
.donor-card { background: var(--card); border: 1px solid var(--border); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 12px; position: relative; overflow: hidden; opacity: 0; animation: fadeUpIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; transition: transform .25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow .25s ease, border-color .25s; }
.donor-card:hover { transform: scale(1.02) translateY(-5px); box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.4); z-index: 10; border-color: var(--text-muted); }

.donor-header { display: flex; align-items: center; gap: 12px; width: 100%; }
.donor-avatar { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; color: #fff; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.15), 0 4px 10px rgba(0,0,0,0.2); }
.last-donation-date { font-size: 0.75rem; color: var(--text-muted); background: rgba(255,255,255,0.05); padding: 3px 10px; border-radius: 999px; align-self: flex-start; margin-top: -2px; font-weight: 500; }
.donor-pseudo { font-weight: 800; font-size: 1.15rem; color: var(--text); display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.2px; }
.donor-amount { font-weight: 900; font-size: 1.25rem; color: #10b981; white-space: nowrap; text-shadow: 0 2px 5px rgba(16,185,129,0.2); }
.donor-message { margin-top: 10px; padding: 12px 16px; background: rgba(0,0,0,0.15); border-left: 4px solid var(--border); border-radius: 8px; font-size: 0.95rem; line-height: 1.5; color: var(--text-muted); font-style: italic; }

.tier-soutien .donor-avatar { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.tier-bronze .donor-avatar { background: linear-gradient(135deg, #A0522D, #CD7F32); }
.tier-bronze .donor-message { border-left-color: rgba(205, 127, 50, 0.5); }
.tier-argent .donor-avatar { background: linear-gradient(135deg, #71717a, #a1a1aa); }
.tier-argent .donor-message { border-left-color: rgba(161, 161, 170, 0.5); }
.tier-or .donor-avatar { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.donor-card.tier-or { box-shadow: 0 4px 20px -5px rgba(245, 158, 11, 0.08); border-color: rgba(245, 158, 11, 0.2); }
.tier-or .donor-message { border-left-color: rgba(245, 158, 11, 0.5); }
.tier-platine .donor-avatar { background: linear-gradient(135deg, #0284c7, #38bdf8); }
.donor-card.tier-platine { background: linear-gradient(160deg, #18181b 0%, #0f172a 100%); border-color: rgba(56, 189, 248, 0.4); box-shadow: 0 8px 25px rgba(56, 189, 248, 0.1); }
.tier-platine .donor-message { border-left-color: rgba(56, 189, 248, 0.6); color: #e0f2fe; }

.donor-card-diamant { grid-column: 1 / -1; border-color: #f59e0b; box-shadow: 0 10px 40px rgba(245, 158, 11, 0.15), inset 0 0 0 1px rgba(245, 158, 11, 0.3); padding: 25px; background: linear-gradient(145deg, #27250f 0%, #18181b 50%, #1e1b4b 100%); transform-style: preserve-3d; }
@media (min-width: 768px) { .donor-card-diamant { max-width: 60%; margin: 0 auto; } }
.donor-card-diamant::before { content: ''; position: absolute; top: 0; left: -100%; width: 50%; height: 100%; background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0) 100%); transform: skewX(-20deg); animation: shine 6s infinite; z-index: 1; pointer-events: none; }
.donor-card-diamant::after { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(to right, transparent, #fbbf24, #a855f7, transparent); }
.tier-diamant .donor-avatar { background: linear-gradient(135deg, #ca8a04, #fde047); color: #111; font-weight: 800; width: 60px; height: 60px; font-size: 1.5rem; }
.tier-diamant .donor-pseudo { font-size: 1.4rem; background: linear-gradient(to right, #fde047, #f59e0b); -webkit-background-clip: text; -webkit-text-fill-color: transparent; font-weight: 900; }
.tier-diamant .donor-amount { font-size: 1.6rem; color: #f59e0b; }

.rank-medal { font-size: 1.2rem; margin-right: 5px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); }

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

/* =========================================================
   9. COMPOSANTS EXTRA (HISTORIQUE, CHAT & AUDIO TERMINAL)
   ========================================================= */
.history-section { margin-top: 30px; padding-top: 25px; border-top: 1px solid var(--border); }
.history-list { display: flex; flex-direction: column; gap: 12px; max-height: 380px; overflow-y: auto; padding-right: 5px; }
.history-item { display: flex; flex-direction: row !important; justify-content: space-between; align-items: center; background-color: var(--input-bg); padding: 15px 18px; border-radius: 8px; border: 1px solid var(--border); gap: 15px; flex-wrap: wrap; }
.history-item-info { display: flex; flex-direction: column; gap: 4px; flex-grow: 1; min-width: 200px; overflow: hidden; }
.history-item-title { font-weight: bold; font-size: 14.5px; color: var(--text); text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.history-item-meta { font-size: 12px; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; }
.history-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.btn-history { background-color: var(--card); border: 1px solid var(--border); color: var(--text); padding: 6px 12px; border-radius: 20px; font-size: 11.5px; cursor: pointer; font-weight: bold; display: inline-flex; align-items: center; gap: 4px; }
.btn-history:hover { border-color: var(--primary); color: var(--primary); }
.btn-history-load { background-color: var(--primary); color: #ffffff; border-color: var(--primary); }
.btn-history-load:hover { background-color: var(--primary-hover); border-color: var(--primary-hover); color: #ffffff; }
.btn-history-delete { color: #ff4d4d; border-color: rgba(255, 77, 77, 0.2); }
.btn-history-delete:hover { background-color: rgba(255, 77, 77, 0.1); border-color: #ff4d4d; color: #ff4d4d; }

.section-block { padding: 10px 0 10px 25px; margin-bottom: 35px; border-left: 4px solid var(--primary); }
.section-block h3 { color: var(--primary); margin-top: 0; margin-bottom: 12px; font-size: 1.4em; font-weight: bold; }
.section-block p { line-height: 1.8; font-size: 16px; color: var(--text); text-align: justify; margin: 0; word-break: break-word; }

.download-zone { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; margin-top: 30px; }

.chat-container { display: flex; flex-direction: column; gap: 15px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 12px; padding: 20px; max-height: 400px; overflow-y: auto; margin-top: 20px; }
.chat-bubble { padding: 12px 18px; border-radius: 16px; max-width: 80%; font-size: 15px; line-height: 1.5; }
.bubble-user { align-self: flex-end; background-color: var(--primary); color: white; }
.bubble-ai { align-self: flex-start; background-color: var(--card); color: var(--text); border: 1px solid var(--border); }

.audio-dropzone { border: 2px dashed var(--border); border-radius: 12px; padding: 30px 20px; text-align: center; background: var(--input-bg); cursor: pointer; transition: border-color 0.3s, background-color 0.3s; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.audio-dropzone:hover, .audio-dropzone.dragover { border-color: var(--primary); background: var(--card); }
.audio-console-terminal { background-color: #121212; color: #00ff00; font-family: 'Courier New', Courier, monospace; padding: 15px; border-radius: 8px; min-height: 100px; max-height: 150px; overflow-y: auto; font-size: 13px; line-height: 1.4; border: 1px solid #333; }

.chat-sidebar-item { position: relative; transition: background-color 0.2s, border-color 0.2s; }
.chat-sidebar-item:hover { background-color: var(--card) !important; }
.btn-delete-chat { opacity: 0; transition: opacity 0.2s; }
.chat-sidebar-item:hover .btn-delete-chat { opacity: 1; }

#chatSidebar { width: 260px; min-width: 260px; border-right: 1px solid var(--border); background: var(--input-bg); display: flex; flex-direction: column; flex-shrink: 0; position: relative; height: 100%; transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, border-right-width 0.35s ease; overflow: hidden; }
#chatSidebar.collapsed { width: 0 !important; min-width: 0 !important; border-right-width: 0 !important; opacity: 0; pointer-events: none; }

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

footer { margin-top: 40px; padding: 30px 0 10px 0; border-top: 1px solid var(--border); text-align: center; font-size: 14px; color: var(--text-muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
footer p { margin: 0; }
footer a { color: var(--primary); text-decoration: none; font-weight: bold; }
footer a:hover { color: var(--primary-hover); text-decoration: underline; }
.footer-links { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; align-items: center; }

/* =========================================================
   10. RESPONSIVE BREAKPOINTS & GRID APPLICATION MOBILE (MAX-WIDTH: 1024px)
   ========================================================= */
@media (max-width: 1024px) {
    .app-sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; }
    .app-sidebar.open { transform: translateX(0); box-shadow: 4px 0 25px rgba(0,0,0,0.5); }
    .main-content-wrapper { margin-left: 0 !important; padding: 0 15px; } 
    .sidebar-toggle { display: none !important; }
    .mobile-burger-btn { display: block !important; padding: 5px; }
    .header-area { padding: 15px 0; margin-bottom: 10px; }
    #logoHub { display: none; } 
    .hub-hero { margin: 0 0 30px 0; padding: 25px 20px; }
    .container { padding: 20px 15px; margin: 0 0 30px 0; }
    
    #chatSidebar { position: absolute !important; left: -260px; width: 260px !important; min-width: 260px !important; top: 0; bottom: 0; height: 100%; z-index: 100; transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1); opacity: 1 !important; }
    #chatSidebar.open { left: 0 !important; box-shadow: 5px 0 15px rgba(0, 0, 0, 0.15); }
    .close-chat-sidebar-mobile { display: block !important; }
    
    .donors-grid { grid-template-columns: 1fr; gap: 15px; }
    .donor-wall-stats { gap: 8px; justify-content: center; }
    .stat-pill { font-size: 0.85rem; padding: 8px 14px; }
    .wall-container { padding: 10px; }
    .wall-title { font-size: 2.2rem; }
    #wallStats { transition: opacity 0.2s; }
}

@media (max-width: 480px) {
    #wallStats { padding: 10px 12px !important; }
    #wallStats > div { font-size: 0.78rem; }
}

/* =========================================================
   11. AFFICHAGE "APPLICATION ECOSYSTÈME" MOBILE (MAX-WIDTH: 600px)
   ========================================================= */
@media (max-width: 600px) {
    /* Grille à 3 colonnes pour afficher un maximum d'icônes comme sur l'écran d'un smartphone */
    .services-grid { 
        grid-template-columns: repeat(3, 1fr) !important; 
        gap: 12px !important; 
        margin: 0 0 30px 0; 
    }

    /* Transformation de la carte en carré parfait cliquable */
    .service-card {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: flex-start !important;
        text-align: center !important;
        padding: 0 !important;
        min-height: auto !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }

    /* Conteneur de l'icône de la carte : Devient un carré parfait aux bords arrondis avec dégradé */
    .card-image { 
        width: 100% !important;
        aspect-ratio: 1 / 1 !important; /* Force le carré parfait */
        height: auto !important;
        border-radius: 18px !important; 
        border-bottom: none !important; 
        flex-shrink: 0;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    /* Réduction de la taille de l'icône à l'intérieur */
    .card-image i { 
        font-size: 2rem !important; 
    }

    /* Le contenu textuel se place en dessous */
    .card-content { 
        padding: 6px 0 0 0 !important; 
        align-items: center;
        width: 100%;
    }

    /* Style épuré pour le titre de l'application sous l'icône */
    .service-title { 
        font-size: 0.8rem !important; 
        font-weight: 600 !important;
        line-height: 1.2 !important;
        color: var(--text) !important;
        margin: 0 !important;
        display: -webkit-box;
        -webkit-line-clamp: 2; /* Coupe proprement sur 2 lignes max si le titre est long */
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Masquage de la description et du lien d'action pour garder l'aspect épuré "iOS/Android" */
    .service-card .service-desc,
    .service-action-link,
    .service-status { 
        display: none !important; 
    }
}



/* ==========================================
   EPHRA CHAT FLOTTANT - VERSION PROPRE + ANIMATIONS
   Style Grok / Claude - Épuré & Moderne
   ========================================== */

/* --- Bouton flottant --- */
.ephra-float-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 62px;
    height: 62px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: white;
    border: none;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 10px 30px rgba(99, 102, 241, 0.35);
    cursor: pointer;
    z-index: 9999;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ephra-float-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 15px 40px rgba(99, 102, 241, 0.45);
}

/* Animation subtile du bouton flottant (respiration légère) */
.ephra-float-btn {
    animation: floatPulse 3s ease-in-out infinite;
}

@keyframes floatPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

/* --- Fenêtre de chat (avec animation d'ouverture) --- */
.ephra-chat-window {
    position: fixed;
    bottom: 110px;
    right: 28px;
    width: 420px;
    max-width: 92vw;
    height: 620px;
    max-height: 85vh;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    /* Animation d'ouverture */
    animation: chatWindowEnter 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom right;
}

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

/* --- Header --- */
.ephra-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: var(--input-bg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.ephra-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ephra-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    flex-shrink: 0;
}

.ephra-header-left strong {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.ephra-status {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    margin-top: -2px;
}

.ephra-header-right {
    display: flex;
    align-items: center;
    gap: 2px;
}

.ephra-header-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.ephra-header-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    transform: scale(1.1);
}

/* --- Zone de messages --- */
.chat-area {
    flex: 1;
    padding: 20px 18px;
    overflow-y: auto;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

/* --- Bulles de messages (avec animation) --- */
.chat-bubble {
    max-width: 82%;
    padding: 13px 18px;
    border-radius: 18px;
    font-size: 15.2px;
    line-height: 1.45;
    white-space: pre-wrap;
    animation: messagePop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.bubble-user {
    align-self: flex-end;
    background: #6366f1;
    color: white;
    border-bottom-right-radius: 6px;
}

.bubble-ai {
    align-self: flex-start;
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 6px;
}

/* ==========================================
   EPHRA - BASE INPUT MULTILIGNE AUTOMATIQUE
   ========================================== */

.base-bar {
    padding: 12px 16px 20px;
    background: var(--card);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.base-input {
    background: var(--input-bg);
    border-radius: 9999px;           /* Pill par défaut */
    padding: 8px 12px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    min-height: 50px;
    transition: border-radius 0.25s ease, box-shadow 0.2s ease;
}

/* Quand on est en multiligne, on change la forme via JS */
.base-input.multiline {
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Textarea */
.base-input textarea {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    outline: none;
    padding: 10px 8px;
    color: var(--text);
    resize: none;
    line-height: 1.45;
    max-height: 140px;               /* ~6 lignes max */
    min-height: 24px;
    overflow-y: auto;
    font-family: inherit;
}

.base-input textarea::placeholder {
    color: #9ca3af;
}

/* Boutons dans la barre */
.base-input button {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #555;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.1s ease;
    flex-shrink: 0;
}

.base-input button:hover {
    color: var(--text);
}

.base-input button:active {
    transform: scale(0.9);
}

/* Bouton Parler */
.talk-btn {
    background: #111827;
    color: white;
    padding: 0 20px;
    border-radius: 9999px;
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.talk-btn:hover {
    background: #1f2937;
}

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

/* Bouton Envoyer */
.send-btn {
    background: #111827;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.1s ease;
}

.send-btn:hover {
    background: #1f2937;
}

.send-btn:active {
    transform: scale(0.85);
}

/* --- Barre de conversation (sombre) --- */
.conv-bar {
    padding: 14px 16px 20px;
    background: #1e2937;
    display: none;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;

    /* Animation d'apparition */
    animation: convBarEnter 0.2s ease forwards;
}

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

.conv-bar input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: white;
    font-size: 16px;
    padding: 8px 4px;
}

.conv-bar button {
    color: #94a3b8;
    background: none;
    border: none;
    font-size: 22px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.1s ease;
}

.conv-bar button:active {
    transform: scale(0.9);
}

/* Bouton Arrêter */
.stop-btn {
    background: white;
    color: black;
    padding: 8px 18px;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.1s ease;
}

.stop-btn:hover {
    background: #f1f5f9;
}

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

/* --- Plein écran --- */
.ephra-chat-window.fullscreen {
    top: 20px;
    bottom: 20px;
    left: 20px;
    right: 20px;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    border-radius: 16px;
    animation: fullscreenEnter 0.3s ease;
}

@keyframes fullscreenEnter {
    from {
        opacity: 0.7;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* --- Responsive Mobile --- */
@media (max-width: 768px) {
    .ephra-chat-window {
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        bottom: 0;
        right: 0;
        border-radius: 20px 20px 0 0;
    }

    .base-bar,
    .conv-bar {
        padding-bottom: 24px;
    }
}

/* Adaptation Mobile pour la barre du Studio Docs & Réécriture */
@media (max-width: 768px) {
    .doc-controls-wrapper {
        flex-direction: column !important;
        gap: 8px !important;
    }
    #docRewriteOptions {
        flex-direction: row !important;
        width: 100% !important;
    }
    /* Hauteur minimale de confort tactile augmentée pour les sélecteurs sur mobile */
    #docProcessMode, #docRewriteStyle, #docRewriteLanguage {
        height: 44px !important;
        font-size: 14px !important;
    }
}

#canvasOrientation, #exportFormatSelect, #variantCountSelect { width: inherit !important;}
#overlayColorPicker, #textColorPicker {padding: inherit !important;} 
/* --- Ephra : mode agent (outils) --- */
.ephra-header-btn.ephra-agent-toggle.is-active {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.12);
}
.chat-bubble .ephra-tools-used,
.chat-bubble .ephra-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed rgba(148, 163, 184, 0.35);
    font-size: 0.78em;
}
.chat-bubble .ephra-tools-title {
    width: 100%;
    opacity: 0.75;
    font-weight: 600;
}
.chat-bubble .ephra-tool-chip {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(34, 197, 94, 0.12);
}
.chat-bubble .ephra-tool-chip.ko { background: rgba(239, 68, 68, 0.12); }
.chat-bubble .ephra-sources a {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-bubble.ephra-pending { opacity: 0.7; font-style: italic; }
/* v12 : images créées par Ephra (outil generate_image) */
.chat-bubble .ephra-images { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.chat-bubble .ephra-image { margin: 0; display: flex; flex-direction: column; gap: 6px; font-style: normal; }
.chat-bubble .ephra-image img { max-width: 100%; height: auto; border-radius: 10px; display: block; }
.chat-bubble .ephra-image-download {
    align-self: flex-start;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.12);
    font-size: 0.85em;
    text-decoration: none;
    color: inherit;
}
.chat-bubble .ephra-plan {
    margin-bottom: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.08);
    font-size: 0.82em;
}
.chat-bubble .ephra-plan .ephra-tools-title { display: block; }
.chat-bubble.ephra-confirm { border: 1px solid rgba(245, 158, 11, 0.55); }
.chat-bubble .ephra-confirm-box {
    margin-top: 8px;
    padding: 8px;
    border-radius: 8px;
    background: rgba(245, 158, 11, 0.10);
    font-size: 0.88em;
}
.chat-bubble .ephra-confirm-cat {
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.25);
    font-size: 0.8em;
}
.chat-bubble .ephra-confirm-args { margin-top: 4px; word-break: break-word; opacity: 0.85; }
.chat-bubble .ephra-confirm-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chat-bubble .ephra-confirm-actions button {
    padding: 5px 12px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9em;
    background: rgba(0, 0, 0, 0.08);
    color: inherit;
}
.chat-bubble .ephra-confirm-actions .ephra-confirm-yes { background: rgba(34, 197, 94, 0.25); }
.chat-bubble .ephra-confirm-actions .ephra-confirm-no { background: rgba(239, 68, 68, 0.2); }
.chat-bubble .ephra-confirm-actions button:disabled { opacity: 0.5; cursor: default; }

/* ==========================================================
   v3 : barres d'outils de résultat, bouton Annuler, accessibilité
   ========================================================== */
.aif-result-tools { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.aif-result-tools .aif-tool-btn { margin: 0; padding: 8px 14px; font-size: 13px; border-radius: 20px; min-height: 36px; }
.aif-cancel-btn {
    margin: 10px auto 0; display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid #ef4444 !important; color: #ef4444 !important; background: rgba(239, 68, 68, 0.08) !important;
    padding: 8px 16px; border-radius: 20px; font-weight: 600; min-height: 36px;
}
.aif-cancel-btn:hover { background: rgba(239, 68, 68, 0.16) !important; }
.aif-cancel-btn[hidden] { display: none !important; }
button:focus-visible, select:focus-visible, textarea:focus-visible, input:focus-visible, [role="checkbox"]:focus-visible {
    outline: 2px solid var(--primary, #6366f1); outline-offset: 2px;
}
@media (max-width: 600px) {
    .aif-result-tools { justify-content: stretch; }
    .aif-result-tools .aif-tool-btn { flex: 1 1 30%; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* =========================================================
   v8 – AI ACADEMY : « 🎧 Écouter ce cours » (synthèse vocale du navigateur)
   ========================================================= */
.aif-listen {
    background: var(--input-bg); border: 1px solid var(--border); border-radius: 14px;
    padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; color: var(--text);
}
.aif-listen__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.aif-listen__title { font-size: 13px; font-weight: 800; color: var(--primary); text-transform: uppercase; letter-spacing: 0.5px; }
.aif-listen__duration, .aif-listen__count { font-size: 12px; color: var(--text-muted); }
.aif-listen__controls, .aif-listen__options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.aif-listen__btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin: 0;
    min-height: 40px; padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer;
    background: var(--card); color: var(--text); border: 1px solid var(--border); width: auto;
}
.aif-listen__btn:hover:not(:disabled) { border-color: var(--primary); }
.aif-listen__btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.aif-listen__btn--primary:hover:not(:disabled) { background: var(--primary-hover); }
.aif-listen__btn:disabled { opacity: 0.5; cursor: not-allowed; }
.aif-listen__btn[hidden], .aif-listen [hidden] { display: none !important; }
.aif-listen__field { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.aif-listen__field label { margin: 0; font-size: 12px; color: var(--text-muted); }
.aif-listen__select {
    background: var(--card); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
    padding: 6px 8px; font-size: 13px; min-height: 36px; max-width: 260px; width: auto !important; margin: 0;
}
.aif-listen__check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); font-weight: 600; cursor: pointer; margin: 0; }
.aif-listen__check input { width: 16px !important; height: 16px; padding: 0; margin: 0; accent-color: var(--primary); }
.aif-listen__progress { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.aif-listen__bar { height: 100%; width: 0; background: var(--primary); border-radius: 999px; transition: width 0.4s ease; }
.aif-listen__foot { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.aif-listen__status { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.aif-listen--unavailable .aif-listen__status { color: var(--text); }
.aif-listen[data-state="playing"] .aif-listen__title::after { content: ' • en lecture'; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text-muted); }
/* Paragraphe en cours de lecture : simple classe posée sur l'élément déjà rendu */
.aif-tts-reading {
    background: rgba(59, 130, 246, 0.12);
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    box-shadow: inset 3px 0 0 var(--primary);
    border-radius: 6px; padding-left: 8px; margin-left: -8px;
    scroll-margin: 80px 0;
}
@media (max-width: 600px) {
    .aif-listen { padding: 12px; }
    .aif-listen__controls .aif-listen__btn { flex: 1 1 40%; }
    .aif-listen__field, .aif-listen__field--voice { flex: 1 1 100%; }
    .aif-listen__select { flex: 1; max-width: none; font-size: 16px; } /* 16 px : pas de zoom auto sur iOS */
}
@media (prefers-reduced-motion: reduce) {
    .aif-listen__bar { transition: none; }
}

/* =========================================================
   v14 – HUB : « 🕘 Récemment utilisées » (3 dernières apps, stockage local)
   ========================================================= */
.recent-apps {
    margin: 0 0 24px 0; padding: 14px 18px; width: 100%;
    background: var(--container-bg); border: 1px solid var(--border); border-radius: 16px;
    box-shadow: 0 4px 15px var(--shadow); color: var(--text);
}
.recent-apps[hidden] { display: none !important; }
body.neon-theme .recent-apps { backdrop-filter: blur(24px); }
.recent-apps__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.recent-apps__title { margin: 0; font-size: 13px; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.recent-apps__clear {
    margin: 0; width: auto; min-height: 32px; padding: 4px 12px; border-radius: 999px; cursor: pointer;
    background: transparent; color: var(--text-muted); border: 1px solid var(--border); font-size: 12px; font-weight: 600;
}
.recent-apps__clear:hover { color: var(--text); border-color: var(--text-muted); }
.recent-apps__list {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
}
.recent-apps__item { margin: 0; padding: 0; min-width: 0; }
.recent-app {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; margin: 0;
    padding: 8px 12px 8px 8px; border-radius: 12px; cursor: pointer; text-align: left; text-decoration: none;
    background: var(--card); color: var(--text); border: 1px solid var(--border);
    font: inherit; font-size: 14px; font-weight: 700;
    transition: border-color .2s, transform .2s;
}
.recent-app:hover { border-color: var(--text-muted); transform: translateY(-2px); }
.recent-app:focus-visible { outline: 2px solid var(--primary, #6366f1); outline-offset: 2px; }
.recent-app__icon {
    flex: 0 0 40px; width: 40px; height: 40px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--primary); color: #fff; font-size: 22px;
}
.recent-app__icon i { color: #fff; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25)); }
.recent-app__title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.services-grid:focus { outline: none; }
@media (max-width: 768px) {
    .recent-apps { padding: 12px; border-radius: 14px; }
    .recent-apps__list { grid-template-columns: 1fr; gap: 8px; }
    .recent-app { min-height: 48px; }
    .recent-app__icon { flex-basis: 34px; width: 34px; height: 34px; font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
    .recent-app { transition: none; }
    .recent-app:hover { transform: none; }
}
