/*
 * HKTV operator panel.
 *
 * Dark by default: this panel is read in front of screens, often in a dim room, and a white
 * page next to a wall of video is genuinely unpleasant to work in for an hour.
 *
 * Hand-written and served as one file. No build step, no CDN, nothing to install - see the
 * note at the top of resources/views/panel/layout.blade.php.
 */

:root {
    --bg: #0e1116;
    --bg-raised: #161b22;
    --bg-inset: #0b0e13;
    --line: #262d37;
    --line-strong: #38414e;
    --text: #e6edf3;
    --text-dim: #8b98a8;
    --text-faint: #5d6875;
    --accent: #3d8bfd;
    --accent-dim: #1f4e8c;
    --ok: #3fb950;
    --warn: #d29922;
    --bad: #f85149;
    --radius: 6px;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- shell ------------------------------------------------------------------- */

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--bg-raised);
    border-right: 1px solid var(--line);
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 9px; padding: 0 16px 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: grid; place-items: center;
    width: 28px; height: 28px; border-radius: var(--radius);
    background: var(--accent); color: #fff; font-weight: 700; font-size: 12px;
}
.brand-text { font-weight: 600; letter-spacing: .3px; }

.nav { list-style: none; margin: 0; padding: 0 8px; }
.nav a, .nav span {
    display: block; padding: 7px 10px; border-radius: var(--radius);
    color: var(--text-dim); font-size: 13.5px;
}
.nav a:hover { background: var(--bg-inset); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-dim); color: #fff; }
.nav-heading {
    margin: 20px 16px 6px; font-size: 10.5px; text-transform: uppercase;
    letter-spacing: .09em; color: var(--text-faint);
}
.nav-planned span { color: var(--text-faint); cursor: not-allowed; }

.sidebar-foot { margin-top: auto; padding: 14px 16px 0; border-top: 1px solid var(--line); }
.who { display: flex; flex-direction: column; margin-bottom: 6px; }
.who strong { font-size: 13px; }
.who span { font-size: 11.5px; color: var(--text-faint); }

.main { padding: 22px 28px 60px; min-width: 0; }

.page-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 21px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ---- flashes ----------------------------------------------------------------- */

