/* Clip Search Admin — palette and type follow the build-plan document. */

:root {
  --paper: #F5F6F9;
  --surface: #FFFFFF;
  --ink: #1C2434;
  --muted: #59637A;
  --line: #DCE0E9;
  --accent: #2D4FBF;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7ECFA;
  --code-bg: #EEF0F5;
  --timecode: #A85E14;
  --green: #1F7A46;
  --green-soft: #E3F3E9;
  --red: #B3383C;
  --red-soft: #F9E7E7;
  --amber: #8A5A0F;
  --amber-soft: #FBF0DC;
  --blue-soft: #E7ECFA;
  --shadow: 0 1px 3px rgba(28, 36, 52, 0.06);
  --sidebar-w: 232px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #10141C;
    --surface: #171C26;
    --ink: #E3E7F0;
    --muted: #96A0B5;
    --line: #2A3140;
    --accent: #7C96E8;
    --accent-ink: #10141C;
    --accent-soft: #1E2637;
    --code-bg: #10151F;
    --timecode: #D9975C;
    --green: #6FCB96;
    --green-soft: #16281E;
    --red: #E08A8D;
    --red-soft: #2E1A1B;
    --amber: #E0B36A;
    --amber-soft: #2B2214;
    --blue-soft: #1E2637;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Source Sans 3", -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

h1, h2, h3, .brand { font-family: "Archivo", -apple-system, sans-serif; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }

.mono, .timecode, .json-block { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.92em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-weight: 800;
  font-size: 17px;
  color: var(--ink);
  padding: 4px 10px;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-sub {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  vertical-align: 2px;
  margin-left: 2px;
}

nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}
.nav-item:hover { background: var(--accent-soft); color: var(--ink); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item svg { opacity: 0.75; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.as-button {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.content {
  flex: 1;
  padding: 32px 40px 64px;
  max-width: 1160px;
  min-width: 0;
}

/* --- page furniture --- */

.kicker {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 4px;
}
.kicker a { color: inherit; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head p { max-width: 640px; margin-top: 4px; }
.sub-meta { display: flex; gap: 8px; align-items: center; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }

.stat-chips { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--muted);
}
.chip-stat b { color: var(--ink); font-size: 14px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 14px;
}

.flash {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid color-mix(in srgb, var(--green) 30%, transparent);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-weight: 600;
}
.error-flash { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }

/* --- tables --- */

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: 6px 10px 10px;
  border-bottom: 1px solid var(--line);
}
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
th.num, td.num { text-align: right; }
.row-link { font-weight: 600; color: var(--ink); }
.row-link:hover { color: var(--accent); }
.empty { color: var(--muted); text-align: center; padding: 28px 10px; }
.warn-text { color: var(--amber); font-weight: 700; }

/* --- pills & chips --- */

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.pill.embedded { background: var(--green-soft); color: var(--green); }
.pill.ingested { background: var(--blue-soft); color: var(--accent); }
.pill.pending  { background: var(--code-bg); color: var(--muted); }
.pill.error    { background: var(--red-soft); color: var(--red); }
.pill.warn     { background: var(--amber-soft); color: var(--amber); }

.chip {
  display: inline-block;
  background: var(--code-bg);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}
.pill.working {
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill.working .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}
.work-banner { display: flex; align-items: center; gap: 12px; border-left: 3px solid var(--accent); }

.chip.subject { background: var(--accent-soft); color: var(--accent); }
.chip.grade { background: var(--amber-soft); color: var(--amber); }
.err-note { color: var(--red); font-size: 12.5px; }

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

.clip-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.spacer { flex: 1; }
.timecode { color: var(--timecode); font-weight: 500; }
.dialog { color: var(--muted); font-size: 14px; }
.desc { font-weight: 600; margin-bottom: 6px; }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; }
.clip-card.editing { border-color: var(--accent); }

/* --- buttons & forms --- */

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); color: var(--accent-ink); }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--accent); }
.btn.danger { border-color: transparent; color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.wide { width: 100%; padding: 10px; font-size: 15px; }

label { display: block; font-weight: 700; font-size: 12.5px; margin: 12px 0 5px; }
input, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 11px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type="file"] { padding: 7px; background: var(--surface); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* --- search console --- */

.search-row { display: flex; gap: 10px; }
.search-row input { flex: 1; font-size: 15px; }
.htmx-indicator { display: none; margin-top: 8px; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }

.results-meta { display: flex; gap: 10px; align-items: center; margin: 4px 0 12px; flex-wrap: wrap; }
.rank {
  font-family: "Archivo", sans-serif;
  font-weight: 800;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 1px 8px;
}
.result-title { font-family: "Archivo", sans-serif; font-weight: 700; font-size: 16px; color: var(--ink); }
.result-title:hover { color: var(--accent); }
.result-card { border-left: 3px solid var(--accent); }

.score-row { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; }
.score-bar { flex: 0 0 180px; height: 6px; background: var(--code-bg); border-radius: 99px; overflow: hidden; }
.score-fill { height: 100%; background: var(--accent); border-radius: 99px; }

.debug-panel { border-left: 3px solid var(--amber); }
.json-block {
  background: var(--code-bg);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.5;
  margin-top: 8px;
}
.raw-json summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.raw-json summary:hover { color: var(--accent); }

/* --- ingest --- */

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.action-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.action-row:last-child { border-bottom: none; }
.action-row p { margin-top: 6px; }
.job-panel, .sources-foot { padding: 12px 20px; }
.job-line { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 4px 0; }

/* --- scene hints --- */

.section-head { margin: 26px 0 12px; }
.section-head p { max-width: 640px; }
.hint-card { border-left: 3px solid var(--green); }
.hint-card.hint-unmatched { border-left-color: var(--amber); }
.hint-form { margin-top: 12px; max-width: 460px; }
.hint-form .btn { margin-top: 10px; }

/* --- login --- */

.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: min(400px, 92vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 34px 34px 30px;
}
.login-card h1 { margin-bottom: 4px; }
.login-card form { margin-top: 10px; }
.login-card .btn { margin-top: 18px; }
.login-card .flash { margin-top: 14px; margin-bottom: 0; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; }
  nav { flex-direction: row; }
  .sidebar-foot { margin-top: 0; margin-left: auto; flex-direction: row; }
  .content { padding: 20px 16px 48px; }
  .two-col, .form-grid { grid-template-columns: 1fr; }
}

/* Clip playback modal */
.clip-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.clip-modal[hidden] { display: none; }
.clip-modal-backdrop { position: absolute; inset: 0; background: rgba(10, 12, 16, 0.72); }
.clip-modal-box {
  position: relative; width: min(880px, 94vw);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px;
}
.clip-modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
#clip-player { width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 8px; overflow: hidden; }
.clip-modal-controls { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
/* ui.disable removes the player CSS that sizes the video — size it ourselves */
#clip-player { position: relative; }
#clip-player > div,
#clip-player .kaltura-player-container { position: absolute; inset: 0; width: 100%; height: 100%; }
#clip-player video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }
