/* ============================================================================
   ASSISTANT TERRAIN — style.css
   Styles globaux + 4 thèmes (Nuit, Carbone, Crème, Océan)
   IDJ Ingénierie — Phase 1
   ============================================================================ */

/* ============================================================================
   1. THÈMES — Variables CSS
   ============================================================================ */

/* --- THÈME 1 : NUIT (défaut) --- */
[data-theme="nuit"], :root {
    --bg: #0C0E14;
    --bg2: #141721;
    --bg3: #1C2030;
    --bg4: #252A3A;
    --border: #2A3048;
    --text: #E4E8F1;
    --text2: #7E879E;
    --text3: #505872;
    --accent: #4A73F5;
    --accent2: #6B94FF;
    --accent-glow: rgba(74,115,245,0.15);
    --vert: #2DD4A0;
    --vert-glow: rgba(45,212,160,0.12);
    --orange: #F5A623;
    --orange-glow: rgba(245,166,35,0.12);
    --rouge: #EF4444;
    --rouge-glow: rgba(239,68,68,0.12);
    --violet: #A855F7;
    --violet-glow: rgba(168,85,247,0.12);
    --msg-user-bg: linear-gradient(135deg, #4A73F5, #5580F8);
    --msg-bot-bg: var(--bg3);
    --login-gradient: linear-gradient(135deg, var(--accent2), var(--vert));
    --btn-gradient: linear-gradient(135deg, var(--accent), #5B87FF);
}

/* --- THÈME 2 : CARBONE --- */
[data-theme="carbone"] {
    --bg: #050505;
    --bg2: #0E0E0E;
    --bg3: #1A1A1A;
    --bg4: #252525;
    --border: #2A2A2A;
    --text: #E0E0E0;
    --text2: #808080;
    --text3: #555555;
    --accent: #00E676;
    --accent2: #69F0AE;
    --accent-glow: rgba(0,230,118,0.12);
    --vert: #00E676;
    --vert-glow: rgba(0,230,118,0.12);
    --orange: #FFAB40;
    --orange-glow: rgba(255,171,64,0.12);
    --rouge: #FF5252;
    --rouge-glow: rgba(255,82,82,0.12);
    --violet: #E040FB;
    --violet-glow: rgba(224,64,251,0.12);
    --msg-user-bg: linear-gradient(135deg, #00C853, #00E676);
    --msg-bot-bg: var(--bg3);
    --login-gradient: linear-gradient(135deg, var(--accent2), #FFAB40);
    --btn-gradient: linear-gradient(135deg, #00C853, #00E676);
}

/* --- THÈME 3 : CRÈME --- */
[data-theme="creme"] {
    --bg: #F5F0E8;
    --bg2: #FFFFFF;
    --bg3: #EDE8DF;
    --bg4: #E0D9CE;
    --border: #D4CCC0;
    --text: #2C2418;
    --text2: #7A7060;
    --text3: #A69E90;
    --accent: #C2632A;
    --accent2: #D97B46;
    --accent-glow: rgba(194,99,42,0.1);
    --vert: #2D8659;
    --vert-glow: rgba(45,134,89,0.1);
    --orange: #D4920A;
    --orange-glow: rgba(212,146,10,0.1);
    --rouge: #C53030;
    --rouge-glow: rgba(197,48,48,0.1);
    --violet: #7C3AED;
    --violet-glow: rgba(124,58,237,0.1);
    --msg-user-bg: linear-gradient(135deg, #C2632A, #D97B46);
    --msg-bot-bg: var(--bg2);
    --login-gradient: linear-gradient(135deg, var(--accent2), var(--vert));
    --btn-gradient: linear-gradient(135deg, #C2632A, #D97B46);
}

/* --- THÈME 4 : OCÉAN --- */
[data-theme="ocean"] {
    --bg: #0A1628;
    --bg2: #0F1F38;
    --bg3: #162A4A;
    --bg4: #1E3558;
    --border: #253D60;
    --text: #E0EAF5;
    --text2: #7A9BBF;
    --text3: #4A6A8F;
    --accent: #00BCD4;
    --accent2: #4DD0E1;
    --accent-glow: rgba(0,188,212,0.12);
    --vert: #26A69A;
    --vert-glow: rgba(38,166,154,0.12);
    --orange: #FFB74D;
    --orange-glow: rgba(255,183,77,0.12);
    --rouge: #EF5350;
    --rouge-glow: rgba(239,83,80,0.12);
    --violet: #AB47BC;
    --violet-glow: rgba(171,71,188,0.12);
    --msg-user-bg: linear-gradient(135deg, #00ACC1, #00BCD4);
    --msg-bot-bg: var(--bg3);
    --login-gradient: linear-gradient(135deg, var(--accent2), #FFB74D);
    --btn-gradient: linear-gradient(135deg, #00ACC1, #00BCD4);
}

/* ============================================================================
   2. RESET & BASE
   ============================================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ============================================================================
   3. NAVIGATION
   ============================================================================ */

.nav {
    display: flex;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 100;
    transition: background 0.3s ease;
}

.nav-tab {
    flex: 1;
    padding: 14px 8px 12px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text2);
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
    letter-spacing: 0.3px;
    text-decoration: none;
}

.nav-tab:hover { color: var(--text); }
.nav-tab.active { color: var(--accent2); }

.nav-tab.active::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 25%;
    width: 50%;
    height: 2.5px;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 3px 3px 0 0;
}

.nav-icon {
    font-size: 18px;
    display: block;
    margin-bottom: 3px;
}

/* Bouton paramètres dans la nav */
.nav-settings {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg3);
    color: var(--text2);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 101;
}

.nav-settings:hover {
    border-color: var(--accent);
    color: var(--accent2);
}

/* ============================================================================
   4. PAGES
   ============================================================================ */

.page {
    display: none;
    position: fixed;
    top: 56px;
    bottom: 0;
    left: 0;
    right: 0;
    overflow-y: auto;
}

.page.active {
    display: flex;
    flex-direction: column;
}

/* ============================================================================
   5. LOGIN
   ============================================================================ */

.login-wrap {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--bg);
    padding: 20px;
}

.login-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px 36px;
    width: 100%;
    max-width: 340px;
    text-align: center;
    animation: fadeUp 0.5s ease-out;
}

.login-logo { font-size: 42px; margin-bottom: 8px; }

.login-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
    background: var(--login-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-sub {
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 28px;
}

.login-input {
    width: 100%;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text);
    outline: none;
    margin-bottom: 12px;
    font-family: 'DM Sans', sans-serif;
    transition: border-color 0.2s ease;
}

.login-input:focus { border-color: var(--accent); }
.login-input::placeholder { color: var(--text3); }

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--btn-gradient);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    font-family: 'DM Sans', sans-serif;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.login-error {
    color: var(--rouge);
    font-size: 13px;
    margin-top: 12px;
}

/* ============================================================================
   6. CHAT
   ============================================================================ */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 110px;
}

.msg {
    max-width: 82%;
    margin-bottom: 10px;
    animation: fadeUp 0.3s ease-out;
}

.msg-user { margin-left: auto; }

.msg-user .msg-bubble {
    background: var(--msg-user-bg);
    color: white;
    border-radius: 18px 18px 4px 18px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.55;
}

.msg-bot { margin-right: auto; }

.msg-bot .msg-bubble {
    background: var(--msg-bot-bg);
    border: 1px solid var(--border);
    border-radius: 18px 18px 18px 4px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.55;
}

.msg-time {
    font-size: 11px;
    color: var(--text3);
    margin-top: 4px;
    padding: 0 4px;
}

.msg-user .msg-time { text-align: right; }

.msg-tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    margin-top: 6px;
    letter-spacing: 0.5px;
}

.tag-rouge { background: var(--rouge-glow); color: var(--rouge); }
.tag-vert { background: var(--vert-glow); color: var(--vert); }
.tag-violet { background: var(--violet-glow); color: var(--violet); }
.tag-bleu { background: var(--accent-glow); color: var(--accent2); }
.tag-orange { background: var(--orange-glow); color: var(--orange); }

/* Indicateur "en train d'écrire" */
.typing-indicator {
    display: none;
    margin-right: auto;
    margin-bottom: 10px;
}

.typing-indicator .msg-bubble {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 18px 18px 18px 4px;
    padding: 12px 20px;
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text3);
    animation: typingBounce 1.2s infinite;
}

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

/* Barre de saisie */
.chat-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg2);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input {
    flex: 1;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 13px 20px;
    font-size: 14px;
    color: var(--text);
    outline: none;
    font-family: 'DM Sans', sans-serif;
    transition: border-color 0.2s ease;
}

