/* media-cdn admin tab — observability dashboard + runtime config tuner. */

/* ── Observability stats cards (Task 2.7.7) ───────────────────────── */

.mcdn-stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.mcdn-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px 18px;
}

.mcdn-card-title {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Performance grid */
.mcdn-perf-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.mcdn-perf-cell {
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
}

.mcdn-perf-cell-wide {
    grid-column: 1 / -1;
}

.mcdn-perf-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.mcdn-perf-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    line-height: 1.2;
}

.mcdn-perf-value.mcdn-ratio-good  { color: #43b581; }
.mcdn-perf-value.mcdn-ratio-warn  { color: #faa61a; }
.mcdn-perf-value.mcdn-ratio-bad   { color: #e06d5b; }

.mcdn-perf-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* L2 usage summary + bars */
.mcdn-usage-summary {
    display: flex;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.mcdn-usage-numbers {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    font-variant-numeric: tabular-nums;
}

.mcdn-usage-pct {
    color: var(--accent);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.mcdn-usage-detail {
    color: var(--text-muted);
    font-size: 12px;
}

.mcdn-usage-bar-track {
    height: 6px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
    margin: 6px 0 14px;
}

.mcdn-usage-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #5b8bd6);
    transition: width 0.4s ease-out;
}

/* Category rows */
.mcdn-categories {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 8px;
}

.mcdn-cat-row {
    display: grid;
    grid-template-columns: 120px 1fr 200px;
    align-items: center;
    gap: 12px;
}

.mcdn-cat-label {
    font-size: 13px;
    color: var(--text-primary, #fff);
}

.mcdn-cat-bar-wrap {
    height: 14px;
    background: var(--bg-primary);
    border-radius: 3px;
    overflow: hidden;
}

.mcdn-cat-bar {
    height: 100%;
    transition: width 0.4s ease-out;
}

.mcdn-cat-numbers {
    display: flex;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
    justify-content: flex-end;
    font-variant-numeric: tabular-nums;
}

.mcdn-cat-bytes { color: var(--text-primary, #fff); font-weight: 500; }
.mcdn-cat-pct { color: var(--text-muted); min-width: 50px; text-align: right; }

/* Collapsible prefix detail */
.mcdn-prefix-toggle {
    margin-top: 14px;
    color: var(--accent);
}

.mcdn-prefix-detail {
    margin-top: 8px;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.mcdn-prefix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.mcdn-prefix-table th, .mcdn-prefix-table td {
    padding: 4px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.mcdn-prefix-table th {
    color: var(--text-muted);
    text-align: left;
    font-weight: 500;
}

.mcdn-prefix-table td.num,
.mcdn-prefix-table th.num {
    text-align: right;
}

.mcdn-prefix-table tbody tr:last-child td {
    border-bottom: none;
}

/* L1 card */
.mcdn-l1-summary {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mcdn-l1-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.mcdn-l1-row strong {
    color: var(--text-primary, #fff);
    font-variant-numeric: tabular-nums;
}

.mcdn-l1-label {
    color: var(--text-muted);
}

.mcdn-l1-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    font-style: italic;
}

/* Stats meta footer */
.mcdn-stats-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.mcdn-link-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: underline;
}
.mcdn-link-btn:hover { color: #5b8bd6; }

/* Empty state */
.mcdn-empty {
    padding: 18px;
    text-align: center;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    border: 1px dashed var(--border);
}

.mcdn-empty strong {
    display: block;
    color: var(--text-primary, #fff);
    margin-bottom: 4px;
}

.mcdn-empty-hint {
    color: var(--text-muted);
    font-size: 12px;
}

.mcdn-section-title {
    margin: 24px 0 12px;
    font-size: 13px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Tablet / narrow viewport — 2-column form collapses to 1. */
@media (max-width: 900px) {
    .mcdn-form {
        grid-template-columns: 1fr;
    }
}

/* Mobile breakpoint per designer recommendation */
@media (max-width: 768px) {
    .mcdn-perf-grid {
        grid-template-columns: 1fr;
    }
    .mcdn-cat-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }
    .mcdn-cat-numbers {
        justify-content: flex-start;
    }
}

/* ── Original config form styles ──────────────────────────────────── */


.mcdn-page {
    max-width: 1080px;         /* fits 2-column form on regular monitors */
    margin: 0;                 /* left-aligned to admin sidebar, not centered */
    padding-bottom: 32px;
}

.mcdn-header h2 {
    margin: 0 0 8px;
    font-size: 22px;
    color: var(--text-primary, #fff);
}

.mcdn-subtitle {
    margin: 0 0 24px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.mcdn-subtitle code {
    background: var(--bg-secondary);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}

/* ── Status card ────────────────────────────────────────────────── */

.mcdn-status-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 4px solid var(--text-muted);
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 24px;
}

.mcdn-status-card[data-status="ok"] {
    border-left-color: #43b581;
}
.mcdn-status-card[data-status="degraded"] {
    border-left-color: #f0a500;
}
.mcdn-status-card[data-status="err"],
.mcdn-status-card[data-status="unknown"] {
    border-left-color: #c0392b;
}

.mcdn-status-label {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex: 0 0 120px;
}

.mcdn-status-body {
    display: flex;
    gap: 18px;
    align-items: center;
    flex-wrap: wrap;
}

.mcdn-status-detail {
    color: var(--text-muted);
    font-size: 13px;
}

.mcdn-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}
.mcdn-badge-ok    { background: rgba(67, 181, 129, 0.15); color: #43b581; }
.mcdn-badge-warn  { background: rgba(240, 165, 0, 0.15); color: #f0a500; }
.mcdn-badge-err   { background: rgba(192, 57, 43, 0.15); color: #e06d5b; }

/* ── Sections (grouped fields, 2-column grid on wide screens) ──── */

/* Wrap the <form> contents into a 2-column grid: L1↔L2 paired, Range↔RateLimits paired. */
.mcdn-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 0;
}

.mcdn-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);  /* visual anchor — top accent bar */
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.mcdn-section-head {
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--border);
    background: rgba(114, 137, 218, 0.06);  /* tinted with --accent for separation */
}

.mcdn-section-head h4 {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    letter-spacing: 0.01em;
}

.mcdn-section-note {
    margin: 0;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
}

.mcdn-section-body {
    padding: 14px 18px;
    flex: 1;
}

/* Actions row spans both columns at the bottom. */
.mcdn-form .mcdn-actions {
    grid-column: 1 / -1;
}

/* ── Field row ─────────────────────────────────────────────────── */

.mcdn-field {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.mcdn-field:last-child {
    border-bottom: none;
}

.mcdn-field-label {
    display: block;
    font-size: 13px;
    color: var(--text-primary, #fff);
    margin-bottom: 6px;
    font-weight: 500;
}

.mcdn-field-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.mcdn-input {
    flex: 0 0 170px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    color: var(--text-primary, #fff);
    font-size: 13px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    transition: border-color 0.15s, background 0.15s;
}
.mcdn-input:hover {
    border-color: rgba(255, 255, 255, 0.18);
}
.mcdn-input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(0, 0, 0, 0.35);
    box-shadow: 0 0 0 2px rgba(114, 137, 218, 0.18);
}
.mcdn-input::placeholder {
    color: var(--text-muted);
    opacity: 0.55;
}

.mcdn-current {
    color: var(--text-muted);
    font-size: 12px;
}
.mcdn-current strong {
    color: var(--text-primary, #fff);
    font-weight: 500;
}

.mcdn-hint {
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.4;
    padding-left: 0;
    margin-top: 2px;
}

/* ── Actions bar ───────────────────────────────────────────────── */

.mcdn-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    flex-wrap: wrap;
}

.mcdn-actions-hint {
    color: var(--text-muted);
    font-size: 11px;
    flex: 1;
    min-width: 240px;
}

.mcdn-actions-hint code {
    background: var(--bg-primary);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 11px;
}

/* ── Feedback panel (после submit) ─────────────────────────────── */

.mcdn-feedback {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.5;
    border: 1px solid;
}

.mcdn-feedback ul {
    margin: 6px 0 0 18px;
    padding: 0;
}

.mcdn-feedback code {
    background: rgba(0, 0, 0, 0.25);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}

.mcdn-feedback-ok {
    background: rgba(67, 181, 129, 0.1);
    border-color: rgba(67, 181, 129, 0.35);
    color: #43b581;
}
.mcdn-feedback-info {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--border);
    color: var(--text-muted);
}
.mcdn-feedback-error {
    background: rgba(192, 57, 43, 0.1);
    border-color: rgba(192, 57, 43, 0.35);
    color: #e06d5b;
}

/* ── Loading / error states ────────────────────────────────────── */

.mcdn-loading {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.mcdn-error-card {
    padding: 16px;
    background: rgba(192, 57, 43, 0.1);
    border: 1px solid rgba(192, 57, 43, 0.35);
    border-radius: 6px;
    color: #e06d5b;
    font-size: 13px;
}
