/* Panel administrador: menú lateral, resumen gráfico y filtros (2026-11-08).
   Solo afecta a la vista #admin. Se carga después de admin-layout.css.
   Gráficos: una serie por gráfico en azul (#3987e5, paso oscuro de la paleta validada);
   estados con icono + texto (nunca solo color). */

#admin {
    --dash-series: #3987e5;
    --dash-series-hover: #6da7ec;
    --dash-series-track: rgba(57, 135, 229, 0.18);
    --dash-surface: rgba(15, 23, 42, 0.62);
    --dash-surface-2: rgba(2, 6, 23, 0.45);
    --dash-line: rgba(148, 163, 184, 0.16);
    --dash-axis: rgba(148, 163, 184, 0.38);
    --dash-accent: rgba(255, 214, 107, 0.85);
    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-serious: #ec835a;
    --status-critical: #d03b3b;
}

#admin .visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Distribución: menú lateral + contenido ---- */
#admin .admin-shell {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
    margin-top: 16px;
}

#admin .admin-shell-content {
    display: grid;
    gap: 16px;
    min-width: 0;
}

#admin .admin-shell-content > section.admin-card,
#admin .admin-shell-content > .admin-grid {
    margin-top: 0;
    min-width: 0;
}

#admin .admin-section-nav.admin-sidebar {
    position: sticky;
    top: 12px;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 4px;
    margin: 0;
    padding: 10px;
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(8, 13, 28, 0.96));
}

#admin .admin-sidebar button {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: #cbd5e1;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

#admin .admin-sidebar button:hover {
    background: rgba(148, 163, 184, 0.1);
    color: #f1f5f9;
}

#admin .admin-sidebar button:focus-visible {
    outline: 2px solid var(--dash-accent);
    outline-offset: 2px;
}

#admin .admin-sidebar button.is-active {
    border-color: rgba(255, 214, 107, 0.55);
    background: linear-gradient(90deg, rgba(120, 88, 24, 0.85), rgba(70, 50, 14, 0.55));
    color: #fff4d1;
}

#admin .admin-sidebar button.is-active::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: #ffd66b;
}

#admin .admin-nav-icon {
    flex: none;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#admin .admin-nav-label {
    flex: 1;
    min-width: 0;
}

#admin .admin-nav-badge {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--status-warning);
    color: #1f1400;
    font-size: 0.75rem;
    font-weight: 800;
}

#admin .admin-nav-badge[hidden] {
    display: none;
}

/* ---- Resumen ---- */
#admin .admin-dashboard-card {
    display: grid;
    gap: 14px;
}

#admin .admin-dash-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

#admin .admin-dash-head h3 {
    margin: 0;
    font-size: 1.35rem;
}

#admin .admin-dash-head p {
    margin: 4px 0 0;
    max-width: 70ch;
    color: var(--muted, #aeb8c8);
    font-size: 0.92rem;
}

#admin .admin-dash-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

#admin .admin-dash-range {
    display: inline-flex;
    padding: 3px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: var(--dash-surface-2);
}

#admin .admin-dash-range button {
    min-height: 34px;
    padding: 0 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #cbd5e1;
    font-weight: 700;
    cursor: pointer;
}

#admin .admin-dash-range button.is-active {
    background: rgba(255, 214, 107, 0.18);
    color: #fff4d1;
    box-shadow: inset 0 0 0 1px rgba(255, 214, 107, 0.55);
}

#admin .admin-dash-range button:focus-visible {
    outline: 2px solid var(--dash-accent);
    outline-offset: 1px;
}

#admin .admin-dash-updated {
    margin: -6px 0 0;
    color: var(--muted, #aeb8c8);
    font-size: 0.82rem;
}

#admin .admin-dash-body {
    display: grid;
    gap: 14px;
    transition: opacity 0.2s ease;
}

#admin .admin-dash-body.is-loading {
    opacity: 0.55;
}

#admin .admin-dash-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

#admin .admin-dash-kpi {
    display: grid;
    gap: 4px;
    align-content: start;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: linear-gradient(160deg, rgba(30, 41, 59, 0.75), rgba(15, 23, 42, 0.75));
    color: #f1f5f9;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

#admin .admin-dash-kpi:hover {
    border-color: rgba(255, 214, 107, 0.45);
}

#admin .admin-dash-kpi:focus-visible {
    outline: 2px solid var(--dash-accent);
    outline-offset: 2px;
}

#admin .admin-dash-kpi-label {
    color: var(--muted, #aeb8c8);
    font-size: 0.82rem;
    font-weight: 700;
}

