/* =========================================================================
   Portail Astralook — DS on-brand (navy #0F2443 / or #C29317), clair + sombre.
   Portal Astralook — on-brand DS (navy / gold), light + dark.
   Thème : par défaut clair ; prefers-color-scheme sombre ; [data-theme] force.
   Theme: light by default; prefers-color-scheme dark; [data-theme] forces.
   ========================================================================= */

:root {
    --navy: #0F2443;
    --gold: #C29317;
    --gold-soft: #d8ae3f;

    --bg: #f4f6f9;
    --bg-panel: #ffffff;
    --bg-elevated: #ffffff;
    --border: #e2e7ee;
    --border-strong: #cfd7e3;
    --text: #0F2443;
    --text-soft: #5a6b83;
    --text-invert: #ffffff;
    --accent: var(--gold);
    --shadow: 0 1px 2px rgba(15,36,67,.06), 0 8px 24px rgba(15,36,67,.08);
    --radius: 14px;
    --sidebar-w: 244px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #080C14;
        --bg-panel: #0f1a2e;
        --bg-elevated: #13203a;
        --border: #1e2c46;
        --border-strong: #29395a;
        --text: #e8ecf4;
        --text-soft: #97a6c0;
        --text-invert: #0b1220;
        --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
    }
}

:root[data-theme="dark"] {
    --bg: #080C14;
    --bg-panel: #0f1a2e;
    --bg-elevated: #13203a;
    --border: #1e2c46;
    --border-strong: #29395a;
    --text: #e8ecf4;
    --text-soft: #97a6c0;
    --text-invert: #0b1220;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: "DM Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ---------- Boutons / champs ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    font: inherit; font-weight: 500; cursor: pointer;
    padding: .7rem 1.1rem; border-radius: 10px; border: 1px solid transparent;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: #16345f; }
:root[data-theme="dark"] .btn-primary,
.btn-primary { }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--bg-elevated); }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px;
    background: transparent; border: 1px solid var(--border-strong); color: var(--text-soft);
    cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg-elevated); color: var(--accent); }
.theme-toggle-form { margin: 0; display: inline-flex; }

label { display: block; margin: 0 0 1rem; }
label > span { display: block; font-size: .85rem; font-weight: 500; color: var(--text-soft); margin-bottom: .35rem; }
input[type="text"], input[type="password"] {
    width: 100%; font: inherit; color: var(--text);
    padding: .7rem .85rem; border-radius: 10px;
    background: var(--bg-panel); border: 1px solid var(--border-strong);
    transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(194,147,23,.18); }
.code-input { text-align: center; letter-spacing: .5em; font-size: 1.4rem; font-weight: 500; }

/* ---------- Alertes ---------- */
.alert { padding: .7rem .9rem; border-radius: 10px; font-size: .9rem; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-error { background: rgba(214,58,58,.1); color: #d63a3a; border-color: rgba(214,58,58,.25); }
.alert-info { background: rgba(194,147,23,.1); color: var(--gold); border-color: rgba(194,147,23,.28); }

/* ---------- Écrans d'authentification ---------- */
body.auth { display: flex; }
.auth-wrap { margin: auto; width: 100%; max-width: 400px; padding: 2rem 1.25rem; }
.auth-card {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 2rem 1.9rem;
}
.auth-brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.15rem; color: var(--navy); margin-bottom: 1.4rem; }
:root[data-theme="dark"] .auth-brand { color: var(--text); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .auth-brand { color: var(--text); } }
.auth-card h1 { font-size: 1.35rem; margin: 0 0 .35rem; }
.auth-sub { color: var(--text-soft); font-size: .92rem; margin: 0 0 1.4rem; }
.auth-alt { text-align: center; margin-top: 1rem; font-size: .88rem; }
.auth-alt a, .alert a { color: var(--accent); }

/* ---------- Application (sidebar + header + tuiles) ---------- */
body.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
    background: var(--navy); color: #dfe6f1;
    display: flex; flex-direction: column; padding: 1.25rem 1rem;
    position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.2rem; color: #fff; padding: .25rem .3rem 1.4rem; }
.nav { display: flex; flex-direction: column; gap: .25rem; }
.nav-item { display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: 10px; color: #c3cee0; font-weight: 500; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(194,147,23,.16); color: #fff; }
.nav-item.active svg { color: var(--gold-soft); }
.sidebar-foot { margin-top: auto; font-size: .78rem; color: rgba(255,255,255,.4); padding: .3rem; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.75rem; border-bottom: 1px solid var(--border);
    background: var(--bg-panel); position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-weight: 700; font-size: 1.05rem; }
.topbar-actions { display: flex; align-items: center; gap: .6rem; }

.content { padding: 1.9rem 1.75rem; max-width: 1120px; width: 100%; }
.tiles-head h1 { font-size: 1.5rem; margin: 0 0 .3rem; }
.tiles-head p { color: var(--text-soft); margin: 0 0 1.6rem; }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.1rem; }
@media (max-width: 1024px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px)  { .tiles { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .tiles { grid-template-columns: 1fr; } }

.tile {
    position: relative; display: flex; flex-direction: column; gap: .9rem;
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
    transition: transform .12s, border-color .12s, box-shadow .12s;
}
.tile:hover { transform: translateY(-3px); border-color: var(--gold); }
.tile-icon { width: 62px; height: 62px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--bg-elevated); border: 1px solid var(--border); }
.tile-name { font-weight: 700; font-size: 1.05rem; }
.tile-desc { color: var(--text-soft); font-size: .88rem; }
.tile-badge { position: absolute; top: 1rem; right: 1rem; color: var(--gold); opacity: .8; }

/* ---------- Responsive : sidebar repliée en barre haute ---------- */
@media (max-width: 640px) {
    body.app { grid-template-columns: 1fr; }
    .sidebar { flex-direction: row; align-items: center; height: auto; position: static; padding: .8rem 1rem; }
    .sidebar .brand { padding: 0; }
    .nav { flex-direction: row; margin-left: auto; }
    .sidebar-foot { display: none; }
}
