@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap");

:root {
  --ink: #061210;
  --teal: #0f3d38;
  --teal-light: #1a5c54;
  --gold: #d4a84b;
  --gold-dim: #b87333;
  --cream: #f5efe6;
  --muted: #a8b5ad;
  --danger: #ef4444;
  --sidebar-w: 260px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Outfit, system-ui, sans-serif; background: var(--ink); color: var(--cream); }

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

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(ellipse at top, rgba(15,61,56,.55), var(--ink)); }
.login-card { width: min(420px, 100%); border: 1px solid rgba(212,168,75,.28); border-radius: 16px; padding: 2rem; background: rgba(15,61,56,.45); box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.login-card h1 { margin: 0 0 .35rem; font-size: 1.5rem; }
.login-card p { margin: 0 0 1.25rem; color: var(--muted); font-size: .95rem; }
.login-brand { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.5rem; }
.login-brand span { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, var(--gold), var(--gold-dim)); display: grid; place-items: center; font-weight: 800; color: var(--ink); }

/* App shell */
.admin-app { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: rgba(15,61,56,.65);
  border-right: 1px solid rgba(212,168,75,.15);
  padding: 1.25rem 0;
  display: flex;
  flex-direction: column;
}
.admin-brand { padding: 0 1.25rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.06); margin-bottom: .75rem; }
.admin-brand strong { display: block; font-size: 1rem; }
.admin-brand small { color: var(--muted); font-size: .8rem; }
.admin-nav { flex: 1; padding: .5rem; }
.admin-nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .65rem .85rem; margin-bottom: .25rem;
  border-radius: 10px; color: var(--cream); text-decoration: none;
  font-weight: 500; font-size: .95rem;
  transition: background .15s;
}
.admin-nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.admin-nav a.active { background: rgba(212,168,75,.18); color: var(--gold); }
.admin-nav .nav-icon { width: 1.25rem; text-align: center; opacity: .85; }
.admin-sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.06); font-size: .85rem; color: var(--muted); }
.admin-sidebar-footer button { width: 100%; margin-top: .5rem; }

.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(212,168,75,.12);
  background: rgba(15,61,56,.25);
  display: flex; justify-content: space-between; align-items: center;
}
.admin-topbar h1 { margin: 0; font-size: 1.35rem; font-weight: 600; }
.admin-topbar-left { display: flex; align-items: center; min-width: 0; flex: 1; gap: 0; }
.admin-content { padding: 1.5rem; max-width: 1100px; width: 100%; }

.card {
  border: 1px solid rgba(212,168,75,.22);
  border-radius: 14px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  background: rgba(15,61,56,.28);
}
.card h2 { margin: 0 0 1rem; font-size: 1.1rem; }

.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; }
.stat-card { text-align: center; padding: 1.25rem; }
.stat-card .num { font-size: 2rem; font-weight: 700; color: var(--gold); line-height: 1.1; }
.stat-card small { color: var(--muted); }

label { display: block; margin: .65rem 0 .35rem; font-size: .9rem; font-weight: 500; }
input, textarea, select {
  width: 100%; padding: .6rem .75rem; border-radius: 10px;
  border: 1px solid rgba(212,168,75,.25); background: #061210; color: var(--cream);
  font-family: inherit; font-size: .95rem;
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(212,168,75,.35); border-color: var(--gold); }

