/* admin.css - v1.3 - Restore Stream Tiles + Bigger Donut
CHANGELOG (v1.2 -> v1.3): Re-added .metric-grid/.metric-tile - removing
them in v1.2 (thinking metrics.html was the only user) broke Stream
Metrics, which still uses them for its Live/Peak/Average tiles. Donut
chart bumped 170px -> 210px and given a left margin per request.
CHANGELOG (v1.1 -> v1.2):
  - Nav rebuilt from a fixed 200px sidebar into a header (icon + title)
    and an underline-style horizontal tab bar, matching PAP-KB's Knowledge
    Dashboard. Same dark background / red active-accent / green highlight
    colors as before - layout changed, palette didn't.
  - Actually fixed mobile this time: previous v1.1 mobile rules were
    correct in the CSS file but Cloudflare was serving browsers a cached
    pre-mobile admin.css for up to 4 hours (no version on the URL) - see
    base.html's changelog. The tab bar is now also just inherently more
    mobile-friendly than a sidebar was (scrolls horizontally instead of
    squeezing page content).
  - Added .stat-row/.stat (plain, unboxed KPI numbers - PAP-KB doesn't box
    its metric tiles) and .two-col/.donut-chart-wrap for the new Metrics
    page layout (chart + gaps table side by side, like PAP-KB's Search
    Outcomes / Zero-Result Searches split).
  - Dropped the old boxed .metric-grid/.metric-tile - metrics.html no
    longer uses them (kept .card for other pages that still want a boxed
    section, e.g. Content Viewer, Article Editor).
*/
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1e1e24; color: #fff;
}
a { color: #1e90ff; }

.admin-shell { min-height: 100vh; }

.admin-header {
    display: flex; align-items: center; gap: 14px;
    padding: 26px 30px 18px 30px;
}
.admin-header-icon { font-size: 1.8rem; line-height: 1; }
.admin-header-title { font-size: 1.7rem; font-weight: 800; }

.admin-tabs {
    display: flex; align-items: center; gap: 26px; flex-wrap: wrap;
    padding: 0 30px 14px 30px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.admin-tabs a {
    color: #aaa; text-decoration: none; font-size: 0.95rem; font-weight: 600;
    padding-bottom: 14px; border-bottom: 3px solid transparent; white-space: nowrap;
}
.admin-tabs a:hover { color: #fff; }
.admin-tabs a.active { color: #ff4757; border-bottom-color: #ff4757; }
.admin-tabs a.admin-logout { margin-left: auto; color: #ff6b81; }

.admin-content { padding: 30px; max-width: 1200px; }

.card { background: #2f3542; border-radius: 10px; padding: 25px; margin-bottom: 25px; }
.card h2, .card h3 { margin-bottom: 15px; }

.section-heading { margin: 30px 0 14px 0; color: #2ed573; font-size: 1.15rem; }
.muted { color: #aaa; font-size: 0.9rem; }

label { display: block; margin-bottom: 5px; color: #ccc; font-size: 0.9rem; }
input[type=text], input[type=password], input[type=email], input[type=number], textarea, select {
    width: 100%; padding: 10px; margin-bottom: 15px; border-radius: 5px; border: none;
    background: rgba(0,0,0,0.3); color: white; font-size: 0.95rem;
}
textarea { resize: vertical; }

.content-filter {
    width: 100%; padding: 12px 16px; margin-bottom: 15px; border-radius: 30px; border: none;
    background: rgba(0,0,0,0.3); color: white; font-size: 0.95rem;
}

button, .btn {
    background: #ff4757; border: none; padding: 12px 24px; border-radius: 30px;
    color: white; font-weight: bold; cursor: pointer; font-size: 0.95rem;
    display: inline-block; text-decoration: none;
}
button.secondary, .btn.secondary { background: rgba(255,255,255,0.1); }
button.danger, .btn.danger { background: #a4161a; }
button:hover, .btn:hover { opacity: 0.9; }

.flash { padding: 12px 20px; border-radius: 8px; margin-bottom: 20px; font-size: 0.9rem; }
.flash-notice { background: rgba(46,213,115,0.15); color: #2ed573; border: 1px solid rgba(46,213,115,0.3); }
.flash-error { background: rgba(255,71,87,0.15); color: #ff4757; border: 1px solid rgba(255,71,87,0.3); }

.auth-page {
    display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { text-align: center; margin-bottom: 25px; font-size: 1.4rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid rgba(255,255,255,0.05); font-size: 0.9rem; }
th { color: #888; }

.content-row { cursor: pointer; }
.content-row:hover { background: rgba(255,255,255,0.04); }
.content-title-cell { color: #fff; font-weight: 600; }

.metric-grid { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 25px; }
.metric-tile { background: #2f3542; border-radius: 10px; padding: 20px 30px; text-align: center; flex: 1 1 150px; }
.metric-tile .value { font-size: 2rem; font-weight: bold; color: #2ed573; }
.metric-tile .label { color: #aaa; font-size: 0.85rem; margin-top: 5px; }

/* --- Plain KPI stats (PAP-KB style: no boxes, just number over label) --- */
.stat-row { display: flex; gap: 50px; flex-wrap: wrap; margin-bottom: 25px; }
.stat-value { font-size: 1.8rem; font-weight: bold; color: #fff; }
.stat-label { color: #aaa; font-size: 0.85rem; margin-top: 4px; }

/* --- Two-column section (chart + table), stacks on mobile --- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-bottom: 30px; align-items: start; }
.two-col h4 { margin-bottom: 12px; font-size: 1rem; }

.line-chart { width: 100%; height: auto; }
.chart-empty { color: #888; font-size: 0.9rem; padding: 20px 0; }

.donut-chart-wrap { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; margin-left: 28px; }
.donut-chart { width: 210px; height: 210px; flex-shrink: 0; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; margin-bottom: 8px; }
.donut-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex-shrink: 0; }

.rte-toolbar { margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.rte-toolbar button {
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1);
    color: white; padding: 6px 12px; border-radius: 5px; cursor: pointer; font-size: 0.85rem;
    font-weight: normal;
}
.rte-color-swatch {
    width: 34px; height: 30px; padding: 2px; border-radius: 5px; cursor: pointer;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1);
}
.rte-select {
    width: auto; margin-bottom: 0;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1);
    color: white; padding: 6px 8px; border-radius: 5px; cursor: pointer; font-size: 0.85rem;
    height: 30px;
}
.rte-sep { width: 1px; align-self: stretch; background: rgba(255,255,255,0.15); margin: 0 2px; }
.rte-editor {
    min-height: 300px; padding: 12px; border-radius: 5px; background: rgba(0,0,0,0.3);
    color: white; line-height: 1.5; outline: none; border: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 15px; resize: vertical; overflow: auto;
}

.qr-box { text-align: center; margin: 15px 0; }
.qr-box img { background: white; padding: 10px; border-radius: 8px; }
.secret-code { font-family: monospace; background: rgba(0,0,0,0.3); padding: 8px; border-radius: 5px; display: inline-block; }

.checkbox-row { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.checkbox-row input { width: auto; margin: 0; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: bold; }
.badge-on { background: rgba(255,71,87,0.2); color: #ff4757; }
.badge-off { background: rgba(46,213,115,0.2); color: #2ed573; }

/* --- Content Viewer preview modal --- */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    z-index: 100; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.visible { display: flex; }
.modal-box {
    background: #2f3542; border-radius: 10px; max-width: 700px; width: 100%;
    max-height: 85vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 20px 25px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.modal-header h3 { margin-top: 6px; }
.modal-close {
    background: none; border: none; color: #aaa; font-size: 1.5rem; cursor: pointer;
    padding: 0 0 0 15px; line-height: 1;
}
.modal-close:hover { color: #fff; }
.modal-body { padding: 20px 25px; overflow-y: auto; line-height: 1.6; }
.modal-body h1, .modal-body h2, .modal-body h3, .modal-body h4,
.rte-editor h1, .rte-editor h2, .rte-editor h3, .rte-editor h4 {
    margin: 22px 0 10px 0;
}
.modal-body h1:first-child, .modal-body h2:first-child, .modal-body h3:first-child, .modal-body h4:first-child,
.rte-editor h1:first-child, .rte-editor h2:first-child, .rte-editor h3:first-child, .rte-editor h4:first-child {
    margin-top: 0;
}
.modal-body p, .rte-editor p { margin-bottom: 12px; }
.modal-body ul, .modal-body ol, .rte-editor ul, .rte-editor ol { margin: 0 0 12px 0; padding-left: 25px; }
.modal-body li, .rte-editor li { margin-bottom: 6px; }
.modal-body li:last-child, .rte-editor li:last-child { margin-bottom: 0; }
.modal-body img, .rte-editor img { max-width: 100%; height: auto; border-radius: 8px; margin: 10px 0; display: block; }
.modal-body blockquote, .rte-editor blockquote {
    border-left: 3px solid rgba(255,255,255,0.3); padding-left: 15px; margin: 0 0 12px 0;
    color: #ccc; font-style: italic;
}
.modal-body pre, .rte-editor pre {
    background: rgba(0,0,0,0.4); padding: 12px; border-radius: 5px; overflow-x: auto;
    margin: 0 0 12px 0; font-family: 'Courier New', monospace; white-space: pre-wrap;
}
.modal-body hr, .rte-editor hr { border: none; border-top: 1px solid rgba(255,255,255,0.15); margin: 20px 0; }
.modal-footer {
    display: flex; gap: 10px; padding: 15px 25px; border-top: 1px solid rgba(255,255,255,0.08);
}
.kb-category-badge {
    display: inline-block; background: rgba(46,213,115,0.15); color: #2ed573;
    padding: 3px 10px; border-radius: 12px; font-size: 0.75rem;
}

/* --- Mobile --- */
@media (max-width: 768px) {
    .admin-header { padding: 16px 16px 12px 16px; }
    .admin-header-title { font-size: 1.35rem; }

    .admin-tabs {
        padding: 0 16px 10px 16px; gap: 18px; overflow-x: auto; flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .admin-tabs a { padding-bottom: 10px; flex-shrink: 0; }
    .admin-tabs a.admin-logout { margin-left: 18px; }

    .admin-content { padding: 16px; max-width: 100%; }
    .card { padding: 16px; }

    .stat-row { gap: 28px; }
    .two-col { grid-template-columns: 1fr; gap: 25px; }

    table thead { display: none; }
    table, table tbody, table tr, table td { display: block; width: 100%; }
    table tr {
        border: 1px solid rgba(255,255,255,0.08); border-radius: 8px;
        margin-bottom: 12px; padding: 6px 10px;
    }
    table td {
        border-bottom: none; padding: 6px 0; display: flex; justify-content: space-between; gap: 10px;
    }
    table td[data-label]:not([data-label=""])::before {
        content: attr(data-label); color: #888; font-size: 0.8rem; flex-shrink: 0;
    }
    table td[data-label=""] { justify-content: flex-end; }

    .modal-box { max-height: 90vh; }
}
