/* NovaConfig · Panel de administración — hoja de estilos principal */

:root {
    --bg: #f1f5f9;
    --bg-grad-1: #eef2ff;
    --bg-grad-2: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --txt: #0f172a;
    --muted: #475569;       /* contraste AA sobre blanco (>7:1) */
    --faint: #64748b;       /* contraste AA sobre blanco (>4.5:1) */
    --brand: #6366f1;
    --brand-d: #4f46e5;
    --brand-soft: #eef2ff;
    --ok: #047857;
    --ok-soft: #ecfdf5;
    --ok-border: #6ee7b7;
    --danger: #be123c;
    --danger-soft: #fff1f2;
    --danger-border: #fda4af;
    --focus: #4f46e5;
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
    --shadow-md: 0 4px 6px -1px rgba(15,23,42,.07), 0 2px 4px -2px rgba(15,23,42,.05);
    --shadow-lg: 0 20px 25px -5px rgba(15,23,42,.08), 0 8px 10px -6px rgba(15,23,42,.04);
    --r-sm: 8px; --r-md: 12px; --r-lg: 18px;
    --header-bg: rgba(255,255,255,.78);
}

/* ---------- Dark mode (automático según el sistema) ---------- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1120;
        --bg-grad-1: #1e1b4b;
        --bg-grad-2: #0f172a;
        --surface: #111827;
        --surface-2: #1e293b;
        --border: #334155;
        --txt: #e5e7eb;
        --muted: #cbd5e1;
        --faint: #94a3b8;
        --brand: #818cf8;
        --brand-d: #a5b4fc;
        --brand-soft: #1e1b4b;
        --ok: #34d399;
        --ok-soft: #052e23;
        --ok-border: #065f46;
        --danger: #fb7185;
        --danger-soft: #3f1320;
        --danger-border: #9f1239;
        --focus: #a5b4fc;
        --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
        --shadow-md: 0 4px 6px -1px rgba(0,0,0,.45);
        --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.5);
        --header-bg: rgba(17,24,39,.8);
    }
    .btn-primary { color: #0b1120; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
    color: var(--txt);
    background:
        radial-gradient(1200px 600px at 100% -10%, var(--bg-grad-1), transparent 60%),
        radial-gradient(1000px 500px at -10% 110%, var(--bg-grad-2), transparent 55%),
        var(--bg);
    background-attachment: fixed;
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Accesibilidad ---------- */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: 12px; top: -60px; z-index: 100;
    background: var(--brand); color: #fff; padding: 10px 16px; border-radius: var(--r-sm);
    font-weight: 600; text-decoration: none; transition: top .15s;
}
.skip-link:focus { top: 12px; }

/* Anillo de foco visible y consistente solo para teclado */
:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}
.btn:focus-visible, .input:focus-visible, .nav a:focus-visible { outline-offset: 2px; }
/* Quitar outline por defecto cuando no es navegación por teclado */
:focus:not(:focus-visible) { outline: none; }

/* ---------- Header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--header-bg);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.site-header__inner {
    max-width: 1140px; margin: 0 auto; padding: 12px 20px;
    display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--txt); font-weight: 700; font-size: 1.02rem; }
.brand__logo {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), #818cf8);
    display: grid; place-items: center; color: #fff;
    box-shadow: var(--shadow-sm); flex: none;
}
.brand__logo svg { width: 18px; height: 18px; }
.nav { display: flex; gap: 4px; }
.nav a {
    color: var(--muted); text-decoration: none; font-weight: 500; font-size: .92rem;
    padding: 7px 12px; border-radius: var(--r-sm); transition: color .15s, background .15s;
}
.nav a:hover { color: var(--txt); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--brand-d); background: var(--brand-soft); }
.header-spacer { margin-left: auto; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip__email { color: var(--muted); font-size: .85rem; }
.menu-toggle {
    display: none; align-items: center; justify-content: center;
    width: 40px; height: 40px; border: 1px solid var(--border); border-radius: var(--r-sm);
    background: var(--surface); color: var(--txt); cursor: pointer; margin-left: auto;
}
.menu-toggle svg { width: 20px; height: 20px; }

/* ---------- Layout ---------- */
main { max-width: 1140px; margin: 0 auto; padding: 32px 20px 64px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card--pad { padding: 24px; }
.card--form { max-width: none; }
.card__title { margin: 0 0 4px; font-size: 1.05rem; }
.card__subtitle { margin: 0 0 16px; color: var(--muted); font-size: .88rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px; border-radius: var(--r-sm); border: 1px solid transparent;
    font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none;
    transition: background .15s, box-shadow .15s, transform .05s, color .15s; white-space: nowrap; line-height: 1.2;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-d); box-shadow: var(--shadow-md); }