.btn, button {
  border: 0; border-radius: 999px; padding: .55rem 1.1rem;
  background: linear-gradient(180deg, var(--gold), var(--gold-dim));
  color: var(--ink); font-weight: 700; cursor: pointer; font-family: inherit; font-size: .9rem;
}
.btn:hover, button:hover { filter: brightness(1.05); }
.btn:disabled, button:disabled { opacity: .55; cursor: not-allowed; }
.btn-outline { background: transparent; border: 1px solid rgba(212,168,75,.4); color: var(--cream); }
.btn-danger, button.danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .35rem .75rem; font-size: .82rem; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data-table th, .data-table td { padding: .65rem .75rem; text-align: left; border-bottom: 1px solid rgba(255,255,255,.08); }
.data-table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge-ok { background: rgba(34,197,94,.2); color: #86efac; }
.badge-off { background: rgba(239,68,68,.15); color: #fca5a5; }
.badge-lock { background: rgba(212,168,75,.2); color: var(--gold); }

.row-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.prize-row { display: grid; grid-template-columns: 72px 1fr auto; gap: 1rem; align-items: center; padding: .85rem 0; border-bottom: 1px solid rgba(255,255,255,.08); }
.accordion { display: flex; flex-direction: column; gap: .5rem; }
.accordion-item { border: 1px solid rgba(212,168,75,.22); border-radius: 12px; overflow: hidden; background: rgba(6,18,16,.35); }
.accordion-head {
  width: 100%; text-align: left; border: 0; border-radius: 0;
  background: rgba(15,61,56,.45); color: var(--cream); padding: .85rem 1rem;
  display: flex; align-items: center; gap: .65rem; cursor: pointer; font-family: inherit; font-size: .95rem;
}
.accordion-head:hover { background: rgba(15,61,56,.65); }
.accordion-chevron { color: var(--gold); width: 1.25rem; flex-shrink: 0; }
.accordion-body { padding: .75rem 1rem 1rem; border-top: 1px solid rgba(255,255,255,.06); }
.accordion-body[hidden] { display: none; }
.accordion-prize:last-child { border-bottom: 0; }
.prize-row img { width: 72px; height: 54px; object-fit: cover; border-radius: 8px; }

.tabs { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { background: rgba(255,255,255,.06); color: var(--cream); border: 1px solid transparent; }
.tabs button.active { background: rgba(212,168,75,.2); border-color: rgba(212,168,75,.35); color: var(--gold); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.error { color: #fca5a5; background: rgba(239,68,68,.12); padding: .65rem .85rem; border-radius: 8px; margin-bottom: 1rem; display: none; }
.hint { color: var(--muted); font-size: .85rem; margin-top: .35rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.checkbox-grid { display: grid; gap: .5rem; margin-top: .75rem; }
.checkbox-grid label { display: flex; align-items: center; gap: .5rem; margin: 0; font-weight: 400; cursor: pointer; }
.checkbox-grid input { width: auto; }

/* ——— Móvil admin ——— */
.admin-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  margin-right: .75rem;
  flex-shrink: 0;
  border: 1px solid rgba(212, 168, 75, .35);
  border-radius: 10px;
  background: rgba(6, 18, 16, .45);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.admin-menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  margin: 0 auto;
  background: var(--cream);
  border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}
body.admin-sidebar-open .admin-menu-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.admin-sidebar-open .admin-menu-toggle span:nth-child(2) { opacity: 0; }
body.admin-sidebar-open .admin-menu-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.admin-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(6, 18, 16, .55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
body.admin-sidebar-open .admin-sidebar-backdrop { display: block; }

.admin-topbar-left {
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1;
}
.admin-topbar-left h1 {
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-user { font-size: .8rem; text-align: right; flex-shrink: 0; max-width: 42%; }

@media (max-width: 768px) {
  body.admin-app { overflow-x: hidden; }
  body.admin-sidebar-open { overflow: hidden; }

  .admin-menu-toggle { display: flex; }

  .admin-app { flex-direction: row; }
  .admin-sidebar {
    position: fixed;
    z-index: 210;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(var(--sidebar-w), 88vw);
    max-width: 300px;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 8px 0 32px rgba(0, 0, 0, .35);
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  body.admin-sidebar-open .admin-sidebar { transform: translateX(0); }

  .admin-nav {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: .15rem;
    overflow-y: auto;
    max-height: calc(100vh - 180px);
    -webkit-overflow-scrolling: touch;
  }
  .admin-nav a {
    flex: 0 0 auto;
    min-width: 0;
    min-height: 44px;
    padding: .75rem .85rem;
  }

  .admin-main { width: 100%; min-height: 100vh; }
  .admin-topbar {
    padding: .75rem max(1rem, env(safe-area-inset-right)) .75rem max(1rem, env(safe-area-inset-left));
    padding-top: max(.75rem, env(safe-area-inset-top));
    gap: .5rem;
  }
  .admin-content {
    padding: 1rem max(1rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: .35rem;
    padding-bottom: .35rem;
    margin-bottom: .85rem;
    scrollbar-width: thin;
  }
  .tabs button {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 44px;
    padding: .55rem 1rem;
  }

  .card { padding: 1rem; border-radius: 12px; }
  .card-header-row { flex-direction: column; align-items: stretch; }
  .card-header-row button { width: 100%; min-height: 44px; }

  .form-grid { grid-template-columns: 1fr; }
  .prize-row { grid-template-columns: 56px 1fr; grid-template-rows: auto auto; }
  .prize-row .row-actions { grid-column: 1 / -1; }

  .data-table { font-size: .85rem; min-width: 520px; }
  .table-wrap {
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .row-actions button { min-height: 40px; }

  .ber-modal-overlay, .ber-dialog-overlay { padding: max(.5rem, env(safe-area-inset-top)) max(.5rem, env(safe-area-inset-right)) max(.5rem, env(safe-area-inset-bottom)) max(.5rem, env(safe-area-inset-left)); align-items: flex-end; }
  .ber-modal, .ber-dialog {
    max-height: min(92vh, 100%);
    border-radius: 16px 16px 0 0;
  }
  .ber-modal-footer, .ber-dialog-actions { flex-direction: column-reverse; }
  .ber-modal-footer button, .ber-dialog-actions button { width: 100%; min-height: 44px; }

  #berToastContainer {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }
  .ber-toast { max-width: none; width: 100%; }

  .login-page { padding: max(1.25rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left)); }
  .login-card { padding: 1.5rem; }
  .login-card input, .login-card button { min-height: 48px; font-size: 16px; }

  input, textarea, select { font-size: 16px; }
}

/* Loader, modal, diálogo, toast (patrón VHM) */
.ber-modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 500;
  background: rgba(6, 18, 16, .72); align-items: center; justify-content: center; padding: 16px;
}
.ber-modal-overlay.open { display: flex; }
.ber-modal {
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  background: rgba(15, 61, 56, .96); border: 1px solid rgba(212, 168, 75, .28);
  border-radius: 16px; box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
  animation: berModalIn .2s ease;
}
.ber-modal.lg { max-width: 640px; }
@keyframes berModalIn { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.ber-rich-wrap { margin-bottom: .75rem; }
.ber-rich-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .35rem;
  padding: .45rem .5rem; border: 1px solid rgba(212, 168, 75, .22);
  border-radius: 10px 10px 0 0; background: rgba(6, 18, 16, .35);
}
.ber-rich-cmd, .ber-rich-emoji-toggle {
  border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .06);
  color: var(--cream); border-radius: 6px; padding: .25rem .5rem; font-size: .8rem; cursor: pointer;
}
.ber-rich-cmd:hover, .ber-rich-emoji-toggle:hover { border-color: rgba(212, 168, 75, .4); color: var(--gold); }
.ber-rich-sep { width: 1px; height: 1.25rem; background: rgba(255, 255, 255, .12); margin: 0 .25rem; }
.ber-rich-body {
  min-height: 120px; max-height: 220px; overflow-y: auto;
  padding: .65rem .75rem; border: 1px solid rgba(212, 168, 75, .22); border-top: 0;
  border-radius: 0 0 10px 10px; background: rgba(6, 18, 16, .45);
  line-height: 1.5; font-size: .95rem;
}
.ber-rich-body:focus { outline: 2px solid rgba(212, 168, 75, .35); outline-offset: 0; }
.ber-rich-body ul { margin: .35rem 0 .35rem 1.25rem; padding: 0; }
.ber-emoji-popover {
  margin-top: .5rem; padding: .65rem; max-height: 180px; overflow-y: auto;
  border: 1px solid rgba(212, 168, 75, .25); border-radius: 10px; background: rgba(6, 18, 16, .55);
}
.ber-emoji-group-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .35rem 0 .25rem; }
.ber-emoji-grid { display: flex; flex-wrap: wrap; gap: .2rem; }
.ber-emoji-btn {
  border: 0; background: transparent; font-size: 1.25rem; line-height: 1; padding: .2rem; cursor: pointer; border-radius: 6px;
}
.ber-emoji-btn:hover { background: rgba(212, 168, 75, .2); }

.ber-rich-body-full { min-height: 160px; max-height: 280px; }
.ber-rich-select {
  border: 1px solid rgba(255, 255, 255, .12); background: rgba(255, 255, 255, .06);
  color: var(--cream); border-radius: 6px; padding: .25rem .35rem; font-size: .75rem; max-width: 7rem;
}
.ber-rich-color {
  display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; color: var(--muted); cursor: pointer;
}
.ber-rich-color input[type="color"] {
  width: 28px; height: 28px; padding: 0; border: 1px solid rgba(255, 255, 255, .15); border-radius: 6px; background: transparent;
}
.ber-rich-source {
  width: 100%; min-height: 160px; max-height: 280px; margin-top: 0;
  font-family: ui-monospace, monospace; font-size: .8rem;
  padding: .65rem .75rem; border: 1px solid rgba(212, 168, 75, .22); border-top: 0;
  border-radius: 0 0 10px 10px; background: rgba(6, 18, 16, .55); color: var(--cream);
}
.ber-rich-html-toggle { font-size: .72rem !important; }
.table-thumb { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; }
.step-modal-preview {
  display: block; max-width: 100%; max-height: 140px; object-fit: cover;
  border-radius: 8px; margin: .5rem 0; border: 1px solid rgba(212, 168, 75, .25);
}
.ber-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.ber-modal-title { font-weight: 700; font-size: 1.05rem; color: var(--gold); }
.ber-modal-close {
  background: transparent; border: 0; color: var(--muted); font-size: 1.5rem; line-height: 1; cursor: pointer; padding: 0 .25rem;
}
.ber-modal-close:hover { color: var(--cream); }
.ber-modal-body { padding: 1.25rem; }
.ber-modal-footer {
  display: flex; gap: .5rem; justify-content: flex-end; padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.card-header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-header-row h2 { margin: 0; }

#berToastContainer {
  position: fixed; bottom: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.ber-toast {
  padding: 12px 18px; border-radius: 10px; color: #fff; font-size: .85rem; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35); animation: berToastIn .2s ease; min-width: 220px; max-width: 360px;
}
@keyframes berToastIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.ber-toast-success { background: var(--teal-light); border: 1px solid rgba(212, 168, 75, .35); }
.ber-toast-danger { background: var(--danger); }
.ber-toast-info { background: rgba(212, 168, 75, .85); color: var(--ink); }

.ber-loader {
  display: none; position: fixed; inset: 0; z-index: 10000;
  background: rgba(6, 18, 16, .55); align-items: center; justify-content: center;
}
.ber-loader.open { display: flex; }
.ber-loader-box {
  background: rgba(15, 61, 56, .98); border: 1px solid rgba(212, 168, 75, .28);
  border-radius: 14px; padding: 1.5rem 1.75rem; min-width: 200px; text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .4);
}
.ber-loader-spinner {
  width: 36px; height: 36px; margin: 0 auto 12px;
  border: 3px solid rgba(255, 255, 255, .12); border-top-color: var(--gold);
  border-radius: 50%; animation: berSpin .7s linear infinite;
}
@keyframes berSpin { to { transform: rotate(360deg); } }
.ber-loader-text { font-size: .9rem; font-weight: 600; color: var(--cream); }
body.ber-loading { overflow: hidden; }

.ber-dialog-overlay {
  display: none; position: fixed; inset: 0; z-index: 10001;
  background: rgba(6, 18, 16, .72); align-items: center; justify-content: center; padding: 16px;
}
.ber-dialog-overlay.open { display: flex; }
.ber-dialog {
  width: 100%; max-width: 420px;
  background: rgba(15, 61, 56, .98); border: 1px solid rgba(212, 168, 75, .28);
  border-radius: 14px; padding: 1.25rem 1.35rem; box-shadow: 0 20px 56px rgba(0, 0, 0, .45);
}
.ber-dialog-title { font-size: 1.05rem; font-weight: 700; color: var(--gold); margin-bottom: .65rem; }
.ber-dialog-body { font-size: .92rem; line-height: 1.5; color: var(--cream); margin-bottom: 1rem; white-space: pre-wrap; }
.ber-dialog-input {
  width: 100%; margin-bottom: 1rem; padding: .55rem .75rem; border-radius: 8px;
  border: 1px solid rgba(212, 168, 75, .25); background: rgba(6, 18, 16, .45); color: var(--cream);
}
.ber-dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; flex-wrap: wrap; }
.ber-dialog-actions #berDialogConfirm:not(.btn-danger) {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim)); color: var(--ink); border: 0;
  padding: .5rem 1rem; border-radius: 8px; font-weight: 600; cursor: pointer;
}
.ber-modal-footer #berModalSave:not(.btn-danger) {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim)); color: var(--ink); border: 0;
  padding: .5rem 1rem; border-radius: 8px; font-weight: 600; cursor: pointer;
}
