/* DrekoTV admin — Glizzy picks
 *
 * Mirrors the macOS app's brand palette + Liquid Glass-inspired
 * surfaces without using the SDK (web can't render real Liquid
 * Glass — we approximate the feel with backdrop-filter + accent
 * radial wash on a near-black backdrop). Tokens here are 1:1 with
 * `BrandPalette.swift` so the admin reads as part of the same
 * product family. */

:root {
  --bg: #050505;
  --surface: #111;
  --surface-2: #1c1c1c;
  --rim: rgba(255, 255, 255, 0.08);
  --rim-strong: rgba(255, 255, 255, 0.16);
  --text: #fff;
  --text-muted: #b8b8b8;
  --text-dim: #7d7d7d;
  --accent: #dd090c;
  --accent-dark: #8b0003;
  --danger: #ff5b5b;
  --green: #34c759;
}

* { box-sizing: border-box; }

/* Honour the HTML5 `hidden` attribute even on elements that set an
 * explicit `display` value. The user-agent stylesheet ships
 * `[hidden] { display: none }` but with the LOWEST specificity, so
 * any class that sets `display` (e.g. `.auth { display: grid }`)
 * wins and `hidden = true` becomes a no-op. We add `!important` so
 * `login.hidden = true` after a successful sign-in actually hides
 * the login pane and the shell takes over. Without this rule the
 * shell renders BENEATH the still-visible login form, which reads
 * to the user as "sign-in didn't do anything". */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

/* Page-level radial wash, the same trick `DrekoPageBackdrop` uses on
 * the macOS app — gives glass-style surfaces something to refract. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 0%, rgba(221, 9, 12, 0.10), transparent 55%),
    radial-gradient(circle at 80% 100%, rgba(221, 9, 12, 0.05), transparent 60%),
    linear-gradient(180deg, #111 0%, #050505 100%);
  z-index: -1;
}

button { font: inherit; cursor: pointer; }
input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ============================== AUTH ============================== */

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  padding: 32px 28px 28px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid var(--rim);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.4px;
}
.brand.small { gap: 10px; }
.brand.small strong { font-size: 14px; letter-spacing: 1.2px; text-transform: uppercase; }

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  background:
    radial-gradient(circle at 30% 30%, rgba(221, 9, 12, 0.35), transparent 70%),
    linear-gradient(180deg, #1f1f1f 0%, #0a0a0a 100%);
  border: 1px solid var(--rim);
}

.auth-hint {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}

.field {
  display: block;
  margin-bottom: 18px;
}
.field > span {
  display: block;
  font-size: 10px;
  letter-spacing: 1.8px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--rim);
  background: rgba(0, 0, 0, 0.45);
  outline: none;
  font-size: 14px;
  letter-spacing: 0.3px;
  transition: border-color 120ms ease, background 120ms ease;
}
.field input:focus {
  border-color: rgba(221, 9, 12, 0.6);
  background: rgba(0, 0, 0, 0.62);
}

.primary, .ghost, .danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--rim);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.primary {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  border-color: rgba(221, 9, 12, 0.55);
  color: #fff;
}
.primary:hover { transform: translateY(-1px); }
.ghost:hover { background: rgba(255, 255, 255, 0.08); }
.danger {
  border-color: rgba(255, 91, 91, 0.5);
  color: var(--danger);
}
.danger:hover { background: rgba(255, 91, 91, 0.08); }
button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.auth-error {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--danger);
}

/* ============================= SHELL ============================== */

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 28px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  margin-bottom: 22px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--rim);
}
.spacer { flex: 1; }

.panel {
  margin: 0 0 28px;
  padding: 22px 22px 24px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--rim);
}
.panel h2 {
  margin: 0 0 6px;
  font-size: 15px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent);
}
.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.muted {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 0 0 16px;
}

/* ============================ SEARCH ============================== */

#search-form {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
#search-input {
  flex: 1;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--rim);
  background: rgba(0, 0, 0, 0.45);
  outline: none;
  font-size: 14px;
}
#search-input:focus { border-color: rgba(221, 9, 12, 0.6); }
#search-type {
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--rim);
  background: rgba(0, 0, 0, 0.45);
  outline: none;
  font-size: 13px;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.result-card {
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--rim);
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  position: relative;
  display: flex;
  flex-direction: column;
}
.result-card:hover {
  transform: translateY(-2px);
  border-color: rgba(221, 9, 12, 0.5);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.45);
}
.result-card.added { border-color: rgba(52, 199, 89, 0.55); }
.result-card.added::after {
  content: "✓";
  position: absolute;
  top: 8px; right: 8px;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--green);
  color: #050505;
  font-weight: 700;
  font-size: 14px;
}
.result-card .poster {
  width: 100%;
  aspect-ratio: 2 / 3;
  background: #222 center/cover no-repeat;
}
.result-card .meta {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.result-card .title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-card .sub {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
}
.result-card .tag {
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

/* ============================== RAIL ============================== */

.rail {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.pick {
  display: grid;
  grid-template-columns: 24px 56px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--rim);
  transition: border-color 120ms ease, transform 120ms ease, background 120ms ease;
  position: relative;
}
.pick.dragging {
  opacity: 0.55;
  border-color: rgba(221, 9, 12, 0.55);
}
.pick.drop-target {
  border-color: rgba(52, 199, 89, 0.65);
  transform: translateY(-1px);
}
.pick .handle {
  color: var(--text-dim);
  font-size: 16px;
  letter-spacing: -0.5px;
  cursor: grab;
  user-select: none;
}
.pick .handle:active { cursor: grabbing; }
.pick .poster {
  width: 56px;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  background: #222 center/cover no-repeat;
  flex-shrink: 0;
}
.pick .info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.pick .info .name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pick .info .sub {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
}
.pick .actions {
  display: flex;
  gap: 6px;
}
.empty-rail {
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  border-radius: 14px;
  border: 1px dashed var(--rim-strong);
}

/* ============================ TOASTS ============================== */

.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 50;
}
.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(20, 20, 20, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--rim);
  font-size: 13px;
  max-width: 340px;
  animation: slide-in 200ms ease;
}
.toast.error { border-color: rgba(255, 91, 91, 0.5); color: var(--danger); }
.toast.success { border-color: rgba(52, 199, 89, 0.45); }
@keyframes slide-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
