/* frontend/static/style.css */

/* --- VARIABLES & RESET --- */
:root {
    --bg-main: #060b13;       /* Fond principal (très sombre, correspond à l'image) */
    --bg-panel: #0d1522;      /* Fond du panneau de droite et header */
    --bg-input: #121d2f;      /* Fond des champs de texte et messages utilisateur */
    --text-main: #e2e8f0;     /* Texte clair */
    --text-muted: #8b9bb4;    /* Texte secondaire (gris-bleu) */
    --accent-cyan: #38bdf8;   /* Bleu cyan (boutons, sliders, accents) */
    --accent-cyan-hover: #0ea5e9;
    --border-color: #1e293b;  /* Bordures discrètes */
    --msg-ai-bg: #0d1522;     /* Fond de la bulle IA */
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

/* --- CORRECTION MAJEURE : FORCER L'AFFICHAGE DES RÉGLAGES --- */
#config-content {
    display: block !important; /* Outrepasse la classe 'hidden' du HTML */
}
.toggle-config-button {
    display: none !important; /* Le bouton n'est plus nécessaire car le panneau est toujours là */
}

/* On garde hidden pour les autres éléments comme le loader de la Forge */
.hidden { display: none !important; }

/* --- AUTHENTIFICATION --- */
.auth-panel-top {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--bg-panel);
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    border: 1px solid var(--border-color);
    text-align: center;
    width: 350px;
    z-index: 1000;
}
.auth-panel-top input[type="password"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-input);
    color: var(--text-main);
}
.auth-panel-top button {
    width: 100%;
    background-color: var(--accent-cyan);
    color: #000;
    padding: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

/* --- CONTENEUR PRINCIPAL --- */
.container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-main);
    overflow: hidden;
}

/* --- HEADER --- */
header {
    background-color: var(--bg-panel);
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}
.header-top-row {
    display: flex;
    justify-content: center;
}
header h1 {
    margin: 0;
    font-size: 2em;
    color: var(--accent-cyan);
    text-align: center;
    font-weight: bold;
}
header .subtitle {
    margin: 4px 0 0;
    font-size: 0.9em;
    color: var(--text-muted);
    text-align: center;
}
.header-info {
    display: flex;
    justify-content: center;
    gap: 30px;
    font-size: 0.85em;
    color: var(--text-muted);
    margin-top: 15px;
}

/* --- MAIN LAYOUT --- */
main {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
}

/* --- CHAT PANEL (GAUCHE) --- */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background-color: var(--bg-main);
}

.chat-history {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 15px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Scrollbars discrètes */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 3px; }

/* Bulles de message (Calqué sur l'image) */
.message {
    max-width: 90%;
    padding: 20px;
    border-radius: 6px;
    line-height: 1.6;
    font-size: 15px;
}
.message.user {
    align-self: flex-end;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
}
.message.ai {
    align-self: flex-start;
    background-color: var(--msg-ai-bg);
    border-left: 4px solid var(--accent-cyan); /* La fameuse ligne bleue à gauche */
}

.message-actions {
    text-align: right;
    margin-top: 10px;
}
.message-actions button {
    background: #000;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    transition: color 0.2s;
}
.message-actions button:hover {
    color: var(--accent-cyan);
}

/* Zone de saisie */
.chat-input-area {
    display: flex;
    gap: 15px;
    align-items: stretch;
    height: 90px;
}
#user-query {
    flex-grow: 1;
    background-color: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 15px;
    font-family: inherit;
    font-size: 15px;
    resize: none;
}
#user-query:focus {
    outline: none;
    border-color: var(--accent-cyan);
}
#send-button {
    background-color: var(--accent-cyan);
    color: #000;
    border: none;
    border-radius: 6px;
    padding: 0 30px;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s;
    width: 180px;
}
#send-button:hover { background-color: var(--accent-cyan-hover); }

/* --- CONFIGURATION PANEL (DROITE) --- */
.config-panel {
    width: 480px;
    background-color: var(--bg-panel);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 25px;
    border-left: 1px solid var(--border-color);
}

