/*
 * Owner dashboard styles (local preview). Plain CSS, no frameworks, no web fonts.
 * Colours are tokens at the top; the dark theme only swaps the tokens.
 * Contrast of every text/background pair below was checked (all at least 4.5:1,
 * borders and focus rings at least 3:1).
 */

:root {
  color-scheme: light dark;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #151a22;
  --muted: #4b5565;
  --border: #cfd5df;          /* soft divider lines */
  --border-strong: #8a94a6;   /* edges of inputs and buttons (3:1 against the surface) */
  --primary: #1f4fd1;
  --on-primary: #ffffff;
  --soft: #e8eefc;
  --soft-text: #173a9c;
  --danger: #b3261e;
  --on-danger: #ffffff;
  --ok-bg: #e3f4e8;
  --ok-text: #0d5c2b;
  --warn-bg: #fff3cd;
  --warn-text: #5c4200;
  --err-bg: #fdeceb;
  --err-text: #8a1c15;
  --banner-bg: #ffefb8;
  --banner-text: #3f2d00;
  --track: #dde3ee;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161b22;
    --text: #e8ecf2;
    --muted: #a9b3c2;
    --border: #2d3541;
    --border-strong: #6b7686;
    --primary: #7aa5ff;
    --on-primary: #07122b;
    --soft: #1c2a4d;
    --soft-text: #bcd0ff;
    --danger: #ff8f86;
    --on-danger: #2b0603;
    --ok-bg: #12301d;
    --ok-text: #8fe0ab;
    --warn-bg: #3a2e08;
    --warn-text: #ffd979;
    --err-bg: #3b1512;
    --err-text: #ffb4ab;
    --banner-bg: #3a2e0a;
    --banner-text: #ffe39a;
    --track: #2a3342;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

h1, h2, h3, p { margin: 0; }
h2 { font-size: 1.5rem; line-height: 1.25; }
h3 { font-size: 1.15rem; line-height: 1.3; overflow-wrap: anywhere; }
p + p { margin-top: 0.5rem; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.9rem; margin-top: 0.35rem; }

/* Visible only to screen readers */
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Keyboard focus: always clearly visible */
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
#app:focus { outline: none; }

/* ---------- Page frame ---------- */
.wrap { width: 100%; max-width: 880px; margin: 0 auto; padding: 0 16px; }

.banner {
  background: var(--banner-bg);
  color: var(--banner-text);
  padding: 10px 16px;
  text-align: center;
  font-size: 0.95rem;
}

.topbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; }
.brand { font-weight: 700; letter-spacing: 0.01em; }

main.wrap { padding-top: 24px; padding-bottom: 64px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 18px;
  border: 1px solid transparent; border-radius: 10px;
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; text-align: center;
  cursor: pointer; background: none; color: var(--text);
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--soft); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-quiet { color: var(--primary); padding: 6px 10px; min-height: 40px; font-weight: 600; }
.btn-quiet:hover:not(:disabled) { background: var(--soft); }
.btn-quiet.is-danger { color: var(--danger); }
.btn-big { min-height: 52px; font-size: 1.05rem; padding: 10px 24px; }
.btn-small { min-height: 40px; padding: 6px 14px; }

