:root {
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-card: #1c2029;
  --border: #2a2f3a;
  --text: #eef0f4;
  --text-dim: #a3aab8;
  --gold: #c9a24b;
  --gold-soft: #e4c876;
  --purple: #6d5ef7;
  --blue: #4fa3d1;
  --green: #3ec98a;
  --red: #e2555a;
  --radius: 12px;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at top, #181c25 0%, #0f1115 55%);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  min-height: 100vh;
}

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

.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* -------------------- Nav -------------------- */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  background: rgba(15,17,21,0.85); backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 20;
}
.navbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .5px; }
.navbar .brand .mark { color: var(--gold); font-size: 1.4rem; }
.brand .logo-fid {
  height: 38px; width: auto; border-radius: 7px; display: block;
  box-shadow: 0 0 0 1px rgba(255,255,255,.06);
}
.brand .logo-divider { width: 1px; height: 26px; background: var(--border); }
.brand .logo-imss {
  height: 26px; width: auto; display: block; border-radius: 5px;
  background: #fff; padding: 3px 5px;
}
.brand .brand-label { white-space: nowrap; }
@media (max-width: 640px) {
  .brand .brand-label { display: none; }
}
.navbar nav { display: flex; gap: 20px; align-items: center; font-size: .92rem; }
.navbar nav a { color: var(--text-dim); }
.navbar nav a:hover { color: var(--gold-soft); text-decoration: none; }

/* -------------------- Buttons -------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px; border: 1px solid transparent;
  font-size: .95rem; font-weight: 600; cursor: pointer; transition: transform .1s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--gold-soft), var(--gold)); color: #22160a; }
.btn-primary:hover { opacity: .92; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--gold); color: var(--gold-soft); }
.btn-danger { background: var(--red); color: white; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn-block { width: 100%; }

/* -------------------- Cards -------------------- */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px;
}
.card-hover { transition: transform .15s ease, border-color .15s ease; }
.card-hover:hover { transform: translateY(-3px); border-color: var(--gold); }

.grid { display: grid; gap: 20px; }
.grid > * { min-width: 0; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }

.evento-card { display: flex; flex-direction: column; padding-bottom: 16px; }
.evento-card-link { display: block; color: inherit; }
.evento-card-link:hover { text-decoration: none; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
}
.badge-imss { background: rgba(79,163,209,.18); color: var(--blue); }
.badge-tercero { background: rgba(201,162,75,.18); color: var(--gold-soft); }

/* Banner del evento: recorte 16:9 en las tarjetas de la cartelera, con un
   fondo genérico cuando el evento aún no tiene imagen cargada desde admin. */