.config-group {
    margin-bottom: 25px;
}
.config-group h3, .config-group h4 {
    margin-top: 0;
    color: var(--text-main);
    font-size: 1.1em;
    margin-bottom: 15px;
    font-weight: bold;
}
.config-group label {
    display: block;
    font-size: 0.85em;
    margin-bottom: 8px;
    color: var(--text-main);
}

/* Sliders natifs avec la couleur bleue (accent-color) */
.config-group input[type="range"] {
    width: 100%;
    accent-color: var(--accent-cyan);
    cursor: pointer;
    margin-bottom: 15px;
}

.config-group select {
    width: 100%;
    padding: 10px;
    background-color: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 15px;
}

.eclaireur-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.eclaireur-options input[type="checkbox"] {
    accent-color: var(--accent-cyan);
    width: 16px;
    height: 16px;
}

.info-text {
    font-size: 0.8em;
    color: var(--text-muted);
    margin-bottom: 15px;
    line-height: 1.4;
}

/* --- PANNEAU D'INGESTION ET PURGE --- */
.upload-panel {
    margin-bottom: 20px;
}
.upload-panel select, .upload-panel input[type="file"] {
    width: 100%;
    padding: 10px;
    background-color: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 10px;
}

.upload-panel button, .purge-button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    background-color: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    transition: background 0.2s;
}
.upload-panel button:hover, .purge-button:hover {
    background-color: var(--border-color);
}

/* --- OVERLAY CHARGEMENT --- */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(6, 11, 19, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}
.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-cyan);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Styles pour le Markdown (Optionnel mais propre) */
.markdown-body pre {
    background-color: var(--bg-main);
    padding: 15px;
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}
.markdown-body code {
    font-family: 'Courier New', Courier, monospace;
    background-color: var(--bg-main);
    padding: 2px 5px;
    border-radius: 3px;
}
.markdown-body p { margin-top: 0; }
/* =============================================================================
   UPGRADE VISUEL CYBER-TECH (Potars, Boutons, Saisie)
   ============================================================================= */

/* 1. Potentiomètres (Range Sliders) */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: #0f172a;
    border-radius: 4px;
    border: 1px solid #1e293b;
    outline: none;
    margin: 10px 0 16px 0;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="range"]:hover {
    border-color: #00e5ff;
}

/* Curseur (Thumb) Chrome / Edge / Safari */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: #00e5ff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.6), inset 0 0 2px #fff;
    border: 1px solid #e0f7fa;
    transition: transform 0.15s ease, background-color 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #38bdf8;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.9);
}

/* Curseur Firefox */
input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: #00e5ff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
    border: 1px solid #e0f7fa;
}

/* 2. Bouton d'Action (Envoyer / Forge) */
#send-button, .btn-primary, button[type="submit"] {
    background: linear-gradient(135deg, #0284c7 0%, #00e5ff 100%) !important;
    color: #04101e !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.85rem;
    border: 1px solid #38bdf8 !important;
    border-radius: 6px !important;
    padding: 12px 20px !important;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 229, 255, 0.25) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#send-button:hover, .btn-primary:hover {
    background: linear-gradient(135deg, #00e5ff 0%, #38bdf8 100%) !important;
    box-shadow: 0 0 18px rgba(0, 229, 255, 0.5) !important;
    transform: translateY(-1px);
}

#send-button:active, .btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(0, 229, 255, 0.2) !important;
}

/* 3. Zone de Saisie Utilisateur */
textarea, input[type="text"], select {
    background-color: #070d18 !important;
    border: 1px solid #1e293b !important;
    color: #e2e8f0 !important;
    border-radius: 6px !important;
    padding: 12px 14px !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus, input[type="text"]:focus, select:focus {
    border-color: #00e5ff !important;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.25) !important;
    outline: none !important;
}

/* =============================================================================
   UPGRADE VISUEL CYBER-TECH (Potars, Boutons, Saisie)
   ============================================================================= */

/* 1. Potentiomètres (Range Sliders) */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: #0f172a;
    border-radius: 4px;
    border: 1px solid #1e293b;
    outline: none;
    margin: 10px 0 16px 0;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="range"]:hover {
    border-color: #00e5ff;
}