.chat-input:focus { border-color: var(--accent); }
.chat-input::placeholder { color: var(--text3); }

.btn-mic, .btn-send {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 20px;
    flex-shrink: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-mic {
    background: var(--btn-gradient);
    color: white;
}

.btn-mic:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-mic.recording {
    background: linear-gradient(135deg, var(--rouge), #FF6B6B);
    animation: pulse 1.2s infinite;
}

.btn-send {
    background: var(--bg4);
    color: var(--accent2);
    font-size: 18px;
}

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

/* ============================================================================
   7. DASHBOARD & PERSO
   ============================================================================ */

.dash { padding: 20px 16px 30px; }

.dash-header h2 {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.dash-header p {
    color: var(--text2);
    font-size: 13px;
    margin-top: 3px;
}

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

.perso-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--violet), #C084FC);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 18px 0;
}

.stat-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    transition: border-color 0.2s ease;
}

.stat-card:hover { border-color: var(--bg4); }

.stat-number {
    font-size: 30px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text2);
    margin-top: 4px;
    font-weight: 500;
}

/* Sections */
.dash-section { margin-bottom: 22px; }

.dash-section h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 10px;
}

/* Task items */
.task-item {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 13px 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
    transition: border-color 0.2s ease;
}

.task-item:hover { border-color: var(--bg4); }