.evento-banner-wrap {
  margin: -20px -20px 14px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-top-left-radius: calc(var(--radius) - 1px);
  border-top-right-radius: calc(var(--radius) - 1px);
  background: linear-gradient(135deg, #1c2030, #14161f);
  display: flex; align-items: center; justify-content: center;
}
.evento-banner-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.evento-banner-placeholder { font-size: 2.4rem; opacity: .3; }

/* Banner grande (hero) en la página de detalle del evento */
.evento-hero-wrap {
  aspect-ratio: 21 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 16px 0 24px;
  background: linear-gradient(135deg, #1c2030, #14161f);
  display: flex; align-items: center; justify-content: center;
}
.evento-hero-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.evento-hero-wrap .evento-banner-placeholder { font-size: 3.4rem; }
@media (max-width: 640px) {
  .evento-hero-wrap { aspect-ratio: 16 / 9; }
}

/* -------------------- Forms -------------------- */
label { display: block; font-size: .85rem; color: var(--text-dim); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-elevated); color: var(--text); font-size: .95rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* -------------------- Misc -------------------- */
.muted { color: var(--text-dim); }
.hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.center { text-align: center; }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8{margin-top:8px;} .mt-16{margin-top:16px;} .mt-24{margin-top:24px;} .mt-32{margin-top:32px;}
.mb-8{margin-bottom:8px;} .mb-16{margin-bottom:16px;} .mb-24{margin-bottom:24px;}

.section-title { font-size: 1.5rem; font-weight: 700; margin: 0 0 4px; }
.section-sub { color: var(--text-dim); margin: 0 0 20px; }

.kpi { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.kpi .value { font-size: 1.9rem; font-weight: 800; color: var(--gold-soft); }
.kpi .label { color: var(--text-dim); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
tr:hover td { background: rgba(255,255,255,.02); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--bg-elevated); border: 1px solid var(--border); padding: 12px 20px;
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.4); z-index: 100; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.error { border-color: var(--red); color: #ffb3b3; }
.toast.success { border-color: var(--green); color: #b8f5d6; }

.timer {
  font-variant-numeric: tabular-nums; font-weight: 700; color: var(--gold-soft);
  border: 1px solid var(--gold); border-radius: 999px; padding: 6px 14px; font-size: .9rem;
}
.timer.warning { color: var(--red); border-color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.55;} }

/* -------------------- Seat map -------------------- */
.stage {
  text-align: center; padding: 14px; margin-bottom: 24px; border-radius: 10px;
  background: linear-gradient(180deg, rgba(201,162,75,.16), transparent);
  border: 1px solid var(--border); letter-spacing: .3em; font-size: .8rem; color: var(--gold-soft);
  text-transform: uppercase; font-weight: 700;
}
.seccion-plano { margin-bottom: 20px; }
.seccion-plano h4 { margin: 0 0 8px; color: var(--text-dim); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.fila-plano { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.fila-label { width: 22px; color: var(--text-dim); font-size: .75rem; text-align: right; flex-shrink: 0; }
.asientos-row { display: flex; gap: 5px; flex-wrap: wrap; }
.asiento {
  width: 26px; height: 26px; border-radius: 6px; font-size: .62rem; display: flex; align-items: center;
  justify-content: center; cursor: pointer; border: 1px solid transparent; color: #0f1115; font-weight: 700;
  user-select: none; transition: transform .1s ease;
}
.asiento:hover:not(.ocupado):not(.bloqueado) { transform: scale(1.15); }
.asiento.disponible { background: #3a4152; color: #cfd4de; }
.asiento.seleccionado { background: var(--green); color: #062015; }
.asiento.ocupado { background: #4a2b2d; color: #8a5c5f; cursor: not-allowed; }
.asiento.bloqueado { background: #33363f; color: #5c606b; cursor: not-allowed; }
.leyenda { display: flex; gap: 18px; flex-wrap: wrap; font-size: .8rem; color: var(--text-dim); margin: 16px 0; }
.leyenda .chip { display: inline-flex; align-items: center; gap: 6px; }
.leyenda .dot { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

.status-pill { padding: 4px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; }
.status-valido, .status-verde { background: rgba(62,201,138,.18); color: var(--green); }
.status-usado, .status-ya_utilizado { background: rgba(226,85,90,.18); color: var(--red); }
.status-invalido { background: rgba(226,85,90,.3); color: #ffb3b3; }

footer { text-align: center; padding: 40px 20px; color: var(--text-dim); font-size: .82rem; }

/* -------------------- Barra inferior (tabbar) tipo app -------------------- */
.tabbar {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(23,26,33,0.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around; align-items: stretch;
}
.tabbar-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--text-dim); font-size: .68rem; font-weight: 600;
  padding: 6px 4px; border-radius: 10px; flex: 1; min-width: 0;
}
.tabbar-item:hover { text-decoration: none; }
.tabbar-item .tabbar-icon { font-size: 1.25rem; line-height: 1; }
.tabbar-item.active { color: var(--gold-soft); }

/* -------------------- Responsivo / formato de app para celular -------------------- */
@media (max-width: 860px) {
  /* Las cuadrículas de dos columnas (detalle + panel lateral) se apilan.
     grid-cards y grid-stats mantienen su propio acomodo responsivo. */
  .grid:not(.grid-cards):not(.grid-stats) { grid-template-columns: 1fr !important; }
  .field-row { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
  :root { font-size: 15px; }
  .container { padding: 0 16px; }
  .navbar { padding: 12px 16px; }
  .section-title { font-size: 1.28rem; }

  /* En las páginas del comprador, la navegación pasa a la barra inferior. */
  body.app-mobile .navbar nav.solo-escritorio { display: none; }
  body.app-mobile { padding-bottom: 76px; }
  body.app-mobile .tabbar { display: flex; }

  /* En los portales (admin/promotor/acceso) la nav de arriba se envuelve
     en vez de desbordar la pantalla. */
  .navbar nav:not(.solo-escritorio) { flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; gap: 12px; }

  .card { padding: 16px; }
  table { font-size: .82rem; }
  th, td { padding: 8px; }
  .kpi .value { font-size: 1.5rem; }

  /* Botones más cómodos para el dedo */
  .btn { padding: 12px 18px; }
  input, select, textarea { font-size: 16px; } /* evita zoom automático de iOS al enfocar */
}

.scroll-hint { display: none; color: var(--text-dim); font-size: .78rem; margin: -8px 0 12px; }

@media (max-width: 640px) {
  /* El mapa de butacas se desliza horizontalmente por fila en vez de
     amontonarse en muchas líneas: así se ve y se usa como el plano de un
     teatro real, igual en celular que en escritorio. */
  #plano { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px 4px; min-width: 0; }
  .asientos-row { flex-wrap: nowrap; }
  .asiento { flex-shrink: 0; }
  .fila-label { flex-shrink: 0; }
  .scroll-hint { display: block; }
  .stage { letter-spacing: .18em; font-size: .72rem; }
}
