/* ==========================================================================
   VMP Admin — shared design system (loaded by views/layouts/header.php).
   Dark only. Pages compose these classes with Tailwind utilities for layout;
   colors, surfaces, controls and states come from here so every page matches.
   The Watch section keeps its own cinema look (views/watch/_theme.php).
   ========================================================================== */

:root {
    --bg: #111827;            /* page (Tailwind gray-900) */
    --panel: #1f2937;         /* cards (gray-800) */
    --panel-2: #243042;       /* raised rows, hovered rows */
    --line: #2f3b4d;          /* hairlines */
    --track: #2a3444;         /* bar tracks, input fill */
    --text-1: #f3f4f6;
    --text-2: #b6bfcc;
    --text-3: #8b95a5;
    --accent: #3987e5;        /* primary actions + data (categorical slot 1, dark) */
    --accent-hover: #4b95ec;
    --good: #0ca30c;
    --warning: #fab219;
    --serious: #ec835a;
    --critical: #d03b3b;
    --radius: .75rem;
    color-scheme: dark;
}

body { background: var(--bg); }

/* ---------- text ---------- */
.t1 { color: var(--text-1); }
.t2 { color: var(--text-2); }
.t3 { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1.5rem; }
.page-title { font-size: 1.875rem; line-height: 2.25rem; font-weight: 700; color: var(--text-1); }
.page-sub { margin-top: .25rem; font-size: .875rem; color: var(--text-3); }
.crumb { display: inline-flex; align-items: center; gap: .35rem; font-size: .875rem; color: var(--text-3); margin-bottom: .5rem; }
.crumb:hover { color: var(--text-1); }

