/* ── Login + Wait (utilisent le _Layout public) ──────────────────────── */

/* Force le fond dark sur les pages login/wait qui héritent du _Layout
   public (sinon fond blanc clair). Selector :has() OK navigateurs 2026. */
body:has(.admin-login-section),
body:has(.admin-wait-section) {
    background: #0b0c0e;
    margin: 0;
}


.admin-login-section,
.admin-wait-section {
    max-width: 380px;
    margin: 4rem auto;
    padding: 2rem;
    background: #181b1f;
    border: 1px solid #2c3035;
    border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,.5);
    color: #ccccdc;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

.admin-login-section h1,
.admin-wait-section h1 {
    font-size: 1.4rem;
    margin: 0 0 1.5rem 0;
    text-align: center;
    color: #ccccdc;
    font-weight: 600;
}

.admin-login-form label,
.admin-otp-form label {
    display: block;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #ccccdc;
}

.admin-login-form input,
.admin-otp-form input {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    margin-top: 0.3rem;
    background: #0b0c0e;
    border: 1px solid #2c3035;
    border-radius: 4px;
    color: #ccccdc;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.admin-login-form input:focus,
.admin-otp-form input:focus {
    outline: none;
    border-color: #5794f2;
}

.admin-login-form button,
.admin-otp-form button {
    width: 100%;
    padding: 0.7rem;
    margin-top: 0.5rem;
    background: #5794f2;
    color: #0b0c0e;
    border: none;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.admin-login-form button:hover,
.admin-otp-form button:hover { background: #75a8f5; }

.admin-error {
    padding: 0.7rem 1rem;
    margin-bottom: 1rem;
    background: rgba(224, 47, 68, 0.1);
    border: 1px solid rgba(224, 47, 68, 0.3);
    color: #e02f44;
    border-radius: 4px;
    font-size: 0.85rem;
}

.admin-login-hint,
.admin-wait-hint {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.85rem;
    color: #8e8e8e;
}

.admin-wait-section { text-align: center; }

.admin-wait-counter {
    margin: 1.5rem 0;
    font-size: 2rem;
    font-weight: 700;
    color: #5794f2;
    font-variant-numeric: tabular-nums;
}

.admin-otp-form { margin-top: 1.5rem; }
.admin-otp-form input {
    letter-spacing: 0.5em;
    font-size: 1.25rem;
    text-align: center;
}

.admin-link-back {
    display: block;
    margin-top: 2rem;
    font-size: 0.85rem;
    color: #8e8e8e;
    text-decoration: underline;
}

.admin-link-back:hover { color: #5794f2; }

/* ── Dashboard (utilise _AdminLayout) ─────────────────────────────────── */

/* ── Admin global Grafana-like dark theme ─────────────────────────────── */
body.admin {
    background: #0b0c0e;
    color: #ccccdc;
    margin: 0;
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.5rem;
    background: #111217;
    border-bottom: 1px solid #2c3035;
}

.admin-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #ccccdc;
    font-weight: 700;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    color: #8e8e8e;
}

.admin-logout-btn {
    background: transparent;
    border: 1px solid #2c3035;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    color: #ccccdc;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.admin-logout-btn:hover {
    background: #22262b;
    border-color: #5794f2;
}

.admin-main {
    max-width: 1300px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

.admin-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid #2c3035;
    margin-bottom: 1rem;
}

.admin-tab {
    padding: 0.7rem 1.1rem;
    text-decoration: none;
    color: #8e8e8e;
    border-bottom: 2px solid transparent;
    font-size: 0.85rem;
    transition: color 0.15s;
}

.admin-tab:hover { color: #ccccdc; }

.admin-tab.active {
    color: #5794f2;
    border-bottom-color: #5794f2;
    font-weight: 600;
}

.admin-tab-content {
    background: #111217;
    border: 1px solid #2c3035;
    padding: 1.5rem;
    border-radius: 4px;
    box-shadow: none;
}

.admin-tab-content h2 {
    font-size: 1rem;
    color: #ccccdc;
    margin: 0 0 1rem 0;
    font-weight: 600;
}

.admin-data-table {
    width: 100%;
    max-width: 600px;
    border-collapse: collapse;
}

.admin-data-table th {
    text-align: left;
    padding: 0.55rem 1rem 0.55rem 0;
    color: #8e8e8e;
    font-weight: 500;
    width: 200px;
    vertical-align: top;
    font-size: 0.85rem;
}

.admin-data-table td {
    padding: 0.55rem 0;
    color: #ccccdc;
    border-bottom: 1px solid #2c3035;
    font-size: 0.85rem;
}

/* ── Push form ────────────────────────────────────────────────────────── */

.admin-push-form fieldset {
    margin: 0 0 1rem 0;
    padding: 0.75rem 1rem;
    border: 1px solid #2c3035;
    border-radius: 4px;
    background: #181b1f;
}

.admin-push-form legend {
    padding: 0 0.5rem;
    color: #8e8e8e;
    font-size: 0.85rem;
}

.admin-push-form fieldset label {
    display: inline-block;
    margin-right: 1rem;
    font-size: 0.85rem;
    color: #ccccdc;
}

.admin-push-form > label {
    display: block;
    margin: 1rem 0;
    font-size: 0.85rem;
    color: #ccccdc;
}

.admin-push-form input[type="text"],
.admin-push-form input[type="email"],
.admin-push-form textarea,
.admin-push-form select {
    display: block;
    width: 100%;
    max-width: 480px;
    padding: 0.5rem 0.75rem;
    margin-top: 0.25rem;
    background: #181b1f;
    border: 1px solid #2c3035;
    border-radius: 4px;
    color: #ccccdc;
    font-family: inherit;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.admin-push-form input::placeholder,
.admin-push-form textarea::placeholder { color: #6e6e6e; }

.admin-push-form input:focus,
.admin-push-form textarea:focus,
.admin-push-form select:focus {
    outline: none;
    border-color: #5794f2;
}

.admin-push-form textarea { resize: vertical; }

.admin-push-form button {
    padding: 0.65rem 1.4rem;
    background: #5794f2;
    color: #0b0c0e;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    transition: background 0.15s;
}

.admin-push-form button:hover { background: #75a8f5; }

.admin-push-conditional {
    padding: 0.75rem;
    margin: 0 0 1rem 0;
    background: #1c1f24;
    border: 1px solid #2c3035;
    border-radius: 4px;
}

.admin-push-result {
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    border-radius: 4px;
    border: 1px solid;
}

.admin-push-result.success {
    background: rgba(115, 191, 105, 0.1);
    border-color: rgba(115, 191, 105, 0.3);
    color: #73bf69;
}
.admin-push-result.error {
    background: rgba(224, 47, 68, 0.1);
    border-color: rgba(224, 47, 68, 0.3);
    color: #e02f44;
}

/* ── Layout 2 colonnes : form gauche + aide droite ───────────────────── */

.admin-push-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 2rem;
}

@media (max-width: 900px) {
    .admin-push-layout {
        grid-template-columns: 1fr;
    }
}

.admin-push-form-col h2 {
    margin-top: 0;
}

.admin-push-help {
    background: #181b1f;
    border: 1px solid #2c3035;
    border-radius: 4px;
    padding: 1rem 1.25rem;
    font-size: 0.85rem;
    color: #ccccdc;
    align-self: start;
}

.admin-push-help h3 {
    font-size: 0.95rem;
    color: #ccccdc;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #2c3035;
}

.admin-push-help h4 {
    font-size: 0.85rem;
    color: #ccccdc;
    margin: 1.25rem 0 0.5rem 0;
}

.admin-push-help h4:first-of-type {
    margin-top: 0;
}

.admin-push-help dl {
    margin: 0;
}

.admin-push-help dt {
    font-weight: 600;
    color: #ccccdc;
    margin-top: 0.5rem;
}

.admin-push-help dd {
    margin: 0.125rem 0 0 0;
    color: #8e8e8e;
}

.admin-push-help code {
    background: rgba(87, 148, 242, 0.1);
    color: #5794f2;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.8rem;
    font-family: ui-monospace, "SF Mono", Consolas, monospace;
}

.admin-push-help p {
    margin: 0.5rem 0;
    color: #8e8e8e;
}

.admin-help-note {
    font-style: italic;
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
    background: rgba(87, 148, 242, 0.08);
    border-left: 3px solid #5794f2;
    border-radius: 3px;
    color: #ccccdc;
}

/* ── Admin Stats — Grafana-like dark theme ─────────────────────────────
   Scope strict : tout est imbriqué dans .admin-stats pour ne pas
   contaminer le reste du dashboard admin (Compte, Push…).
   Palette Grafana :
   - bg page  #111217 / cards #181b1f / row-alt #1f2329
   - border   #2c3035
   - text     #ccccdc (primary) / #8e8e8e (secondary)
   - accents  blue #5794f2 / green #73bf69 / amber #f2cc0c / red #e02f44
*/
.admin-stats {
    color: #ccccdc;
    font-family: inherit;
}

.admin-stats h3 {
    color: #ccccdc;
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    letter-spacing: 0.02em;
}

.admin-stats h4 {
    color: #8e8e8e;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.5rem 0;
}

/* KPI cards */
.admin-stats-kpi {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.admin-kpi-card {
    background: #181b1f;
    border: 1px solid #2c3035;
    border-radius: 4px;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
}

.admin-kpi-card-primary {
    background: linear-gradient(135deg, #1f3a5f 0%, #1a2d4a 100%);
    border-color: #5794f2;
}

.admin-kpi-card-primary .kpi-label { color: #a3c2f0; }
.admin-kpi-card-primary .kpi-value { color: #ffffff; }

.kpi-label {
    font-size: 0.7rem;
    color: #8e8e8e;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #ccccdc;
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}

/* Charts */
.admin-stats-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.admin-chart-block {
    background: #181b1f;
    border: 1px solid #2c3035;
    border-radius: 4px;
    padding: 0.85rem 1rem;
}

.admin-chart-block canvas {
    height: 200px !important;
    width: 100% !important;
}

/* Section header + refresh button */
.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.icon-btn {
    background: #181b1f;
    border: 1px solid #2c3035;
    color: #ccccdc;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, transform 0.3s;
}

.icon-btn:hover {
    background: #22262b;
    color: #5794f2;
}

.icon-btn:active {
    transform: rotate(180deg);
}

/* Filtres */
.admin-stats-filters {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.admin-stats-filters input,
.admin-stats-filters select {
    padding: 0.35rem 0.55rem;
    background: #181b1f;
    border: 1px solid #2c3035;
    border-radius: 3px;
    font-size: 0.8rem;
    color: #ccccdc;
}

.admin-stats-filters input::placeholder { color: #6e6e6e; }

.admin-stats-filters input:focus,
.admin-stats-filters select:focus {
    outline: none;
    border-color: #5794f2;
}

.admin-stats-filters button {
    padding: 0.35rem 0.9rem;
    background: #5794f2;
    color: #111217;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}

.admin-stats-filters button:hover {
    background: #75a8f5;
}

/* Layout 2 colonnes : logs (large) + top endpoints (sidebar plus large) */
.admin-logs-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    gap: 1rem;
    align-items: start;
}

.admin-logs-main { min-width: 0; }

.admin-logs-side {
    background: #181b1f;
    border: 1px solid #2c3035;
    border-radius: 4px;
    padding: 0.85rem 1rem;
    position: sticky;
    top: 1rem;
}

.admin-logs-side h3 { margin-bottom: 0.6rem; }

/* Tables — override TOTAL des styles legacy .admin-data-table
   (max-width 600px / th width 200px) qui ratatinent tout dans le scope
   stats. table-layout: auto + width: 1% sur les cellules courtes laisse
   la colonne Path prendre tout l'espace restant. */
.admin-stats .admin-data-table,
.admin-stats-table {
    width: 100% !important;
    max-width: none !important;
    table-layout: auto !important;
    font-size: 0.78rem;
    border-collapse: collapse;
    background: #181b1f;
    border: 1px solid #2c3035;
    border-radius: 4px;
    overflow: hidden;
    color: #ccccdc;
}

.admin-stats .admin-data-table th,
.admin-stats-table thead th {
    width: auto !important;
    background: #1f2329;
    color: #8e8e8e;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: left;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid #2c3035;
    vertical-align: middle;
}

.admin-stats .admin-data-table td,
.admin-stats-table tbody td {
    padding: 0.5rem 0.7rem;
    border-bottom: 1px solid #2c3035;
    vertical-align: middle;
}

.admin-stats-table tbody tr:nth-child(odd) td:not([colspan]) {
    background: #181b1f;
}

.admin-stats-table tbody tr:nth-child(even) td:not([colspan]) {
    background: #1c1f24;
}

.admin-stats-table code {
    background: rgba(87, 148, 242, 0.08);
    color: #5794f2;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: ui-monospace, monospace;
    font-size: 0.72rem;
}

.admin-stats-table .err  { color: #e02f44; font-weight: 600; }
.admin-stats-table .warn { color: #f2cc0c; font-weight: 600; }

/* Request logs : colonnes "courtes" (timestamp, method, status, latence,
   user, ip) en width: 1% + nowrap → shrink-to-fit. La colonne Path n'a
   PAS de width forcée → prend tout l'espace restant. */
.request-logs-table th:nth-child(1),
.request-logs-table td:nth-child(1),   /* timestamp */
.request-logs-table th:nth-child(2),
.request-logs-table td:nth-child(2),   /* method */
.request-logs-table th:nth-child(4),
.request-logs-table td:nth-child(4),   /* status */
.request-logs-table th:nth-child(5),
.request-logs-table td:nth-child(5),   /* latence */
.request-logs-table th:nth-child(6),
.request-logs-table td:nth-child(6),   /* user */
.request-logs-table th:nth-child(7),
.request-logs-table td:nth-child(7) {  /* ip */
    width: 1% !important;
    white-space: nowrap;
}

.request-logs-table th:nth-child(4),
.request-logs-table td:nth-child(4) { text-align: center; }

.request-logs-table th:nth-child(5),
.request-logs-table td:nth-child(5) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.request-logs-table th.col-path,
.request-logs-table td.path-cell {
    width: auto !important;
    white-space: normal;
    word-break: break-all;
    min-width: 240px;
}

.request-logs-table .path-cell .qs {
    color: #f2cc0c;          /* amber Grafana — querystring qui ressort */
    font-family: ui-monospace, monospace;
    font-size: 0.72rem;
    margin-left: 0.3rem;
}

/* Top endpoints sidebar — colonnes métriques compactes (#/p50/p95/p99)
   en width 1% + nowrap, Path prend tout le reste */
.top-endpoints-table th:nth-child(n+2),
.top-endpoints-table td:nth-child(n+2) {
    width: 1% !important;
    white-space: nowrap;
    text-align: right;
    font-variant-numeric: tabular-nums;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}

.top-endpoints-table th:nth-child(1),
.top-endpoints-table td:nth-child(1) {
    width: auto !important;
    word-break: break-all;
}

.top-endpoints-table td code {
    font-size: 0.7rem;
    line-height: 1.3;
    display: inline-block;
}

/* Pagination */
.admin-stats-pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
    margin-top: 0.75rem;
    color: #8e8e8e;
    font-size: 0.78rem;
}

.admin-stats-pagination button {
    padding: 0.3rem 0.7rem;
    border: 1px solid #2c3035;
    background: #181b1f;
    color: #ccccdc;
    border-radius: 3px;
    cursor: pointer;
}

.admin-stats-pagination button:hover {
    background: #22262b;
    border-color: #5794f2;
}

/* Expand/collapse rows */
.admin-stats-table tr.log-row { cursor: pointer; }
.admin-stats-table tr.log-row:hover td { background: #22262b !important; }
.admin-stats-table tr.log-row .caret {
    display: inline-block;
    width: 1em;
    color: #8e8e8e;
    font-size: 0.85em;
}

.admin-stats-table tr.log-detail > td {
    background: #0d0e11 !important;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #2c3035;
}

.log-detail-headers { margin-bottom: 0.85rem; }

.log-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}

.log-detail-headers h5,
.log-detail-grid h5 {
    margin: 0 0 0.35rem 0;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8e8e8e;
    font-weight: 600;
}

.log-detail-headers .muted,
.log-detail-grid .muted {
    color: #5a5a5a;
    font-weight: normal;
    text-transform: none;
    letter-spacing: 0;
}

/* JSON pretty-print bloc */
.json-block {
    background: #0a0b0e;
    color: #ccccdc;
    border: 1px solid #2c3035;
    padding: 0.75rem;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    overflow-x: auto;
    margin: 0;
    max-height: 420px;
    white-space: pre-wrap;
    word-break: break-word;
}

.json-block .json-key  { color: #5794f2; }   /* blue Grafana */
.json-block .json-str  { color: #73bf69; }   /* green Grafana */
.json-block .json-num  { color: #f2cc0c; }   /* amber Grafana */
.json-block .json-bool { color: #b877d9; }   /* purple */
.json-block .json-null { color: #e02f44; }   /* red Grafana */

@media (max-width: 1100px) {
    .admin-logs-layout {
        grid-template-columns: 1fr;
    }
    .admin-logs-side { position: static; }
}

@media (max-width: 700px) {
    .admin-stats-charts { grid-template-columns: 1fr; }
    .log-detail-grid    { grid-template-columns: 1fr; }
}