#admin .admin-dash-kpi-value {
    font-size: 1.85rem;
    font-weight: 700;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

#admin .admin-dash-kpi-detail {
    color: var(--muted, #aeb8c8);
    font-size: 0.8rem;
    line-height: 1.35;
}

#admin .admin-dash-kpi-detail.is-up { color: #86efac; }
#admin .admin-dash-kpi-detail.is-down { color: #fdba74; }

#admin .admin-dash-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

#admin .admin-dash-wide {
    grid-column: span 2;
}

#admin .admin-dash-panel {
    display: grid;
    gap: 10px;
    align-content: start;
    min-width: 0;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: var(--dash-surface);
}

#admin .admin-dash-panel > header {
    display: grid;
    gap: 2px;
}

#admin .admin-dash-panel h4 {
    margin: 0;
    font-size: 1rem;
    color: #f1f5f9;
}

#admin .admin-dash-panel > header span {
    color: var(--muted, #aeb8c8);
    font-size: 0.8rem;
}

#admin .admin-dash-panel > .secondary.small {
    justify-self: start;
}

/* Gráfico de columnas */
#admin .admin-dash-chart {
    position: relative;
    min-width: 0;
}

#admin .admin-dash-chart svg {
    display: block;
    max-width: 100%;
    overflow: visible;
}

#admin .admin-dash-grid-line {
    stroke: var(--dash-line);
    stroke-width: 1;
}

#admin .admin-dash-axis {
    stroke: var(--dash-axis);
    stroke-width: 1;
}

#admin .admin-dash-tick {
    fill: var(--muted, #aeb8c8);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

#admin .admin-dash-bar {
    fill: var(--dash-series);
    transition: fill 0.12s ease;
}

#admin .admin-dash-hit {
    fill: transparent;
}

#admin .admin-dash-col {
    cursor: default;
    outline: none;
}

#admin .admin-dash-col.is-hover .admin-dash-bar,
#admin .admin-dash-col:focus-visible .admin-dash-bar {
    fill: var(--dash-series-hover);
}

#admin .admin-dash-col:focus-visible .admin-dash-hit {
    fill: rgba(148, 163, 184, 0.08);
}

#admin .admin-dash-tooltip {
    position: absolute;
    z-index: 5;
    display: grid;
    gap: 2px;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: rgba(2, 6, 23, 0.96);
    color: #f8fafc;
    font-size: 0.8rem;
    white-space: nowrap;
    pointer-events: none;
    transform: translate(-50%, -100%);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}

#admin .admin-dash-tooltip[hidden] {
    display: none;
}

#admin .admin-dash-tooltip span {
    color: var(--muted, #aeb8c8);
}

/* Barras horizontales */
#admin .admin-dash-hbars {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

#admin .admin-dash-hbars li {
    display: grid;
    grid-template-columns: minmax(90px, 38%) minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    font-size: 0.86rem;
}

#admin .admin-dash-hbar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #e2e8f0;
}

#admin .admin-dash-hbar-track {
    height: 10px;
    border-radius: 0 4px 4px 0;
    background: var(--dash-series-track);
    overflow: hidden;
}

#admin .admin-dash-hbar-fill {
    display: block;
    height: 100%;
    border-radius: 0 4px 4px 0;
    background: var(--dash-series);
}

#admin .admin-dash-hbar-value {
    min-width: 2.5ch;
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #f1f5f9;
}

/* Alertas */
#admin .admin-dash-alerts {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

#admin .admin-dash-alert {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 10px;
    background: var(--dash-surface-2);
    border: 1px solid rgba(148, 163, 184, 0.14);
    font-size: 0.86rem;
}

#admin .admin-dash-alert-icon {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 900;
    color: #0b1220;
    background: #94a3b8;
}

#admin .admin-dash-alert.is-good .admin-dash-alert-icon { background: var(--status-good); color: #f0fdf4; }
#admin .admin-dash-alert.is-warning .admin-dash-alert-icon { background: var(--status-warning); color: #1f1400; }
#admin .admin-dash-alert.is-serious .admin-dash-alert-icon { background: var(--status-serious); color: #1f0a02; }
#admin .admin-dash-alert.is-critical .admin-dash-alert-icon { background: var(--status-critical); color: #fff1f2; }
#admin .admin-dash-alert.is-warning,
#admin .admin-dash-alert.is-serious { border-color: rgba(250, 178, 25, 0.35); }
#admin .admin-dash-alert.is-critical { border-color: rgba(208, 59, 59, 0.5); }

/* Datos clave */
#admin .admin-dash-facts {
    display: grid;
    gap: 10px;
    margin: 0;
}

#admin .admin-dash-facts > div {
    display: grid;
    gap: 2px;
}

#admin .admin-dash-facts dt {
    color: var(--muted, #aeb8c8);
    font-size: 0.78rem;
    font-weight: 700;
}

#admin .admin-dash-facts dd {
    display: grid;
    gap: 4px;
    margin: 0;
    color: #f1f5f9;
}

#admin .admin-dash-facts dd small,
#admin .admin-dash-note {
    color: var(--muted, #aeb8c8);
    font-size: 0.78rem;
}

#admin .admin-dash-stars {
    color: #ffd66b;
    letter-spacing: 1px;
}

#admin .admin-dash-meter {
    display: block;
    height: 8px;
    border-radius: 999px;
    background: var(--dash-series-track);
    overflow: hidden;
}

#admin .admin-dash-meter > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--dash-series);
}

#admin .admin-dash-env {
    justify-self: start;
    padding: 2px 10px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 0.82rem;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

#admin .admin-dash-env.prod { border-color: rgba(208, 59, 59, 0.6); color: #fecaca; }
#admin .admin-dash-env.qa { border-color: rgba(57, 135, 229, 0.6); color: #bfdbfe; }

#admin .admin-dash-table summary {
    cursor: pointer;
    color: var(--muted, #aeb8c8);
    font-size: 0.8rem;
}

#admin .admin-dash-table table {
    width: 100%;
    margin-top: 6px;
    border-collapse: collapse;
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

#admin .admin-dash-table th,
#admin .admin-dash-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--dash-line);
    text-align: left;
}

#admin .admin-dash-table td:last-child,
#admin .admin-dash-table th:last-child {
    text-align: right;
}

#admin .admin-dash-table tbody {
    display: block;
    max-height: 220px;
    overflow: auto;
}

#admin .admin-dash-table thead,
#admin .admin-dash-table tbody tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

/* ---- Barras de filtros (usuarios, calificaciones) ---- */
#admin .admin-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 12px;
    align-items: flex-end;
    margin: 10px 0 12px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: var(--dash-surface-2);
}

#admin .admin-filter-bar label {
    display: grid;
    gap: 4px;
    flex: 0 1 180px;
    min-width: 150px;
    color: var(--muted, #aeb8c8);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#admin .admin-filter-bar label.admin-filter-search,
#admin .admin-filter-bar label:has(input[type="search"]) {
    flex: 1 1 240px;
}

#admin .admin-filter-bar input,
#admin .admin-filter-bar select {
    width: 100%;
    min-height: 40px;
    box-sizing: border-box;
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--text, #e5e7eb);
}

#admin .admin-filter-bar input[type="search"] {
    padding-left: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aeb8c8' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M16 16l4 4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 16px 16px;
}

#admin .admin-filter-bar input:disabled {
    opacity: 0.55;
}

#admin .admin-filter-count {
    align-self: center;
    margin-left: auto;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
    color: #e2e8f0;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

#admin .admin-filter-count:empty {
    display: none;
}

/* ---- Responsive ---- */
@media (max-width: 1280px) {
    #admin .admin-dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    #admin .admin-shell {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    #admin .admin-section-nav.admin-sidebar {
        top: 0;
        z-index: 20;
        flex-direction: row;
        overflow-x: auto;
        scrollbar-width: thin;
        padding: 6px;
        border-radius: 14px;
    }

    #admin .admin-sidebar button {
        flex: none;
        width: auto;
        min-height: 40px;
        white-space: nowrap;
    }

    #admin .admin-sidebar button.is-active::before {
        display: none;
    }
}

@media (max-width: 720px) {
    #admin .admin-dash-grid { grid-template-columns: 1fr; }
    #admin .admin-dash-wide { grid-column: auto; }
    #admin .admin-dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #admin .admin-dash-kpi-value { font-size: 1.5rem; }
    #admin .admin-filter-bar label { flex: 1 1 100%; }
    #admin .admin-filter-count { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
    #admin .admin-dash-body,
    #admin .admin-dash-bar { transition: none; }
}

@media (forced-colors: active) {
    #admin .admin-dash-bar,
    #admin .admin-dash-hbar-fill,
    #admin .admin-dash-meter > span { fill: CanvasText; background: CanvasText; }
}

#admin .admin-dash-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: baseline;
}