.btn-ghost { background: var(--surface); color: var(--txt); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 11px; font-size: .82rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 20px; }
.field { display: flex; flex-direction: column; }
.field--full { grid-column: 1 / -1; }
.field--align-end { justify-content: flex-end; }
label { font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.req { color: var(--danger); }
.input {
    width: 100%; padding: 10px 13px; font-size: .92rem; color: var(--txt);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
    transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.input::placeholder { color: var(--faint); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.field-error { color: var(--danger); font-size: .8rem; margin-top: 6px; font-weight: 500; }

/* Campo de contraseña con botón mostrar/ocultar */
.input-affix { position: relative; display: flex; }
.input-affix .input { padding-right: 44px; }
.toggle-visibility {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 34px; height: 34px; display: grid; place-items: center;
    background: transparent; border: 0; border-radius: var(--r-sm); cursor: pointer; color: var(--faint);
}
.toggle-visibility:hover { color: var(--txt); background: var(--surface-2); }
.toggle-visibility svg { width: 18px; height: 18px; }
.toggle-visibility .icon-hide { display: none; }
.toggle-visibility[aria-pressed="true"] .icon-show { display: none; }
.toggle-visibility[aria-pressed="true"] .icon-hide { display: block; }

.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: .9rem; color: var(--txt); margin: 0; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--brand); }
.form-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.hint { font-weight: 400; color: var(--faint); font-size: .78rem; margin: 6px 0 0; }

/* Secciones de formulario: agrupan campos relacionados con título y descripción. */
.form-section + .form-section { margin-top: 26px; padding-top: 24px; border-top: 1px solid var(--border); }
.form-section__head { margin-bottom: 16px; }
.form-section__head h2 { font-size: .98rem; font-weight: 700; color: var(--txt); margin: 0; letter-spacing: -.01em; }
.form-section__head p { font-size: .82rem; color: var(--muted); margin: 3px 0 0; }
.input--mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82rem; line-height: 1.5; resize: vertical; }

/* Aviso informativo dentro de un formulario. */
.callout { display: flex; gap: 10px; margin-top: 12px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); font-size: .82rem; color: var(--muted); }
.callout svg { width: 18px; height: 18px; flex: none; color: var(--brand); margin-top: 1px; }
.callout code { white-space: nowrap; }

/* Guía paso a paso (numerada). */
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 16px; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 30px 1fr; gap: 13px; align-items: start; font-size: .88rem; color: var(--txt); line-height: 1.5; }
.steps li::before {
    content: counter(step); display: grid; place-items: center; width: 26px; height: 26px;
    background: var(--brand); color: #fff; border-radius: 50%; font-size: .8rem; font-weight: 700;
}
.steps strong { font-weight: 600; }
.steps .muted { color: var(--muted); }
.steps code { word-break: break-all; }
.steps .copy-block { margin-top: 8px; }

/* Acordeón (details/summary nativo). */
.accordion { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.accordion > summary {
    cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 18px 24px; font-weight: 700; font-size: 1rem; color: var(--txt);
}
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary::after { content: '▾'; color: var(--faint); transition: transform .2s; }
.accordion[open] > summary::after { transform: rotate(180deg); }
.accordion > summary:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: var(--r-lg); }
.accordion__body { padding: 4px 24px 24px; }
.accordion__body p { margin: 0 0 16px; color: var(--muted); font-size: .88rem; }

