/* ============================================================
   Admin — Refined Editorial Tech
   KPI cards · Settings sections · Component showcase
   ============================================================ */

/* ===== KPI Grid ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1px;
    background: var(--border-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 48px;
}
.kpi {
    background: var(--bg-surface);
    padding: 24px 22px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: background-color 240ms;
}
.kpi:hover { background: var(--bg-elevated); }
.kpi__label {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-muted);
    font-weight: 500;
}
.kpi__value {
    font-family: var(--font-display);
    font-size: 44px;
    line-height: 1;
    font-weight: 400;
    letter-spacing: -0.025em;
    font-variation-settings: "opsz" 96;
    color: var(--text-primary);
    margin-top: 4px;
}
.kpi__link {
    font-size: 12.5px;
    color: var(--text-secondary);
    text-decoration: none;
    margin-top: auto;
    padding-top: 16px;
    transition: color 160ms;
}
.kpi__link:hover { color: var(--brand-primary); }

/* ===== Quick action grid (admin home) ===== */
.quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 64px;
}
.quick-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 12px;
    padding: 24px 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.quick-card h3 {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 500;
    margin: 0;
    letter-spacing: -0.015em;
    color: var(--text-primary);
}
.quick-card p {
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 0 0 4px;
}

/* ============================================================
   Settings Sections
   ============================================================ */
.settings-section {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 56px;
    padding: 32px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.settings-section:last-of-type {
    border-bottom: 0;
}
.settings-section--isolated {
    margin-top: 36px;
    padding-top: 36px;
    border-top: 1px solid var(--border-default);
    border-bottom: 0;
}
.settings-section__head {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.settings-section__title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0;
    color: var(--text-primary);
    font-variation-settings: "opsz" 36;
}
.settings-section__desc {
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 0;
}
.settings-section__desc code {
    font-size: 12px;
    background: var(--bg-elevated);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--text-primary);
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}
.settings-row__label { display: flex; flex-direction: column; gap: 4px; }
.settings-row__label strong { font-weight: 500; color: var(--text-primary); font-size: 14.5px; }
.settings-row__label span { font-size: 13px; color: var(--text-secondary); }

.form-stack { display: flex; flex-direction: column; gap: 18px; }

.check-row {
    display: flex; align-items: center; gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
}
.check-row input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px; height: 18px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: var(--bg-base);
    cursor: pointer;
    position: relative;
    transition: border-color 160ms, background-color 160ms;
}
.check-row input[type="checkbox"]:hover { border-color: var(--text-secondary); }
.check-row input[type="checkbox"]:checked {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
}
.check-row input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px; top: 1px;
    width: 5px; height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.check-row--small { font-size: 12.5px; color: var(--text-secondary); }

.action-row { display: flex; gap: 8px; flex-wrap: wrap; }

.settings-save {
    display: flex;
    justify-content: flex-end;
    padding: 24px 0;
}

/* ===== Code card (MCP config etc.) ===== */
.code-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 10px;
    overflow: hidden;
}
.code-card__head {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-default);
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--bg-surface);
}
.code-card__body {
    margin: 0;
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text-primary);
    overflow-x: auto;
}

/* ============================================================
   Component Showcase
   ============================================================ */
.showcase-toc {
    position: sticky;
    top: 76px;
    z-index: 20;
    margin: 0 0 40px;
    padding: 8px 12px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    background: color-mix(in oklab, var(--bg-base) 78%, transparent);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}
.showcase-toc::-webkit-scrollbar { display: none; }
.showcase-toc a,
.showcase-toc a:visited,
.showcase-toc a:link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: -0.005em;
    white-space: nowrap;
    transition: color 160ms, background-color 160ms;
}
.showcase-toc a:hover { color: var(--text-primary); background: var(--bg-hover); }
.showcase-toc a:active { color: var(--brand-primary); }

.show-section {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 56px;
    padding: 56px 0;
    border-bottom: 1px solid var(--border-subtle);
}
.show-section:last-child { border-bottom: 0; }

.show-section__head {
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: sticky;
    top: 152px;
    align-self: start;
    height: fit-content;
}
.show-section__num {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--brand-primary);
    letter-spacing: 0.16em;
    font-weight: 500;
}
.show-section__title {
    font-family: var(--font-display);
    font-size: 36px;
    line-height: 1.05;
    font-weight: 400;
    letter-spacing: -0.025em;
    margin: 0;
    font-variation-settings: "opsz" 144, "SOFT" 30;
    color: var(--text-primary);
}
.show-section__desc {
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--text-secondary);
    margin: 0;
    max-width: 38ch;
}

.show-section__body { display: flex; flex-direction: column; gap: 28px; }

.show-row {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 24px;
    align-items: center;
    padding: 20px 22px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}
.show-row__label {
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-muted);
    font-weight: 500;
}
.show-row__items { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.show-grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}

.show-stack { display: flex; flex-direction: column; gap: 12px; }

/* ===== Type stack ===== */
.type-stack {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 28px 26px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
}
.type-row {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 24px;
    align-items: baseline;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle);
}
.type-row:last-child { border-bottom: 0; padding-bottom: 0; }
.type-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}
.type-display {
    font-family: var(--font-display);
    font-size: clamp(40px, 5vw, 72px);
    line-height: 0.98;
    letter-spacing: -0.04em;
    font-weight: 300;
    margin: 0;
    font-variation-settings: "opsz" 144, "SOFT" 30, "WONK" 1;
    color: var(--text-primary);
}
.type-display em {
    font-style: italic;
    font-variation-settings: "opsz" 144, "SOFT" 100, "WONK" 1;
    color: var(--brand-primary);
}
.type-row em { font-style: italic; color: var(--brand-primary); }