/* ---------- Forms ---------- */
.field { margin-top: 16px; }
label { display: block; font-weight: 600; margin-bottom: 6px; }
label .muted { font-weight: 400; }
input[type="text"], input[type="password"], input.linkbox {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
input.linkbox { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.95rem; }
input[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
.field-error { color: var(--danger); font-size: 0.95rem; margin-top: 6px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-weight: 400; }
.check input { width: 20px; height: 20px; margin: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

.prefixed { display: flex; align-items: stretch; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); }
.prefixed:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }
.prefixed .prefix { display: flex; align-items: center; padding: 0 0 0 12px; color: var(--muted); font-size: 0.9rem; white-space: nowrap; max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
.prefixed input { border: 0; outline: none; background: transparent; min-width: 0; }

/* Password strength bar */
.meter { display: flex; gap: 4px; margin-top: 8px; }
.meter span { flex: 1; height: 6px; border-radius: 3px; background: var(--track); }
.meter[data-level="1"] span:nth-child(-n+1) { background: var(--danger); }
.meter[data-level="2"] span:nth-child(-n+2) { background: #c77700; }
.meter[data-level="3"] span:nth-child(-n+3) { background: var(--primary); }
.meter[data-level="4"] span:nth-child(-n+4) { background: #1e8a47; }

/* ---------- Sign-in and set-up ---------- */
.auth { max-width: 460px; margin: 24px auto 0; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.auth h2 { margin-bottom: 8px; }

/* ---------- Messages ---------- */
.msg { margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-size: 0.95rem; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.msg-success { background: var(--ok-bg); color: var(--ok-text); }
.msg-error { background: var(--err-bg); color: var(--err-text); }
.msg-info { background: var(--soft); color: var(--soft-text); }
.msg .btn { margin-left: auto; }

/* ---------- Dashboard ---------- */
.dash-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 20px; }
.dash-head p { margin-top: 4px; }
/* minmax(0, 1fr): a card may shrink below its content's natural width instead of pushing the page sideways */
.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 16px; padding: 32px 20px; text-align: center; }
.empty h3 { margin-bottom: 6px; }
/* while the "Add a new video" panel is open, "No videos yet" would be misleading (the new one is on its way) */
.new-slot:not(:empty) + .cards .empty { display: none; }

.card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; box-shadow: var(--shadow); }
.panel { margin-bottom: 20px; }
.panel h2 { font-size: 1.25rem; margin-bottom: 4px; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.card-head h3 { flex: 1 1 200px; min-width: 0; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.85rem; font-weight: 700; border: 1px solid transparent; }
.badge-live { background: var(--ok-bg); color: var(--ok-text); }
.badge-draft { background: var(--warn-bg); color: var(--warn-text); }
.badge-hidden { background: var(--track); color: var(--text); }
.badge-problem { background: var(--err-bg); color: var(--err-text); }
.badge-home { background: var(--soft); color: var(--soft-text); }
.status-hint { margin-top: 6px; color: var(--muted); font-size: 0.95rem; }

.linkrow { display: flex; flex-wrap: wrap; gap: 8px; }
.linkrow input { flex: 1 1 220px; min-width: 0; width: auto; }
.linkrow .btn { flex: 0 0 auto; }

.info { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.facts { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 0; }
.facts div { display: flex; gap: 6px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; padding: 0; list-style: none; }
.tag { padding: 2px 10px; border-radius: 6px; background: var(--soft); color: var(--soft-text); font-size: 0.85rem; font-weight: 600; }
.file-meta { margin-top: 8px; color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }

.chips { display: grid; gap: 8px; margin: 12px 0 0; padding: 0; list-style: none; }
.chip { background: var(--warn-bg); color: var(--warn-text); border-radius: 10px; padding: 8px 12px; font-size: 0.95rem; }
.chip strong { display: block; }

.actions-main { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.actions-more { display: flex; flex-wrap: wrap; gap: 2px 4px; margin: 14px -10px 0; padding-top: 10px; border-top: 1px solid var(--border); }

/* ---------- File drop area ---------- */
.dropzone {
  position: relative; display: block; margin: 16px 0 0; padding: 28px 16px; text-align: center; font-weight: 400;
  border: 2px dashed var(--border-strong); border-radius: 14px; background: var(--bg); cursor: pointer;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--soft); }
.dropzone:focus-within { outline: 3px solid var(--primary); outline-offset: 2px; }
.dropzone strong { display: block; font-size: 1.1rem; }
.dropzone .picked { display: block; margin-top: 8px; font-weight: 600; overflow-wrap: anywhere; }

details.field summary { cursor: pointer; font-weight: 600; min-height: 32px; padding: 4px 0; }

/* ---------- Upload progress ---------- */
.upload { margin-top: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.upload-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.upload-top .filename { overflow-wrap: anywhere; min-width: 0; }
.upload-top .upload-pct { font-weight: 700; font-variant-numeric: tabular-nums; }
.upload-stats { color: var(--muted); font-size: 0.95rem; margin-top: 8px; font-variant-numeric: tabular-nums; }
.upload .actions { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
progress { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 12px; border: 0; border-radius: 999px; background: var(--track); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--track); }
progress::-webkit-progress-value { background: var(--primary); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--primary); border-radius: 999px; }

/* ---------- Pop-up windows ---------- */
dialog { width: calc(100% - 32px); max-width: 560px; padding: 0; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(8, 12, 20, 0.6); }
.dlg-inner { padding: 20px; max-height: calc(100vh - 48px); overflow: auto; }
.dlg-inner h2 { font-size: 1.25rem; margin-bottom: 8px; }
.versions { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.version { border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.version-top { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-weight: 600; }
.version p { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.version .actions { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 0 -10px; }

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  main.wrap { padding-top: 16px; }
  .card, .panel, .auth { padding: 16px; }
  .linkrow .btn { flex: 1 1 100%; }
  .actions-main .btn { flex: 1 1 100%; }
  .dash-head .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
