/* JoeTV — panel de administración. Sin build: CSS plano con variables y modo oscuro. */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f1f6;
  --border: #e2e4ec;
  --text: #1a1c26;
  --muted: #6b6f80;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --ok: #0f8a5f;
  --ok-soft: #e3f6ee;
  --warn: #a15c00;
  --warn-soft: #fff3dc;
  --danger: #c4314b;
  --danger-hover: #a8273e;
  --danger-soft: #fde8ec;
  --shadow: 0 1px 2px rgba(16, 18, 30, .05), 0 2px 8px rgba(16, 18, 30, .04);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #171a23;
  --surface-2: #1e2230;
  --border: #2a2f3f;
  --text: #e7e9f0;
  --muted: #9097ab;
  --accent: #8b85ff;
  --accent-hover: #a29dff;
  --accent-soft: #24234a;
  --ok: #4cd4a0;
  --ok-soft: #133528;
  --warn: #f2b45a;
  --warn-soft: #3a2a10;
  --danger: #ff6b85;
  --danger-hover: #ff8a9e;
  --danger-soft: #3d1a22;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1117;
    --surface: #171a23;
    --surface-2: #1e2230;
    --border: #2a2f3f;
    --text: #e7e9f0;
    --muted: #9097ab;
    --accent: #8b85ff;
    --accent-hover: #a29dff;
    --accent-soft: #24234a;
    --ok: #4cd4a0;
    --ok-soft: #133528;
    --warn: #f2b45a;
    --warn-soft: #3a2a10;
    --danger: #ff6b85;
    --danger-hover: #ff8a9e;
    --danger-soft: #3d1a22;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

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

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }

code, .mono { font-family: var(--mono); font-size: .92em; }

/* ---------- Barra superior ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  font-size: 1.1rem;
  color: var(--text);
}
.brand:hover { text-decoration: none; color: var(--text); }

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: .8rem;
  font-weight: 800;
}

.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }

.nav a {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 550;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }

.topbar-user { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }

/* ---------- Layout ---------- */

.container { max-width: 1200px; margin: 0 auto; padding: 28px 16px 64px; }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-header .subtitle { color: var(--muted); margin-top: 4px; }

.breadcrumb { font-size: .875rem; color: var(--muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.stack { display: grid; gap: 20px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }

@media (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .container { padding-top: 20px; }
  h1 { font-size: 1.35rem; }
}

/* ---------- Tarjetas ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header .hint { color: var(--muted); font-size: .875rem; font-weight: 400; }

.card-body { padding: 20px; }
.card-body.flush { padding: 0; }

.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: .9rem;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-outline-danger { color: var(--danger); border-color: var(--border); background: var(--surface); }
.btn-outline-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

.btn-sm { padding: 5px 10px; font-size: .8rem; border-radius: 6px; }

.inline-form { display: inline; margin: 0; }

/* ---------- Insignias ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 650;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge.plain::before { display: none; }

/* ---------- Tablas ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }

.table th, .table td {
  padding: 11px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.table th {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  font-weight: 650;
  background: var(--surface-2);
  white-space: nowrap;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.actions-cell { text-align: right; white-space: nowrap; }
.table .sub { display: block; color: var(--muted); font-size: .8rem; }
.table tr.is-dim td { opacity: .55; }

/* ---------- Formularios ---------- */

.field { display: grid; gap: 6px; }
.field label, .label { font-weight: 600; font-size: .875rem; }
.field .help { color: var(--muted); font-size: .8rem; }
.field .error { color: var(--danger); font-size: .82rem; font-weight: 550; }

.input, select.input, textarea.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .95rem;
  transition: border-color .12s, box-shadow .12s;
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.is-invalid { border-color: var(--danger); }
.input.mono { font-family: var(--mono); font-size: .9rem; }

.check { display: flex; align-items: center; gap: 8px; font-weight: 550; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }

.quick-dates { display: flex; gap: 6px; flex-wrap: wrap; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .input { width: auto; min-width: 0; }
.toolbar .search { flex: 1 1 260px; }

fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 650; margin-bottom: 12px; padding: 0; }

/* ---------- Avisos ---------- */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  border: 1px solid transparent;
  font-weight: 550;
}
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert ul { margin: 6px 0 0; padding-left: 18px; font-weight: 450; }

.empty { text-align: center; color: var(--muted); padding: 36px 20px; }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* ---------- Código de activación ---------- */

.code-panel { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.code-display {
  font-family: var(--mono);
  font-size: clamp(1.8rem, 6vw, 2.6rem);
  font-weight: 700;
  letter-spacing: .14em;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  user-select: all;
  cursor: pointer;
}

/* ---------- Métricas ---------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--surface-2); }
.stat .stat-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }
.stat .stat-value { font-size: 1.15rem; font-weight: 700; margin-top: 2px; }

dl.details { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dl.details dt { color: var(--muted); font-size: .875rem; }
dl.details dd { margin: 0; }

/* ---------- Listas (detalle de cliente) ---------- */

.playlist + .playlist { border-top: 1px solid var(--border); }
.playlist-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 16px 20px 12px; }
.playlist-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: .85rem; }

.secret { font-family: var(--mono); font-size: .88em; }
.secret-toggle { border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; font-size: .8rem; padding: 0 0 0 6px; }

.capacity { font-variant-numeric: tabular-nums; }

/* ---------- Paginación ---------- */

.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pagination .pages { display: flex; gap: 6px; }

/* ---------- Login ---------- */

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { justify-content: center; margin-bottom: 20px; font-size: 1.35rem; }

/* ---------- Tema ---------- */

.theme-toggle { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: inline; }
}

.copied { position: relative; }
.copied::after {
  content: "¡Copiado!";
  position: absolute;
  left: 50%;
  top: -30px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font: 600 .75rem/1 system-ui, sans-serif;
  letter-spacing: 0;
  padding: 6px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

/* ---------- Deportes ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

.day-pills { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px; }
.day-pills a {
  display: grid; justify-items: center; min-width: 64px; padding: 8px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .78rem;
}
.day-pills a b { font-size: 1.05rem; color: var(--text); }
.day-pills a:hover { text-decoration: none; border-color: var(--accent); }
.day-pills a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.day-pills a.active b { color: #fff; }

a.plain, a.plain:hover { color: inherit; text-decoration: none; }
.teams { display: inline-flex; align-items: center; gap: 10px; }
.team { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.team img { flex: none; }
.team img { width: 22px; height: 22px; object-fit: contain; }
.teams .vs { color: var(--muted); font-size: .8rem; }
.teams .score { font-weight: 700; font-variant-numeric: tabular-nums; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); }
.flags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.flags:empty { display: none; }

.chips { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: .78rem;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; margin: 1px 0;
}
.chip b { font-size: .68rem; opacity: .75; }
.chip-inherited { background: var(--surface-2); color: var(--muted); }
/* Canal de la lista base asociado al evento (automático o conectado a mano). */
.chip-stream { background: transparent; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }
.chips .sub { display: inline; margin-left: 4px; }

.bulk-bar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px;
  border-top: 1px solid var(--border); background: var(--surface-2);
}
.dropdown { position: relative; }
.dropdown summary { list-style: none; }
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown-menu {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 10; display: grid; gap: 6px;
  min-width: 260px; max-height: 320px; overflow-y: auto; padding: 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
}
.align-start { align-items: start; }

[hidden] { display: none !important; }