/* ---------- surfaces ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.panel-title { font-weight: 600; color: var(--text-1); }
.panel-body { padding: 1.25rem; }
.divide-line > * + * { border-top: 1px solid var(--line); }
.row-link { transition: background-color .15s; }
.row-link:hover { background: rgba(255, 255, 255, .04); }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    min-height: 2.5rem; padding: .5rem 1rem; border-radius: .5rem;
    font-size: .875rem; font-weight: 600; line-height: 1.2; white-space: nowrap;
    border: 1px solid transparent; transition: background-color .15s, border-color .15s, color .15s;
    cursor: pointer; user-select: none;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--panel-2); color: var(--text-1); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { background: #2c394d; border-color: #3b4a60; }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--panel-2); color: var(--text-1); }
.btn-danger { background: transparent; color: #f08a8a; border-color: rgba(208, 59, 59, .45); }
.btn-danger:hover:not(:disabled) { background: rgba(208, 59, 59, .15); color: #ffb0b0; }
.btn-sm { min-height: 2rem; padding: .3rem .7rem; font-size: .8125rem; }
.btn-icon { min-height: 2.25rem; width: 2.25rem; padding: 0; }
.btn-icon.btn-sm { min-height: 2rem; width: 2rem; }

/* ---------- form controls ---------- */
.field-label { display: block; margin-bottom: .375rem; font-size: .8125rem; font-weight: 500; color: var(--text-2); }
.field-hint { margin-top: .375rem; font-size: .75rem; color: var(--text-3); }
.field {
    width: 100%; min-height: 2.5rem; padding: .5rem .75rem; border-radius: .5rem;
    background: var(--bg); border: 1px solid var(--line); color: var(--text-1); font-size: .875rem;
}
.field::placeholder { color: #6b7686; }
.field:hover { border-color: #3b4a60; }
.field:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(57, 135, 229, .25); }
textarea.field { min-height: 6rem; line-height: 1.5; }
select.field { padding-right: 2rem; }
.field-search { position: relative; }
.field-search > i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.field-search > .field { padding-left: 2.25rem; }

/* ---------- filter bar ---------- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.filter-bar > .grow { flex: 1 1 16rem; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap;
    min-height: 2rem; padding: .25rem .75rem; border-radius: 999px; font-size: .8125rem;
    border: 1px solid var(--line); color: var(--text-2); background: var(--panel);
}
.chip:hover { color: var(--text-1); border-color: #3b4a60; }
.chip[aria-pressed="true"], .chip.is-active { background: var(--text-1); color: var(--bg); border-color: var(--text-1); }
.chip .count { font-size: .75rem; opacity: .7; font-variant-numeric: tabular-nums; }
.chip-row { display: flex; gap: .5rem; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip-row::-webkit-scrollbar { display: none; }

/* ---------- status badges (icon + label, never color alone) ---------- */
.badge {
    display: inline-flex; align-items: center; gap: .3rem; white-space: nowrap;
    padding: .125rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 500;
    border: 1px solid var(--line); color: var(--text-2); background: rgba(255, 255, 255, .03);
}
.badge i { font-size: .875rem; }
.badge-good { color: #7fdc7f; border-color: rgba(12, 163, 12, .45); background: rgba(12, 163, 12, .1); }
.badge-warning { color: #ffd27a; border-color: rgba(250, 178, 25, .45); background: rgba(250, 178, 25, .1); }
.badge-serious { color: #f6b092; border-color: rgba(236, 131, 90, .45); background: rgba(236, 131, 90, .1); }
.badge-critical { color: #f39c9c; border-color: rgba(208, 59, 59, .5); background: rgba(208, 59, 59, .12); }
.badge-info { color: #9cc5f4; border-color: rgba(57, 135, 229, .45); background: rgba(57, 135, 229, .1); }

/* ---------- data tables: real table on md+, stacked cards on phones ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th {
    text-align: left; font-size: .75rem; font-weight: 600; color: var(--text-3);
    padding: .65rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--line); color: var(--text-2); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: rgba(255, 255, 255, .025); }
.data-table .cell-main { color: var(--text-1); font-weight: 500; }
@media (min-width: 768px) { .data-table td:not(.cell-main):not(.cell-wrap) { white-space: nowrap; } }
.data-table .cell-actions { text-align: right; white-space: nowrap; }
@media (min-width: 768px) { .data-table .cell-actions > div { flex-wrap: nowrap; } }
@media (max-width: 767px) {
    .data-table thead { display: none; }
    .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr { padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
    .data-table tbody tr:last-child { border-bottom: 0; }
    .data-table td { border: 0; padding: .2rem 0; display: flex; gap: .75rem; justify-content: space-between; align-items: center; text-align: right; }
    .data-table td[data-label]::before { content: attr(data-label); color: var(--text-3); font-size: .75rem; text-align: left; flex-shrink: 0; }
    .data-table td.cell-main { display: block; text-align: left; font-size: .9375rem; padding-bottom: .35rem; }
    .data-table td.cell-main::before { display: none; }
    .data-table td.cell-actions { justify-content: flex-start; padding-top: .5rem; flex-wrap: wrap; }
    .data-table td.cell-actions::before { display: none; }
    .data-table tbody tr:hover td { background: transparent; }
}

/* ---------- pagination ---------- */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: .875rem 1.25rem; border-top: 1px solid var(--line); font-size: .875rem; color: var(--text-3); }
.pager-links { display: flex; align-items: center; gap: .25rem; }
.pager-links a, .pager-links span {
    min-width: 2.25rem; height: 2.25rem; padding: 0 .5rem; display: inline-flex; align-items: center; justify-content: center;
    border-radius: .5rem; color: var(--text-2);
}
.pager-links a:hover { background: var(--panel-2); color: var(--text-1); }
.pager-links .current { background: var(--accent); color: #fff; font-weight: 600; }
.pager-links .gap { min-width: 1.25rem; }

/* ---------- empty state ---------- */
.empty { padding: 3rem 1.5rem; text-align: center; }
.empty i { font-size: 2.25rem; color: var(--text-3); }
.empty-title { margin-top: .75rem; font-weight: 600; color: var(--text-1); }
.empty-text { margin: .25rem auto 0; max-width: 28rem; font-size: .875rem; color: var(--text-3); }

/* ---------- key/value facts ---------- */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 1rem 1.5rem; }
.fact dt { font-size: .75rem; color: var(--text-3); }
.fact dd { margin-top: .15rem; color: var(--text-1); font-weight: 500; word-break: break-word; }

/* ---------- posters / thumbs ---------- */
.thumb { aspect-ratio: 2 / 3; border-radius: .375rem; overflow: hidden; background: var(--track); flex-shrink: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- bars (same spec as the dashboard) ---------- */
.bar-track { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--accent); }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(3, 7, 18, .72); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; }
.modal-backdrop.hidden { display: none; }
.modal { width: 100%; max-width: 48rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7); }

/* ---------- sidebar ---------- */
.nav-link {
    display: flex; align-items: center; gap: .75rem; padding: .625rem .875rem; border-radius: .5rem;
    color: var(--text-2); font-size: .9375rem; font-weight: 500; transition: background-color .15s, color .15s;
}
.nav-link i { font-size: 1.25rem; width: 1.25rem; text-align: center; flex-shrink: 0; }
.nav-link:hover { background: var(--panel-2); color: var(--text-1); }
.nav-link[aria-current="page"] { background: rgba(57, 135, 229, .14); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-link[aria-current="page"] i { color: var(--accent); }

/* ---------- focus ---------- */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; }
}

/* ---------- icon font gaps ----------
   The pinned tabler stylesheet has no *-filled glyphs (they ship as a separate font that
   would override every .ti). Map the filled names we use onto the outline glyph + tint. */
.ti-star-filled::before { content: "\eb2e"; }
.ti-star-filled { color: var(--warning); }

/* ---------- row action menu ("More" ⋯) ----------
   Fixed-positioned by the header script so table overflow can't clip it;
   on phones it becomes a bottom sheet with big touch targets. */
.menu-list {
    display: none; position: fixed; z-index: 66; min-width: 14rem; padding: .35rem;
    background: var(--panel); border: 1px solid var(--line); border-radius: .625rem;
    box-shadow: 0 18px 50px -12px rgba(0, 0, 0, .7);
}
.menu-list.is-open { display: block; }
.menu-item {
    display: flex; width: 100%; align-items: center; gap: .65rem; padding: .55rem .7rem;
    border-radius: .4rem; font-size: .875rem; color: var(--text-2); text-align: left; white-space: nowrap;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--panel-2); color: var(--text-1); outline: none; }
.menu-item i { font-size: 1.1rem; width: 1.25rem; text-align: center; color: var(--text-3); }
.menu-item:hover i { color: inherit; }
.menu-item.is-danger, .menu-item.is-danger i { color: #f08a8a; }
.menu-item.is-danger:hover { background: rgba(208, 59, 59, .14); }
.menu-item:disabled { opacity: .6; }
.menu-sep { height: 1px; margin: .3rem .2rem; background: var(--line); }
.menu-title { display: none; padding: .5rem .7rem .35rem; font-size: .8125rem; color: var(--text-3); }
@media (max-width: 767px) {
    .menu-list { left: .5rem !important; right: .5rem; bottom: .5rem; top: auto !important; min-width: 0; padding: .5rem; border-radius: 1rem; }
    .menu-item { padding: .9rem .9rem; font-size: 1rem; }
    .menu-title { display: block; }
    html.menu-open::after { content: ''; position: fixed; inset: 0; z-index: 65; background: rgba(3, 7, 18, .55); }
}

/* phones: hide secondary cells (their facts are repeated in the card's meta line) */
@media (max-width: 767px) {
    .data-table td.m-hide { display: none; }
    .data-table td.cell-actions .btn { min-height: 2.5rem; }
}
.row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .75rem; margin-top: .4rem; font-size: .8125rem; color: var(--text-3); }
