/* =============================================================================
   OpenVPN Manager — estilos
   Paleta sobria de panel administrativo. Tipografía:
     - Display: serif para títulos (carácter sin estridencia).
     - UI/body: sans humanista.
     - Datos técnicos: monoespaciada.
   ========================================================================== */

@font-face {
    font-family: "Inter Local"; font-style: normal; font-weight: 400 700;
    src: local("system-ui"), local("Segoe UI"), local("Helvetica Neue");
    font-display: swap;
}

:root {
    /* Colores base */
    --bg:           #f5f3ee;     /* fondo cálido, no blanco puro */
    --bg-elev:     #ffffff;
    --ink:         #1a1a1a;
    --ink-soft:    #4a4a4a;
    --ink-muted:   #8a8a8a;
    --line:        #d8d4c9;
    --line-soft:   #e8e4d8;

    /* Acentos */
    --accent:       #1f4d3a;    /* verde profundo, no chillón */
    --accent-soft:  #e6efe9;
    --danger:       #8b2820;
    --danger-soft:  #f4e4e2;
    --warn:         #8b6a14;
    --warn-soft:    #f7eed1;
    --info:         #244a6b;
    --info-soft:    #e2eaf3;

    /* Tipografía */
    --f-sans:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", sans-serif;
    --f-serif:   "Iowan Old Style", "Palatino Linotype", Palatino,
                 "Book Antiqua", Georgia, serif;
    --f-mono:    "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

    /* Geometría */
    --r-sm: 4px;
    --r-md: 6px;
    --r-lg: 10px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--f-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--f-mono); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.muted { color: var(--ink-muted); }
.ta-right { text-align: right; }

/* ====== Topbar ====== */
.topbar {
    background: var(--bg-elev);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar__inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 32px;
}
.brand {
    display: inline-flex; align-items: center; gap: 10px;
    font-weight: 600; color: var(--ink); font-size: 15px;
}
.brand:hover { text-decoration: none; }
.brand__dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.brand__name { letter-spacing: -0.01em; }

.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
    color: var(--ink-soft);
    padding: 6px 12px;
    border-radius: var(--r-md);
    font-size: 13px;
    font-weight: 500;
}
.nav a:hover { background: var(--line-soft); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

.user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.user__name { color: var(--ink-soft); font-weight: 500; }
.user__logout-form { margin: 0; }
.user__logout {
    color: var(--ink-muted);
    font-size: 12px;
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: transparent;
    font-family: inherit;
    cursor: pointer;
}
.user__logout:hover { background: var(--line-soft); text-decoration: none; }

/* ====== Main ====== */
.main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 24px 60px;
}

.footer {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 24px 32px;
    color: var(--ink-muted);
    font-size: 12px;
    border-top: 1px solid var(--line-soft);
}

/* ====== Page head ====== */
.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line-soft);
}
.page-title {
    font-family: var(--f-serif);
    font-weight: 500;
    font-size: 28px;
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}
.page-sub { margin: 0; color: var(--ink-soft); font-size: 13px; }

/* ====== Cards (dashboard) ====== */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}
.card {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: 18px 20px;
}
.card__label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-muted);
    font-weight: 600;
    margin-bottom: 8px;
}
.card__value {
    font-family: var(--f-serif);
    font-size: 32px;
    font-weight: 500;
    color: var(--ink);
    line-height: 1.1;
}
.card__value--accent { color: var(--accent); }
.card__value--muted { color: var(--ink-muted); }
.card__hint {
    font-size: 12px;
    color: var(--ink-muted);
    margin-top: 6px;
}
.card--status .card__value { font-size: 18px; font-family: var(--f-sans); }

.status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--r-sm);
    font-family: var(--f-mono);
    font-size: 13px;
    font-weight: 500;
}
.status--ok  { background: var(--accent-soft); color: var(--accent); }
.status--bad { background: var(--danger-soft); color: var(--danger); }

/* ====== Panels ====== */
.panel {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    margin-bottom: 24px;
    overflow: hidden;
}
.panel__head {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line-soft);
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}
.panel__title {
    margin: 0;
    font-family: var(--f-serif);
    font-weight: 500;
    font-size: 18px;
}
.panel__hint {
    font-size: 12px;
    color: var(--ink-muted);
}
.panel__toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
}
.checkbox-inline {
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--ink);
}
.checkbox-inline input { margin: 0; cursor: pointer; }

/* Filtro "Solo válidos": oculta filas (data-status presente y distinto a valid). */
tbody.filter-only-valid tr[data-status]:not([data-status="valid"]) {
    display: none;
}