/* Curseur (Thumb) Chrome / Edge / Safari */
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: #00e5ff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.6), inset 0 0 2px #fff;
    border: 1px solid #e0f7fa;
    transition: transform 0.15s ease, background-color 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #38bdf8;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.9);
}

/* Curseur Firefox */
input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: #00e5ff;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
    border: 1px solid #e0f7fa;
}

/* 2. Bouton d'Action (Envoyer / Forge) */
#send-button, .btn-primary, button[type="submit"] {
    background: linear-gradient(135deg, #0284c7 0%, #00e5ff 100%) !important;
    color: #04101e !important;
    font-weight: 700 !important;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.85rem;
    border: 1px solid #38bdf8 !important;
    border-radius: 6px !important;
    padding: 12px 20px !important;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 229, 255, 0.25) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

#send-button:hover, .btn-primary:hover {
    background: linear-gradient(135deg, #00e5ff 0%, #38bdf8 100%) !important;
    box-shadow: 0 0 18px rgba(0, 229, 255, 0.5) !important;
    transform: translateY(-1px);
}

#send-button:active, .btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(0, 229, 255, 0.2) !important;
}

/* 3. Zone de Saisie Utilisateur */
textarea, input[type="text"], select {
    background-color: #070d18 !important;
    border: 1px solid #1e293b !important;
    color: #e2e8f0 !important;
    border-radius: 6px !important;
    padding: 12px 14px !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus, input[type="text"]:focus, select:focus {
    border-color: #00e5ff !important;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.25) !important;
    outline: none !important;
}

/* =============================================================================
   OVERDRIVE VISUEL : TYPOGRAPHIE & ANIMATIONS
   ============================================================================= */

/* 1. Typographie Markdown dans le chat */
.chat-message, .ai-response {
    line-height: 1.6;
    font-size: 0.95rem;
}

.chat-message strong {
    color: #00e5ff;
    font-weight: 600;
}

.chat-message ul {
    margin-top: 10px;
    margin-bottom: 10px;
    margin-left: 0;
    padding-left: 20px;
    border-left: 2px solid rgba(0, 229, 255, 0.3);
}

.chat-message li {
    margin-bottom: 8px;
    padding-left: 5px;
}

.chat-message h3, .chat-message h4 {
    color: #38bdf8;
    margin-top: 18px;
    margin-bottom: 10px;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(56, 189, 248, 0.2);
    padding-bottom: 4px;
}

/* 2. Scrollbar Cybernétique */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: #070d18;
}
::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 4px;
    border: 1px solid rgba(0, 229, 255, 0.3);
}
::-webkit-scrollbar-thumb:hover {
    background: #00e5ff;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
}

/* 3. Animation du Bouton en mode "Forgeage" */
.btn-loading {
    pointer-events: none;
    opacity: 0.8;
    background: linear-gradient(135deg, #090e17 0%, #1e293b 100%) !important;
    color: #00e5ff !important;
    animation: pulse-forge 1.5s infinite;
}

@keyframes pulse-forge {
    0% { box-shadow: 0 0 0 0 rgba(0, 229, 255, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(0, 229, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 229, 255, 0); }
}

/* =============================================================================
   BOUTON ET TIROIR DÉPLIANT DES SOURCES
   ============================================================================= */

.message-footer {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.toggle-sources-btn {
    background: #090e17;
    border: 1px solid #1e293b;
    color: #94a3b8;
    padding: 5px 12px;
    font-size: 0.78rem;
    font-family: inherit;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.toggle-sources-btn:hover {
    color: #00e5ff;
    border-color: #00e5ff;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.2);
}

.sources-drawer {
    margin-top: 8px;
    padding: 10px 14px;
    background: #050a12;
    border: 1px solid #1e293b;
    border-radius: 4px;
}

.sources-drawer ul {
    margin: 0 !important;
    padding-left: 18px !important;
    list-style: square !important;
}

.sources-drawer li {
    font-size: 0.8rem;
    color: #cbd5e1;
    margin-bottom: 4px;
    line-height: 1.4;
}

.hidden {
    display: none !important;
}
