/* =====================================================================
   GameFlix — panel de administración
   ===================================================================== */

body.admin { background: var(--bg); }

input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(255, 59, 71, 0.18); }
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:disabled { opacity: 0.5; }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
select { cursor: pointer; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.88em; background: rgba(255, 255, 255, 0.08); padding: 1px 6px; border-radius: 4px; }
.btn-block { width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }
.opt { color: var(--muted-2); font-weight: 400; }
.req { color: var(--accent-2); }

.boot { min-height: 100vh; display: grid; place-items: center; }
.mini-spinner {
  display: inline-block; width: 14px; height: 14px; vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, 0.2); border-top-color: #fff; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ================= LOGIN ================= */
.login {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: hidden;
}
.login-glow {
  position: absolute; width: 760px; height: 760px; border-radius: 50%;
  background: radial-gradient(circle, rgba(229, 9, 20, 0.22), transparent 62%);
  filter: blur(10px);
}
.login-card {
  position: relative; width: 100%; max-width: 400px;
  background: rgba(23, 23, 29, 0.92);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 36px 32px 28px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(12px);
}
.login-card .brand { margin-bottom: 26px; }
.login-card h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.3px; }
.login-sub { color: var(--muted); font-size: 14.5px; margin: 6px 0 22px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 0 0 8px; }
.login-card #loginUser { height: 46px; margin-bottom: 14px; }
.pw-field { position: relative; margin-bottom: 14px; }
.pw-field input { padding-right: 48px; height: 46px; }
.pw-field .icon-btn { position: absolute; right: 4px; top: 3px; color: var(--muted); }
.form-error { color: #ff6b73; font-size: 13.5px; margin: -4px 0 14px; }
.login-card .btn-primary { height: 46px; }
.login-back { display: block; text-align: center; margin-top: 20px; color: var(--muted); font-size: 13.5px; }
.login-back:hover { color: #fff; }
.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ================= CABECERA ================= */
.admin-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  height: 64px; padding: 0 var(--gutter);
  background: rgba(11, 11, 15, 0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.admin-header .brand-word { font-size: 26px; }
.admin-header .brand-mark { width: 28px; height: 28px; }
.admin-tag {
  font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  padding: 3px 8px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-2);
}
.tabs { display: flex; gap: 2px; margin-left: 18px; height: 100%; }
.tab {
  display: flex; align-items: center; padding: 0 14px;
  font-size: 14.5px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
}
.tab:hover { color: #fff; }
.tab.active { color: #fff; border-bottom-color: var(--accent-2); }
.admin-header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.me-chip {
  font-size: 13px; font-weight: 700; color: var(--text-2);
  padding: 6px 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.05);
}

/* ================= CONTENIDO ================= */
.admin-main { max-width: 1200px; margin: 0 auto; padding: 32px var(--gutter) 80px; }
.admin-intro h1 { font-family: var(--font-display); font-weight: 400; font-size: 52px; line-height: 1; letter-spacing: 1px; }
.admin-intro p { color: var(--muted); margin: 6px 0 24px; max-width: 700px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.stat-value { display: block; font-family: var(--font-display); font-size: 42px; line-height: 1; letter-spacing: 1px; }
.stat-label { color: var(--muted); font-size: 13.5px; font-weight: 500; }
.stat.is-dim .stat-value { color: var(--muted-2); }
.stat.is-warn .stat-value { color: var(--warning); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 20px; overflow: hidden; }
.panel.pad { padding: 20px 22px; }
.panel-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 18px; font-weight: 700; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar select { width: auto; min-width: 180px; padding: 8px 12px; }
.search-field { position: relative; }
.search-field svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-2); }
.search-field input { padding: 8px 12px 8px 36px; width: 240px; }

/* ---------- Lista de juegos ---------- */
.game-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto auto auto;
  align-items: center; gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s, opacity 0.2s;
}
.game-row:last-child { border-bottom: none; }
.game-row:hover { background: rgba(255, 255, 255, 0.025); }
.game-row.is-hidden .thumb, .game-row.is-hidden .gr-main { opacity: 0.5; }
.thumb { position: relative; overflow: hidden; width: 112px; aspect-ratio: 16 / 9; border-radius: 6px; background: var(--surface-2); }
.thumb > img { width: 100%; height: 100%; object-fit: cover; }
.gr-main { min-width: 0; }
.gr-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; font-size: 15px; }
.gr-url { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.gr-url span { color: var(--muted-2); }
.gr-url:hover { color: #fff; }
.status { font-size: 10.5px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; padding: 2px 7px; border-radius: 4px; white-space: nowrap; }
.st-hidden { background: rgba(255, 255, 255, 0.08); color: var(--text-2); }
.st-iso { background: rgba(123, 47, 247, 0.2); color: #c4a5ff; }
.st-ext { background: rgba(31, 111, 235, 0.18); color: #8ab4ff; }
.st-warn { background: rgba(255, 255, 255, 0.05); color: var(--muted); }
.chip {
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line-strong);
  white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis;
}
.gr-toggles, .gr-actions { display: flex; gap: 2px; }
.row-btn {
  width: 34px; height: 34px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.row-btn svg { width: 19px; height: 19px; }
.row-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.08); color: #fff; }
.row-btn:disabled { opacity: 0.25; cursor: default; }
.row-btn.danger:hover:not(:disabled) { background: rgba(229, 9, 20, 0.16); color: #ff6b73; }
.row-btn.star.on { color: #ffc93c; }
.row-btn.eye.on { color: var(--text-2); }
.row-btn.eye:not(.on) { color: var(--warning); }

.list-empty { text-align: center; padding: 56px 24px; }
.list-empty.small { padding: 32px 24px; color: var(--muted); }
.list-empty-icon {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-2);
}
.list-empty-icon svg { width: 34px; height: 34px; }
.list-empty h3 { font-size: 19px; margin-bottom: 6px; }
.list-empty p { color: var(--muted); max-width: 420px; margin: 0 auto 20px; }

/* ---------- Cuentas ---------- */
.two-col { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.side-stack { display: flex; flex-direction: column; gap: 0; }
.user-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; border-bottom: 1px solid var(--line);
}
.user-row:last-child { border-bottom: none; }
.user-row.is-off .avatar, .user-row.is-off .ur-main { opacity: 0.5; }
.avatar {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #fff; background: var(--surface-3);
}
.avatar.is-admin { background: linear-gradient(135deg, var(--accent-2), #7b2ff7); }
.ur-main { flex: 1; min-width: 0; }
.ur-name { font-weight: 700; }
.ur-name .you { color: var(--muted); font-weight: 500; font-size: 13px; }
.ur-meta { font-size: 12.5px; color: var(--muted-2); }

.stack-form { display: flex; flex-direction: column; gap: 12px; }
.stack-form > label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.stack-form > .btn { align-self: flex-start; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.input-row .btn { flex-shrink: 0; }

/* ---------- Ajustes ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.form-grid > label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.switch-list { display: flex; flex-direction: column; gap: 14px; }
.cat-order { display: flex; flex-direction: column; gap: 6px; }
.cat-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px 8px 14px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line);
}
.cat-pos { font-family: var(--font-display); font-size: 22px; color: var(--muted-2); width: 22px; }
.cat-name { flex: 1; font-weight: 600; }
.settings-actions { display: flex; justify-content: flex-end; margin: -4px 0 24px; }
.tool-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* ================= INTERRUPTORES ================= */
.switch-row { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; }
.switch-row small { color: var(--muted-2); font-size: 12.5px; line-height: 1.45; display: inline-block; margin-top: 2px; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; flex-shrink: 0; width: 44px; height: 24px; border-radius: 999px; background: var(--surface-3); transition: background 0.2s; }
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform 0.2s var(--ease);
}
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(20px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.switch-row input:disabled + .switch { opacity: 0.4; }

/* ================= EDITOR (panel lateral) ================= */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity 0.25s;
}
.drawer-backdrop.open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 210;
  width: min(600px, 100vw);
  display: flex; flex-direction: column;
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.5);
  transform: translateX(100%);
  transition: transform 0.3s var(--ease);
}
.drawer.open { transform: none; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 16px 24px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 19px; font-weight: 800; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px 24px 30px; display: flex; flex-direction: column; gap: 20px; }
.drawer-foot { display: flex; align-items: center; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); background: var(--bg-2); }

.field label { display: block; font-size: 13.5px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.hint { font-size: 12.5px; color: var(--muted-2); margin-top: 6px; line-height: 1.5; }
.hint a { color: var(--text-2); text-decoration: underline; }
.field-error { display: none; font-size: 13px; color: #ff6b73; margin-top: 6px; }
.field.invalid input, .field.invalid textarea { border-color: #ff6b73; }
.field.invalid .field-error { display: block; }
.char-count { text-align: right; font-size: 12px; color: var(--muted-2); margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips:empty { display: none; }
.chip-btn {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line-strong);
  transition: color 0.15s, border-color 0.15s;
}
.chip-btn:hover { color: #fff; border-color: #fff; }

.check-result {
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  font-size: 13.5px; line-height: 1.45; border: 1px solid var(--line-strong);
}
.check-result svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.check-result small { display: block; color: var(--muted); margin-top: 2px; }
.check-result.is-loading { color: var(--muted); align-items: center; }
.check-result.is-good { border-color: rgba(34, 197, 94, 0.4); background: rgba(34, 197, 94, 0.08); color: #a7f3c0; }
.check-result.is-info { border-color: rgba(123, 47, 247, 0.45); background: rgba(123, 47, 247, 0.1); color: #d6c4ff; }
.check-result.is-warn { border-color: rgba(245, 159, 0, 0.45); background: rgba(245, 159, 0, 0.08); color: #ffd58a; }
.check-result.is-bad { border-color: rgba(229, 9, 20, 0.45); background: rgba(229, 9, 20, 0.08); color: #ffb3b8; }

.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line-strong); }
.segmented label { margin: 0; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span {
  display: block; text-align: center; padding: 8px 6px; border-radius: 7px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.segmented label:hover span { color: #fff; }
.segmented input:checked + span { background: var(--surface-3); color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent-2); }

.cover-editor { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 14px; align-items: start; }
.cover-thumb { position: relative; overflow: hidden; aspect-ratio: 16 / 9; border-radius: 8px; background: var(--surface); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); }
.cover-thumb > img { width: 100%; height: 100%; object-fit: cover; }
.cover-controls { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cover-buttons { display: flex; flex-wrap: wrap; gap: 6px; }

/* ================= PROBADOR ================= */
.test-player { position: fixed; inset: 0; z-index: 400; display: flex; flex-direction: column; background: #000; opacity: 0; transition: opacity 0.2s; }
.test-player.open { opacity: 1; }
.test-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--bg-2); border-bottom: 1px solid var(--line); }
.test-label { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.test-label b { color: var(--text); font-weight: 600; }
.test-stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; }
.test-stage .game-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; opacity: 0; transition: opacity 0.3s; }
.test-stage .game-frame.ready { opacity: 1; }
.test-help { padding: 10px 16px; font-size: 13px; color: var(--muted); background: var(--bg-2); border-top: 1px solid var(--line); text-align: center; }

/* ================= MODALES ================= */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 600;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(0, 0, 0, 0.65); backdrop-filter: blur(4px);
  opacity: 0; transition: opacity 0.18s;
}
.modal-backdrop.open { opacity: 1; }
.modal {
  width: 100%; max-width: 440px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px;
  padding: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  transform: scale(0.96); transition: transform 0.2s var(--ease);
}
.modal-backdrop.open .modal { transform: none; }
.modal h3 { font-size: 18px; margin-bottom: 12px; }
.modal p { color: var(--muted); font-size: 14.5px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }

/* ---------- Portadas con otra proporción ---------- */
.is-fit > img[data-fit] { object-fit: contain; position: relative; z-index: 1; }
.fit-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scale(1.25); }

/* ================= RESPONSIVE ================= */
@media (max-width: 960px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .game-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
  .thumb { width: 96px; }
  .gr-main { flex: 1 1 calc(100% - 110px); }
  .game-row .chip { margin-right: auto; }
  .tabs { margin-left: 4px; }
}
@media (max-width: 640px) {
  .admin-header { height: auto; flex-wrap: wrap; padding-top: 10px; padding-bottom: 0; row-gap: 6px; }
  .admin-header .brand-word, .hide-sm, .me-chip { display: none; }
  .tabs { order: 5; width: 100%; margin: 0; height: 42px; }
  .tab { flex: 1; justify-content: center; }
  .admin-intro h1 { font-size: 42px; }
  .toolbar, .search-field, .search-field input, .toolbar select { width: 100%; }
  .toolbar .btn { flex: 1; }
  .game-row { padding: 12px 14px; gap: 8px 12px; }
  .thumb { width: 84px; }
  .gr-main { flex-basis: calc(100% - 96px); }
  .row-btn { width: 32px; }
  .user-row { flex-wrap: wrap; padding: 12px 14px; }
  .cover-editor { grid-template-columns: 1fr; }
  .drawer-body { padding: 18px 16px 24px; }
  .drawer-foot { padding: 12px 16px; }
  .segmented span { font-size: 12px; padding: 8px 2px; }
  .test-bar { flex-wrap: wrap; }
  .test-label { flex-basis: 100%; }
}

/* ---------- Edad, contenido y controles ---------- */
.desc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.desc-chips label { margin: 0; cursor: pointer; }
.desc-chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.desc-chips span {
  display: inline-block; font-size: 12.5px; font-weight: 600; color: var(--muted);
  padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line-strong);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.desc-chips input:checked + span { color: #fff; border-color: var(--accent-2); background: var(--accent-soft); }
.desc-chips input:focus-visible + span { outline: 2px solid var(--accent-2); }
.ctrl-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ctrl-edit .mini { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); margin: 0; }
.ctrl-edit textarea { min-height: 92px; font-size: 13px; font-family: ui-monospace, Consolas, monospace; }
.test-stage .game-frame.fixed-res { inset: auto; transform-origin: 0 0; }
@media (max-width: 640px) { .ctrl-edit { grid-template-columns: 1fr; } }

/* Jugadores, cooperativo y anuncios */
.st-feat { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.row-2 { display: grid; grid-template-columns: 1fr 160px; gap: 10px; }
.block-label { display: grid; gap: 6px; margin-top: 14px; font-size: 13px; font-weight: 600; }
.block-label input { width: 100%; }
#playerList .gr-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
