/* =====================================================================
   GESEC — Feuille de style (design professionnel)
   ===================================================================== */
:root {
    --bg:            #f1f5f9;
    --surface:       #ffffff;
    --surface-2:     #f8fafc;
    --border:        #e2e8f0;
    --border-strong: #cbd5e1;

    --text:          #0f172a;
    --text-soft:     #475569;
    --text-muted:    #94a3b8;

    --primary:       #4f46e5;
    --primary-dark:  #4338ca;
    --primary-soft:  #eef2ff;

    --sidebar:       #0b1220;
    --sidebar-2:     #111a2e;
    --sidebar-text:  #cbd5e1;
    --sidebar-muted: #64748b;

    --ok:            #16a34a;
    --ok-soft:       #dcfce7;
    --warn:          #b45309;
    --warn-soft:     #fef3c7;
    --danger:        #dc2626;
    --danger-soft:   #fee2e2;

    --radius:        12px;
    --radius-sm:     8px;
    --shadow:        0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
    --shadow-md:     0 4px 12px rgba(15,23,42,.08);
    --sidebar-w:     248px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
code { font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace; font-size: .86em; }
.muted { color: var(--text-muted); }
.text-soft { color: var(--text-soft); }

/* ============ Shell application (sidebar + main) ============ */
body.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 22px;
    font-size: 1.15rem; font-weight: 700; color: #fff;
    letter-spacing: .02em;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-brand .logo {
    width: 32px; height: 32px; border-radius: 9px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    display: grid; place-items: center; color: #fff; font-weight: 800; font-size: .95rem;
    box-shadow: 0 4px 10px rgba(79,70,229,.4);
}
.sidebar-nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-nav .nav-label {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
    color: var(--sidebar-muted); padding: 12px 12px 6px;
}
.sidebar-nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--sidebar-text); font-weight: 500;
    transition: background .15s, color .15s;
}
.sidebar-nav a svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(79,70,229,.35); }
.sidebar-nav a.active svg { opacity: 1; }

.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 6px 12px; }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: grid; place-items: center; color: #fff; font-weight: 700; font-size: .85rem;
}
.user-chip .u-name { color: #fff; font-weight: 600; font-size: .85rem; line-height: 1.2; }
.user-chip .u-role { color: var(--sidebar-muted); font-size: .72rem; }

/* ============ Zone principale ============ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 62px; background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; position: sticky; top: 0; z-index: 10;
}
.topbar .page-title { font-size: 1.05rem; font-weight: 650; }
.topbar-right { display: flex; align-items: center; gap: 14px; }

.content { padding: 28px; max-width: 1200px; width: 100%; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head .subtitle { color: var(--text-muted); margin-top: 4px; }

/* ============ Boutons ============ */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
    font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(79,70,229,.25); }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 6px 12px; font-size: .82rem; }
.btn svg { width: 16px; height: 16px; }

.link-btn { background: none; border: none; color: var(--danger); cursor: pointer; padding: 0; font: inherit; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }
.inline { display: inline; }

/* ============ Cartes ============ */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.card h3 { font-size: 1rem; margin-bottom: 8px; }
.card p { color: var(--text-soft); margin: 0 0 16px; }

.stat { display: flex; align-items: center; gap: 16px; }
.stat .stat-icon {
    width: 46px; height: 46px; border-radius: 11px; display: grid; place-items: center;
    background: var(--primary-soft); color: var(--primary); flex: 0 0 46px;
}
.stat .stat-icon svg { width: 22px; height: 22px; }
.stat .stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.stat .stat-label { color: var(--text-muted); font-size: .82rem; margin-top: 3px; }

.endpoint-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.endpoint-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.endpoint-list li:last-child { border-bottom: 0; }
.method { font-size: .68rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; letter-spacing: .03em; }
.method.get { background: #e0f2fe; color: #0369a1; }
.method.post { background: #dcfce7; color: #15803d; }

/* ============ Tableau ============ */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { text-align: left; padding: 13px 16px; font-size: .875rem; }
.grid thead th {
    background: var(--surface-2); color: var(--text-muted);
    font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
}
.grid tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
.grid tbody tr:last-child { border-bottom: 0; }
.grid tbody tr:hover { background: var(--surface-2); }
.grid td code { background: var(--surface-2); padding: 2px 7px; border-radius: 6px; border: 1px solid var(--border); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 600; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.revoked { background: var(--danger-soft); color: var(--danger); }
.badge.expired { background: var(--warn-soft); color: var(--warn); }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { background: var(--primary-soft); color: var(--primary); font-size: .74rem; font-weight: 600; padding: 2px 9px; border-radius: 6px; }

/* ============ Formulaires ============ */
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; max-width: 640px; }
.field { margin-bottom: 18px; }
.field > label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field .hint { color: var(--text-muted); font-size: .8rem; margin-top: 4px; }
.input, select.input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); font: inherit; background: #fff; color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, select.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.readonly { padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }

.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 10px; }
.check {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
    transition: border-color .15s, background .15s; font-weight: 400;
}
.check:hover { border-color: var(--primary); background: var(--primary-soft); }
.check input { margin-top: 3px; }
.check .c-name { font-weight: 600; }