/* Variante de aviso para la nota de Windows. */
.callout--warn { background: var(--danger-soft); border-color: var(--danger-border); color: var(--txt); }
.callout--warn svg { color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 16px; font-size: .9rem; }
/* Filas sin saltos de línea (la tabla scrollea en horizontal si no cabe). */
.stack-table th, .stack-table td { white-space: nowrap; }
thead th {
    color: var(--faint); text-transform: uppercase; font-size: .7rem; letter-spacing: .06em; font-weight: 700;
    border-bottom: 1px solid var(--border); background: var(--surface-2);
}
thead th:first-child { border-top-left-radius: var(--r-lg); }
thead th:last-child { border-top-right-radius: var(--r-lg); }
th.align-right { text-align: right; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td .primary-cell { font-weight: 600; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- Badges / misc ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.badge-mono { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; }
.muted { color: var(--muted); }
.truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 2px 7px; border-radius: 6px; font-size: .85em; word-break: break-all; }

/* Bloque de token + botón copiar */
.copy-block { display: flex; gap: 8px; align-items: stretch; margin-top: 10px; }
.copy-block code { flex: 1; display: flex; align-items: center; padding: 10px 12px; }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 10px; padding: 13px 16px; border-radius: var(--r-md); margin-bottom: 20px; font-size: .9rem; border: 1px solid; }
.alert--stack { flex-direction: column; align-items: stretch; }
.alert strong { font-weight: 700; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-border); }
.alert-err { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.alert-err ul { margin: 0; padding-left: 18px; }
.alert__icon { flex: none; }
.alert__icon svg { width: 18px; height: 18px; display: block; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 410px; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 22px; text-align: center; }
.auth-brand .brand__logo { width: 46px; height: 46px; border-radius: 13px; }
.auth-brand .brand__logo svg { width: 24px; height: 24px; }
.auth-brand__name { font-weight: 700; font-size: 1.15rem; }
.auth-brand__sub { color: var(--muted); font-size: .88rem; }

/* ---------- Grids ---------- */
.stack-cards { display: grid; grid-template-columns: 1fr; gap: 20px; }

/* ---------- Utilities ---------- */
.u-mt-2 { margin-top: 8px; }
.u-mt-3 { margin-top: 12px; }
.u-mt-4 { margin-top: 16px; }
.u-mt-5 { margin-top: 22px; }
.u-mb-4 { margin-bottom: 16px; }
.u-text-sm { font-size: .85rem; }
.icon { width: 16px; height: 16px; vertical-align: -2px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
    .form-grid { grid-template-columns: 1fr; }
    .menu-toggle { display: inline-grid; place-items: center; }
    .header-spacer { display: none; }
    .nav, .user-chip { display: none; }
    .site-header__inner[data-open="true"] .nav,
    .site-header__inner[data-open="true"] .user-chip { display: flex; }
    .site-header__inner { flex-wrap: wrap; }
    .nav { order: 3; width: 100%; flex-direction: column; gap: 2px; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 8px; }
    .user-chip { order: 4; width: 100%; }
    .user-chip form, .user-chip .btn { width: 100%; }
    .user-chip__email { display: none; }

    /* tabla responsive -> tarjetas apiladas */
    .stack-table thead { display: none; }
    .stack-table, .stack-table tbody, .stack-table tr, .stack-table td { display: block; width: 100%; }
    .stack-table tr { border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 12px; padding: 6px 4px; background: var(--surface); }
    .stack-table td { display: flex; justify-content: space-between; gap: 14px; padding: 9px 14px; border: 0; text-align: right; white-space: normal; }
    .stack-table td::before { content: attr(data-label); font-weight: 600; color: var(--faint); text-transform: uppercase; font-size: .68rem; letter-spacing: .05em; text-align: left; }
    .stack-table td .truncate { max-width: 55vw; }
    .row-actions { justify-content: flex-end; }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}