.flash {
    padding: 9px 12px; border-radius: var(--radius); margin: 0 0 16px;
    border: 1px solid; font-size: 13px;
}
.flash-ok { background: rgba(63,185,80,.09); border-color: rgba(63,185,80,.4); color: #7ee787; }
.flash-bad { background: rgba(248,81,73,.09); border-color: rgba(248,81,73,.4); color: #ff8a80; }
ul.flash { padding-left: 30px; }

/* ---- cards ------------------------------------------------------------------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-bottom: 26px; }
.card {
    background: var(--bg-raised); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 13px 15px;
}
.card .n { font-size: 25px; font-weight: 600; line-height: 1.15; }
.card .k { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.card.bad .n { color: var(--bad); }
.card.warn .n { color: var(--warn); }
.card.ok .n { color: var(--ok); }
.card a { color: inherit; }

.panel {
    background: var(--bg-raised); border: 1px solid var(--line);
    border-radius: var(--radius); margin-bottom: 22px; overflow: hidden;
}
.panel > h2 {
    margin: 0; padding: 11px 15px; font-size: 13.5px; font-weight: 600;
    border-bottom: 1px solid var(--line); background: var(--bg-inset);
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.panel-body { padding: 15px; }

/* ---- tables ------------------------------------------------------------------ */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
    text-align: left; font-weight: 600; color: var(--text-dim); font-size: 11.5px;
    text-transform: uppercase; letter-spacing: .05em;
    padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.017); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.nowrap { white-space: nowrap; }

.empty { padding: 34px 16px; text-align: center; color: var(--text-dim); }
.empty p { margin: 0 0 4px; }
.empty .hint { font-size: 12.5px; color: var(--text-faint); }

/* ---- pills ------------------------------------------------------------------- */

.pill {
    display: inline-block; padding: 1px 8px; border-radius: 999px;
    font-size: 11.5px; font-weight: 500; border: 1px solid; white-space: nowrap;
}
.pill-ok { color: #7ee787; border-color: rgba(63,185,80,.45); background: rgba(63,185,80,.09); }
.pill-warn { color: #e3b341; border-color: rgba(210,153,34,.45); background: rgba(210,153,34,.09); }
.pill-bad { color: #ff8a80; border-color: rgba(248,81,73,.45); background: rgba(248,81,73,.09); }
.pill-dim { color: var(--text-dim); border-color: var(--line-strong); background: var(--bg-inset); }
.pill-info { color: #79c0ff; border-color: rgba(61,139,253,.45); background: rgba(61,139,253,.09); }

/* ---- forms ------------------------------------------------------------------- */

label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=search], input[type=datetime-local], select, textarea {
    width: 100%; padding: 7px 10px; background: var(--bg-inset); color: var(--text);
    border: 1px solid var(--line-strong); border-radius: var(--radius);
    font: inherit; font-size: 13px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-dim); border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 13px; }
.field .help { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 180px; }

button, .btn {
    display: inline-block; padding: 7px 13px; border-radius: var(--radius);
    border: 1px solid var(--line-strong); background: var(--bg-inset); color: var(--text);
    font: inherit; font-size: 13px; cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--text-faint); text-decoration: none; }
button:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #5a9dff; }
.btn-danger { color: #ff8a80; border-color: rgba(248,81,73,.45); }
.btn-danger:hover { background: rgba(248,81,73,.11); }
.btn-sm { padding: 3px 9px; font-size: 12px; }
button.link {
    background: none; border: 0; padding: 0; color: var(--accent);
    cursor: pointer; font-size: 12.5px;
}
button.link:hover { text-decoration: underline; }
form.inline { display: inline; }

/* ---- login ------------------------------------------------------------------- */

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-box { width: 100%; max-width: 340px; }
.login-box .brand { justify-content: center; padding-bottom: 22px; }
.login-card { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.login-card h1 { margin: 0 0 4px; font-size: 17px; }
.login-card .sub { margin: 0 0 18px; font-size: 12.5px; color: var(--text-dim); }

/* ---- attention list ---------------------------------------------------------- */

.attention { list-style: none; margin: 0; padding: 0; }
.attention li { padding: 11px 15px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.attention li:last-child { border-bottom: 0; }
.attention .sev { width: 3px; align-self: stretch; border-radius: 2px; flex: none; }
.attention .sev-critical { background: var(--bad); }
.attention .sev-warning { background: var(--warn); }
.attention .sev-info { background: var(--line-strong); }
.attention .what { flex: 1; min-width: 0; }
.attention .what strong { font-weight: 600; }
.attention .what .why { display: block; font-size: 12.5px; color: var(--text-dim); margin-top: 1px; }

/* ---- detail layout ----------------------------------------------------------- */

.split { display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .shell { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } }

dl.kv { margin: 0; display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 7px 14px; font-size: 13px; }
dl.kv dt { color: var(--text-dim); }
dl.kv dd { margin: 0; word-break: break-word; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a {
    padding: 8px 13px; color: var(--text-dim); font-size: 13px;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

.bar { height: 5px; background: var(--bg-inset); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.ok > i { background: var(--ok); }
.bar.warn > i { background: var(--warn); }
.bar.bad > i { background: var(--bad); }

.toolbar { display: flex; gap: 9px; align-items: center; margin-bottom: 15px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 250px; }
.toolbar select { max-width: 180px; }

.thumb {
    width: 68px; height: 38px; object-fit: cover; background: var(--bg-inset);
    border: 1px solid var(--line); border-radius: 3px; display: block;
}

/* ---- layout editor ------------------------------------------------------------ */

.ed-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
@media (max-width: 1200px) { .ed-grid { grid-template-columns: 1fr; } }

.ed-toolbar {
    display: flex; gap: 9px; align-items: center; flex-wrap: wrap;
    margin-bottom: 12px;
}
.ed-toolbar select { max-width: 170px; }

/* The stage keeps a 16:9 box whatever the window is, because the canvas is a screen and
 * authoring against a differently-shaped rectangle is authoring against a lie. */
.ed-stage {
    background: var(--bg-inset); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 14px;
}
.ed-canvas {
    position: relative; width: 100%; aspect-ratio: 16 / 9;
    background: #000; border: 1px solid var(--line-strong);
    overflow: hidden; touch-action: none; user-select: none;
}

.ed-safe {
    position: absolute; pointer-events: none;
    border: 1px dashed rgba(255, 255, 255, .28);
}

.ed-widget {
    position: absolute; box-sizing: border-box;
    border: 1px solid rgba(120, 170, 255, .55);
    background: rgba(61, 139, 253, .13);
    display: grid; place-items: center; overflow: hidden;
    cursor: move; font-size: 12px; color: #dce7f5;
}
.ed-widget.selected { border-color: var(--accent); background: rgba(61, 139, 253, .25); box-shadow: 0 0 0 1px var(--accent); }
.ed-widget.locked { cursor: not-allowed; border-style: dashed; }
.ed-widget.hidden { opacity: .3; }
.ed-widget .ed-label {
    padding: 2px 6px; text-align: center; pointer-events: none;
    text-overflow: ellipsis; overflow: hidden; white-space: nowrap; max-width: 100%;
}
.ed-widget.ed-type-video, .ed-widget.ed-type-playlist { background: rgba(210, 153, 34, .16); border-color: rgba(210, 153, 34, .6); }
.ed-widget.ed-type-qr { background: rgba(63, 185, 80, .16); border-color: rgba(63, 185, 80, .6); }
.ed-widget.ed-type-prayer_times { background: rgba(163, 113, 247, .16); border-color: rgba(163, 113, 247, .6); }

.ed-handle {
    position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px;
    background: var(--accent); cursor: nwse-resize; border-radius: 2px 0 2px 0;
}
.ed-widget.locked .ed-handle { display: none; }

.ed-layers { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.ed-layers li {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.ed-layers li:last-child { border-bottom: 0; }
.ed-layers li.selected { background: rgba(61, 139, 253, .12); }
.ed-layers button { background: none; border: 0; padding: 2px 4px; cursor: pointer; color: var(--text-dim); font-size: 12px; }
.ed-layers button:hover { color: var(--text); }
.ed-layer-name { flex: 1; cursor: pointer; color: var(--text); }
.ed-layer-z { min-width: 26px; text-align: right; font-size: 11px; }

.flash-warn { background: rgba(210,153,34,.09); border-color: rgba(210,153,34,.4); color: #e3b341; }
.warn-text { color: var(--warn); }
.bad-text { color: var(--bad); }