.empty {
    padding: 32px 20px;
    text-align: center;
    color: var(--ink-muted);
}

/* ====== Tablas ====== */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th, .table td {
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}
.table th {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
    background: #faf8f3;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fcfaf5; }

.row-form td { background: #faf8f3; padding: 16px 20px; }

/* ====== Pills (estados) ====== */
.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.pill--valid    { background: var(--accent-soft); color: var(--accent); }
.pill--revoked  { background: var(--danger-soft); color: var(--danger); }
.pill--expired  { background: var(--warn-soft);   color: var(--warn); }
.pill--warn     { background: var(--warn-soft);   color: var(--warn); }
/* Variantes genéricas (las usa la vista de auditoría: bad/info/ok según evento). */
.pill--ok       { background: var(--accent-soft); color: var(--accent); }
.pill--bad      { background: var(--danger-soft); color: var(--danger); }
.pill--info     { background: var(--info-soft);   color: var(--info); }

/* ====== Botones ====== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.12s, border-color 0.12s;
    text-decoration: none;
}
.btn--primary {
    background: var(--accent);
    color: #fff;
}
.btn--primary:hover { background: #173825; text-decoration: none; }
.btn--ghost {
    background: transparent;
    border-color: var(--line);
    color: var(--ink-soft);
}
.btn--ghost:hover { background: var(--line-soft); text-decoration: none; }
.btn--block { width: 100%; }
.btn--sm { padding: 5px 12px; font-size: 12px; }

/* ====== Forms ====== */
.field { display: block; margin-bottom: 14px; }
.field__label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-soft);
    margin-bottom: 4px;
}
.field__input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--bg-elev);
    color: var(--ink);
    font-family: inherit;
    font-size: 13px;
    transition: border-color 0.12s, box-shadow 0.12s;
}
.field__input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.field__input.mono { font-family: var(--f-mono); }
.field__input--sm { padding: 5px 10px; font-size: 12px; }
.field__help { display: block; font-size: 11px; color: var(--ink-muted); margin-top: 4px; }

.form-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-grid .form-actions { grid-column: 1 / -1; margin-top: 4px; }

.form-inline {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}
.field--inline {
    display: inline-flex;
    flex-direction: column;
    margin-bottom: 0;
}

.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

/* ====== Flash ====== */
.flash {
    padding: 12px 16px;
    border-radius: var(--r-sm);
    margin-bottom: 20px;
    font-size: 13px;
    border: 1px solid;
}
.flash--success { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.flash--error   { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

/* ====== Row actions (menú por fila) ====== */
.row-actions { position: relative; display: inline-block; }
.row-actions summary {
    list-style: none;
    cursor: pointer;
}
.row-actions summary::-webkit-details-marker { display: none; }
.row-actions__menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 180px;
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-md);
    z-index: 5;
    padding: 4px;
}
.row-actions__menu form { margin: 0; }
.action-link {
    display: block;
    width: 100%;
    text-align: left;
    padding: 7px 10px;
    background: transparent;
    border: none;
    border-radius: var(--r-sm);
    color: var(--ink);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}
.action-link:hover { background: var(--line-soft); }
.action-link--danger { color: var(--danger); }
.action-link--danger:hover { background: var(--danger-soft); }

/* ====== Auth (login) ====== */
.auth-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 25% 20%, #e8efe9 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, #f0ebe0 0%, transparent 50%),
        var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.auth-shell { width: 100%; max-width: 380px; }
.auth-card {
    background: var(--bg-elev);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
}
.auth-card__head { margin-bottom: 24px; text-align: center; }
.auth-card__brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--f-serif);
    font-size: 22px;
    font-weight: 500;
    margin-bottom: 6px;
}
.auth-card__sub { margin: 0; color: var(--ink-soft); font-size: 13px; }
.auth-form { margin-bottom: 16px; }
.auth-card__hint {
    text-align: center;
    color: var(--ink-muted);
    font-size: 12px;
    margin: 0;
}

/* ====== Audit table ====== */
.table--audit .ctx {
    max-width: 480px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ====== Responsive ====== */
@media (max-width: 720px) {
    .topbar__inner { flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
    .nav { order: 3; width: 100%; flex-wrap: wrap; }
    .main { padding: 20px 16px 40px; }
    .page-head { flex-direction: column; align-items: flex-start; }
    .form-grid { grid-template-columns: 1fr; padding: 16px; }
    .page-title { font-size: 24px; }
    .card__value { font-size: 26px; }
}