.actions { display: flex; gap: 10px; margin-top: 22px; }

/* ============ Alertes ============ */
.alert { display: flex; gap: 10px; padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-weight: 500; border: 1px solid transparent; }
.alert.error { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.alert.success { background: var(--ok-soft); color: #166534; border-color: #bbf7d0; }
.alert.warning { background: var(--warn-soft); color: #92400e; border-color: #fde68a; }
.alert svg { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 1px; }

/* ============ Clé générée ============ */
.key-box { display: flex; align-items: center; gap: 12px; background: #0b1220; color: #e2e8f0; padding: 16px 18px; border-radius: var(--radius-sm); word-break: break-all; }
.key-box code { color: #7dd3fc; font-size: .95rem; }
.key-box .copy { margin-left: auto; }

/* ============ Page de connexion ============ */
body.auth {
    display: grid; place-items: center; min-height: 100vh;
    background: radial-gradient(1200px 600px at 20% -10%, #1e293b 0%, #0b1220 55%);
    padding: 24px;
}
.auth-card {
    width: 100%; max-width: 400px; background: var(--surface);
    border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.35); padding: 34px 32px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .logo {
    width: 42px; height: 42px; border-radius: 11px;
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    display: grid; place-items: center; color: #fff; font-weight: 800;
    box-shadow: 0 6px 16px rgba(79,70,229,.45);
}
.auth-brand .b-name { font-size: 1.2rem; font-weight: 700; }
.auth-brand .b-sub { color: var(--text-muted); font-size: .78rem; }
.auth-card h1 { font-size: 1.25rem; margin-bottom: 4px; }
.auth-card .sub { color: var(--text-muted); margin-bottom: 22px; }
.auth-hint { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: .8rem; text-align: center; }
.auth-hint code { background: var(--surface-2); padding: 2px 6px; border-radius: 5px; }
.btn.block { width: 100%; justify-content: center; padding: 11px; }

.field-validation-error { color: var(--danger); font-size: .82rem; display: block; margin-top: 5px; }
.validation-summary-errors { color: #991b1b; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }

.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state svg { width: 46px; height: 46px; opacity: .4; margin-bottom: 12px; }

/* ============ Documentation API ============ */
.lang-tabs { display: flex; gap: 8px; position: sticky; top: 62px; background: var(--bg); padding: 12px 0; z-index: 5; flex-wrap: wrap; }
.lang-tab {
    padding: 8px 16px; border: 1px solid var(--border-strong); border-radius: 8px;
    background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-weight: 600; font-size: .85rem;
    transition: background .15s, color .15s, border-color .15s;
}
.lang-tab:hover { background: var(--surface-2); }
.lang-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(79,70,229,.25); }

.endpoint { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.endpoint-header { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.endpoint-header .path { font-family: "JetBrains Mono", Consolas, monospace; font-weight: 600; font-size: .95rem; }
.endpoint-body { padding: 18px 20px; }
.endpoint-desc { color: var(--text-soft); margin: 0 0 12px; }
.auth-line { font-size: .85rem; color: var(--text-soft); margin: 0 0 14px; }

.method.lg { font-size: .78rem; padding: 5px 11px; }
.method.put { background: #fef3c7; color: #b45309; }
.method.delete { background: #fee2e2; color: #dc2626; }

.code-sample {
    background: #0b1220; color: #e2e8f0; padding: 16px 18px; border-radius: var(--radius-sm);
    overflow-x: auto; margin: 0 0 4px; font-family: "JetBrains Mono", Consolas, monospace;
    font-size: .82rem; line-height: 1.55; white-space: pre;
}
.code-sample code { color: inherit; background: none; padding: 0; border: 0; font-size: inherit; }
.code-sample.response { background: #0f1b2d; color: #7dd3fc; }
.response-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 14px 0 6px; font-weight: 600; }

/* ============ Responsive ============ */
@media (max-width: 820px) {
    .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; }
    .main { width: 100%; }
    .content { padding: 18px; }
}