/* ===== Color swatches ===== */
.swatch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}
.swatch {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.swatch__chip {
    aspect-ratio: 16/9;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
}
.swatch__meta { display: flex; flex-direction: column; gap: 2px; }
.swatch__name {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.005em;
}
.swatch__var {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .settings-section,
    .show-section {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .show-section__head { position: static; }
    .show-row { grid-template-columns: 1fr; gap: 12px; }
    .type-row { grid-template-columns: 1fr; gap: 8px; }
}

/* ============================================================
   Aethon overrides for refined buttons/inputs/cards
   (override Aethon defaults to fit our editorial system)
   ============================================================ */
.aethon-btn {
    font-family: var(--font-body);
    font-weight: 500;
    letter-spacing: -0.005em;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 13.5px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 160ms, color 160ms, border-color 160ms, transform 120ms, box-shadow 220ms;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1;
    min-height: 36px;
}
.aethon-btn:hover { transform: translateY(-1px); }
.aethon-btn:active { transform: translateY(0); }
.aethon-btn-sm { padding: 6px 12px; font-size: 12.5px; min-height: 30px; }
.aethon-btn-md { padding: 9px 16px; font-size: 13.5px; min-height: 36px; }
.aethon-btn-lg { padding: 12px 22px; font-size: 14.5px; min-height: 44px; }

.aethon-btn-primary {
    background: var(--text-primary);
    color: var(--bg-base);
    border-color: var(--text-primary);
}
.aethon-btn-primary:hover {
    background: color-mix(in oklab, var(--text-primary) 88%, var(--brand-primary));
    border-color: color-mix(in oklab, var(--text-primary) 88%, var(--brand-primary));
}

.aethon-btn-secondary {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-default);
}
.aethon-btn-secondary:hover {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
}

.aethon-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.aethon-btn-ghost:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.aethon-btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.aethon-btn-danger:hover {
    background: color-mix(in oklab, var(--danger) 88%, black);
}

.aethon-btn-disabled,
.aethon-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.aethon-btn-loading { cursor: progress; }
.aethon-btn-spinner {
    width: 12px; height: 12px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Inputs */
.aethon-input {
    width: 100%;
    padding: 10px 14px;
    font: inherit;
    font-size: 14px;
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--bg-base);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    transition: border-color 160ms, box-shadow 160ms, background-color 160ms;
}
.aethon-input:focus {
    outline: 0;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-glow-sm);
}
.aethon-input::placeholder { color: var(--text-muted); }
.aethon-input-wrapper { display: flex; flex-direction: column; gap: 6px; }
.aethon-input-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.aethon-input-hint { font-size: 12px; color: var(--text-muted); }
.aethon-input-error { font-size: 12px; color: var(--danger); }
.aethon-input-has-error .aethon-input { border-color: var(--danger); }
.aethon-input-disabled .aethon-input,
.aethon-input[disabled] {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* Card */
.aethon-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
}
.aethon-card[data-padded="true"],
.aethon-card.padded {
    padding: 22px 22px;
}

/* Badge */
.aethon-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.4;
    border: 1px solid transparent;
}
.aethon-badge-brand  { background: var(--brand-primary-glow); color: var(--brand-primary); border-color: var(--brand-primary-border); }
.aethon-badge-green  { background: var(--success-bg);         color: var(--success);       border-color: var(--success-border); }
.aethon-badge-red    { background: var(--danger-bg);          color: var(--danger);        border-color: var(--danger-border); }
.aethon-badge-blue   { background: var(--info-bg);            color: var(--info);          border-color: var(--info-border); }
.aethon-badge-muted  { background: var(--bg-elevated);        color: var(--text-secondary); border-color: var(--border-default); }

/* Table */
.aethon-table-wrap {
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-surface);
}
.aethon-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.aethon-table thead th {
    text-align: left;
    padding: 12px 18px;
    font-family: var(--font-mono);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    font-weight: 500;
    background: var(--bg-base);
    border-bottom: 1px solid var(--border-subtle);
}
.aethon-table tbody td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}
.aethon-table tbody tr:last-child td { border-bottom: 0; }
.aethon-table tbody tr.aethon-table-row { transition: background-color 160ms; }
.aethon-table tbody tr.aethon-table-row:hover { background: var(--bg-elevated); cursor: pointer; }
.aethon-table-empty {
    text-align: center;
    padding: 32px 16px !important;
    color: var(--text-muted) !important;
}

/* Modal */
.aethon-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(12, 11, 10, 0.66);
    backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: backdrop-in 200ms ease;
}
html[data-theme="light"] .aethon-modal-backdrop { background: rgba(26, 24, 21, 0.42); }

@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }

.aethon-modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-in 280ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.aethon-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border-subtle);
}
.aethon-modal-title {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 500;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.015em;
}
.aethon-modal-close {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color 160ms, background-color 160ms;
}
.aethon-modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.aethon-modal-body { padding: 20px 22px; }
.aethon-modal-footer { padding: 14px 22px; border-top: 1px solid var(--border-subtle); }

/* Spacer (flex spacer) */
.aethon-spacer { flex: 1 1 auto; }

/* Divider */
.aethon-divider {
    height: 1px;
    background: var(--border-subtle);
    border: 0;
    margin: 0;
}