.task-prio {
    width: 3.5px;
    min-height: 36px;
    border-radius: 4px;
    flex-shrink: 0;
}

.prio-rouge { background: var(--rouge); }
.prio-orange { background: var(--orange); }
.prio-vert { background: var(--vert); }
.prio-violet { background: var(--violet); }

.task-content { flex: 1; }

.task-title {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
}

.task-meta {
    display: flex;
    gap: 6px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.task-tag {
    font-size: 10px;
    padding: 2px 9px;
    border-radius: 8px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.tag-pro { background: var(--accent-glow); color: var(--accent2); }
.tag-perso { background: var(--violet-glow); color: var(--violet); }
.tag-ech { background: var(--bg3); color: var(--text2); }

/* Alerts */
.alert-item {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--rouge);
    border-radius: 10px;
    padding: 13px 14px;
    margin-bottom: 8px;
}

.alert-title { font-size: 13px; font-weight: 600; color: var(--rouge); }
.alert-desc { font-size: 12px; color: var(--text2); margin-top: 3px; }
.alert-suggest { font-size: 12px; color: var(--accent2); margin-top: 6px; font-style: italic; }

/* Performance */
.perf-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.perf-label {
    font-size: 12px;
    color: var(--text2);
    width: 100px;
    font-weight: 500;
}

.perf-track {
    flex: 1;
    height: 7px;
    background: var(--bg3);
    border-radius: 4px;
    overflow: hidden;
}

.perf-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease-out;
}

.perf-value {
    font-size: 12px;
    font-weight: 600;
    width: 38px;
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
}

/* Boutons action */
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--accent2);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'DM Sans', sans-serif;
    margin-right: 8px;
    margin-top: 6px;
}

.btn-action:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

/* ============================================================================
   8. PANNEAU PARAMÈTRES
   ============================================================================ */

.settings-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    animation: fadeIn 0.2s ease;
}

.settings-overlay.active { display: block; }

.settings-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100%;
    background: var(--bg2);
    border-left: 1px solid var(--border);
    z-index: 201;
    padding: 24px 20px;
    overflow-y: auto;
    transition: right 0.3s cubic-bezier(0.4,0,0.2,1);
}

.settings-panel.active { right: 0; }

.settings-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.settings-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg3);
    color: var(--text2);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-close:hover { color: var(--rouge); }

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

.settings-section h4 {
    font-size: 12px;
    font-weight: 700;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

/* Grille de thèmes */
.theme-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.theme-card {
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
}

.theme-card:hover { border-color: var(--text3); }
.theme-card.active { border-color: var(--accent); }

.theme-preview {
    height: 40px;
    border-radius: 8px;
    margin-bottom: 6px;
}

.theme-name {
    font-size: 12px;
    font-weight: 600;
}

.theme-nuit .theme-preview { background: linear-gradient(135deg, #0C0E14, #1C2030, #4A73F5); }
.theme-carbone .theme-preview { background: linear-gradient(135deg, #050505, #1A1A1A, #00E676); }
.theme-creme .theme-preview { background: linear-gradient(135deg, #F5F0E8, #EDE8DF, #C2632A); }
.theme-ocean .theme-preview { background: linear-gradient(135deg, #0A1628, #162A4A, #00BCD4); }

/* Info système dans settings */
.sys-info {
    font-size: 12px;
    color: var(--text2);
    line-height: 1.8;
}

.sys-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.sys-dot.on { background: var(--vert); }
.sys-dot.off { background: var(--rouge); }

/* ============================================================================
   9. PAGES ERREUR
   ============================================================================ */

.error-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 40px;
}

.error-code {
    font-size: 72px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent);
    line-height: 1;
}

.error-msg {
    font-size: 16px;
    color: var(--text2);
    margin-top: 8px;
}

.error-link {
    display: inline-block;
    margin-top: 24px;
    padding: 12px 24px;
    background: var(--btn-gradient);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
}

/* ============================================================================
   10. ANIMATIONS
   ============================================================================ */

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
    50% { box-shadow: 0 0 0 12px rgba(239,68,68,0); }
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Stagger */
.task-item:nth-child(1) { animation: fadeUp 0.3s ease-out 0.05s both; }
.task-item:nth-child(2) { animation: fadeUp 0.3s ease-out 0.1s both; }
.task-item:nth-child(3) { animation: fadeUp 0.3s ease-out 0.15s both; }
.task-item:nth-child(4) { animation: fadeUp 0.3s ease-out 0.2s both; }

.stat-card:nth-child(1) { animation: fadeUp 0.3s ease-out 0.05s both; }
.stat-card:nth-child(2) { animation: fadeUp 0.3s ease-out 0.1s both; }
.stat-card:nth-child(3) { animation: fadeUp 0.3s ease-out 0.15s both; }
.stat-card:nth-child(4) { animation: fadeUp 0.3s ease-out 0.2s both; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ============================================================================
   11. RESPONSIVE
   ============================================================================ */

@media (min-width: 768px) {
    .chat-messages { max-width: 680px; margin: 0 auto; }
    .dash { max-width: 680px; margin: 0 auto; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
