/* ════════════════════════════════════════════════════════
   GIR PMS — Componentes
   ════════════════════════════════════════════════════════ */

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

body {
  background: var(--canvas);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── SHELL ─────────────────────────────────────── */
#shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }

/* ── SIDEBAR ───────────────────────────────────── */
#side {
  background: var(--ink); color: #C3CCD5;
  padding: 16px 0; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.logo { display: flex; align-items: center; gap: 9px; padding: 4px 18px 18px; }
.logo .mark {
  width: 26px; height: 26px; border-radius: var(--r-sm); flex: none;
  background: linear-gradient(145deg, var(--brass-br), var(--brass));
  display: flex; align-items: center; justify-content: center;
  color: #1A1206; font-weight: 800; font-size: 13px;
  overflow: hidden;
}
/* A real logo shows on its own — no box — so a transparent PNG stays clean. */
.logo .mark.has-logo { background: none; box-shadow: none; border-radius: 0; }
.logo .mark.has-logo img { object-fit: contain !important; }
.logo .nm { color: #fff; font-family: var(--serif); font-weight: 600; font-size: 17px; letter-spacing: .005em; }

.navgrp {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em;
  text-transform: uppercase; color: #65727F; padding: 14px 18px 6px;
}
.nav {
  display: flex; align-items: center; gap: 10px; width: calc(100% - 16px);
  margin: 1px 8px; padding: 8px 12px; font-size: 13.5px; font-family: inherit;
  color: #B4BFC9; background: none; border: none; border-radius: 9px;
  cursor: pointer; text-align: left; transition: background .12s, color .12s;
}
.nav .ic { width: 16px; text-align: center; opacity: .85; flex: none; }
.nav:hover { background: var(--ink-2); color: #fff; }
/* Active item: a soft pill tinted in the hotel's accent, with a gold edge. */
.nav.on {
  background: linear-gradient(90deg, var(--accent-soft), rgba(0,0,0,0));
  color: var(--brass-br); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--brass);
}
.nav.on .ic { color: var(--brass-br); opacity: 1; }
.nav .tag {
  margin-left: auto; font-family: var(--mono); font-size: 10px;
  background: var(--crit); color: #fff; padding: 1px 5px; border-radius: 4px; font-weight: 700;
}

/* ── MAIN ──────────────────────────────────────── */
#main { background: var(--surface-2); min-width: 0; display: flex; flex-direction: column; }

#topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 20px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
#topbar .h { font-family: var(--serif); font-size: 18px; font-weight: 600; letter-spacing: .005em; }
#topbar .sub { font-size: 12px; color: var(--text-3); }
#topbar .right { display: flex; align-items: center; gap: 8px; }

#view { padding: 18px 20px 32px; display: flex; flex-direction: column; gap: 16px; }

/* ── BUTTONS ───────────────────────────────────── */
.btn {
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 7px 13px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); cursor: pointer;
}
.btn:hover { border-color: var(--text-3); color: var(--text); }
.btn.pri { background: var(--brass); border-color: var(--brass); color: #fff; }
.btn.pri:hover { filter: brightness(1.08); color: #fff; }

/* ── CARDS ─────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden;
}
.card > h3 {
  font-family: var(--serif); font-size: 15px; font-weight: 600; padding: 13px 14px;
  border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card > h3 .more { font-family: var(--mono); font-size: 10px; color: var(--brass); font-weight: 600; }
.card .pad { padding: 14px; }

.grid2 { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; }

/* ── KPIs ──────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.kpi .k {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3);
}
.kpi .v {
  font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: -.01em;
  margin-top: 5px; font-variant-numeric: tabular-nums; line-height: 1.05;
}
.kpi .d { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.kpi .d.up { color: var(--ok); font-weight: 600; }

/* ── ROWS (listas de llegadas, avisos…) ────────── */
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-bottom: 1px solid var(--line-2); font-size: 13px;
}
.row:last-child { border-bottom: none; }
.av {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--brass-lt); color: var(--brass);
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 750;
}
.row .who { flex: 1; min-width: 0; }
.row .who b { font-weight: 650; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .who span { font-size: 11.5px; color: var(--text-3); }

/* ── PILLS (estado) ────────────────────────────── */
.pill {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .05em;
  text-transform: uppercase; font-weight: 700;
  padding: 3px 7px; border-radius: 5px; white-space: nowrap;
}
.p-ok    { background: var(--ok-bg);    color: var(--ok); }
.p-info  { background: var(--info-bg);  color: var(--info); }
.p-crit  { background: var(--crit-bg);  color: var(--crit); }
.p-brass { background: var(--brass-lt); color: var(--brass); }

/* ── EMOJI PICKER ──────────────────────────────── */
.emoji-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.emoji-opt {
  width: 34px; height: 34px; font-size: 17px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
  cursor: pointer; transition: border-color .12s, background .12s;
}
.emoji-opt:hover { border-color: var(--brass); }
.emoji-opt.on { border-color: var(--brass); background: var(--brass-lt); box-shadow: 0 0 0 1px var(--brass) inset; }

/* ── ROOM RACK ─────────────────────────────────── */
.rack { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 7px; padding: 14px; }
.rm {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 7px; text-align: center; background: var(--surface-2);
}
.rm .n { font-family: var(--serif); font-size: 14px; font-weight: 600; }
.rm .s {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .05em;
  text-transform: uppercase; margin-top: 3px; font-weight: 700;
}
.rm.free  { border-color: var(--ok); }
.rm.free .s { color: var(--ok); }
.rm.occ   { background: var(--ink); border-color: var(--ink); }
.rm.occ .n { color: #fff; }
.rm.occ .s { color: var(--brass-br); }
.rm.dirty { border-color: var(--crit); background: var(--crit-bg); }
.rm.dirty .s { color: var(--crit); }
.rm.out   { opacity: .5; }

/* ── TABLES ────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-3); font-weight: 650;
  text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line);
}
table.tbl td { padding: 9px 14px; border-bottom: 1px solid var(--line-2); }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── EMPTY STATE (módulos aún por construir) ───── */
.empty {
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--r); padding: 44px 24px; text-align: center;
}
.empty .ic { font-size: 30px; opacity: .5; }
.empty h4 { font-size: 16px; font-weight: 700; margin: 10px 0 5px; }
.empty p { font-size: 13.5px; color: var(--text-3); max-width: 46ch; margin: 0 auto; }

/* ── BILLING BANNER ────────────────────────────── */
#billing {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 20px; font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--line);
}
#billing[hidden] { display: none; }
#billing .cta { margin-left: auto; }
#billing.info { background: var(--surface); color: var(--text-2); font-weight: 500; }
#billing.warn { background: var(--brass-lt); color: var(--brass); }
#billing.crit { background: var(--crit-bg); color: var(--crit); }

/* Paywall: trial over / payment failed */
#paywall {
  position: fixed; inset: 0; background: rgba(14,19,24,.75);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 200;
}
#paywall .box {
  background: var(--surface); border-radius: var(--r-lg); padding: 34px 32px;
  max-width: 560px; width: 100%; box-shadow: var(--shadow); text-align: center;
}
#paywall h2 { font-size: 22px; font-weight: 750; margin-bottom: 8px; }
#paywall p { color: var(--text-2); font-size: 14.5px; margin-bottom: 22px; }

/* Plan cards */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.plan {
  border: 1px solid var(--line); border-radius: var(--r); padding: 18px;
  background: var(--surface-2); text-align: left;
}
.plan.on { border-color: var(--brass); border-width: 2px; background: var(--surface); }
.plan .nm { font-size: 12px; font-family: var(--mono); letter-spacing: .08em;
            text-transform: uppercase; color: var(--text-3); }
.plan .pr { font-size: 24px; font-weight: 750; margin: 5px 0 2px; font-variant-numeric: tabular-nums; }
.plan .li { font-size: 12.5px; color: var(--text-3); }

/* ── FORM CONTROLS ─────────────────────────────── */
.inp, select.inp, textarea.inp {
  width: 100%; font-family: inherit; font-size: 13.5px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text);
}
.inp:focus { outline: none; border-color: var(--brass); }
.lbl { display: block; font-size: 11.5px; font-weight: 700; color: var(--text-2); margin-bottom: 5px; }
.field { display: flex; flex-direction: column; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

/* ── MODAL ─────────────────────────────────────── */
.backdrop {
  position: fixed; inset: 0; background: rgba(14, 19, 24, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 32px 16px; z-index: 100; overflow-y: auto;
}
.modal {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow);
  width: 100%; max-width: 760px;
}
.modal header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal header h3 { font-family: var(--serif); font-size: 17px; font-weight: 600; }
.modal .content { padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.modal footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 18px; border-top: 1px solid var(--line); background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.x { background: none; border: none; font-size: 20px; color: var(--text-3); cursor: pointer; line-height: 1; }

/* Errores de validación */
.errbox {
  background: var(--crit-bg); color: var(--crit); border: 1px solid var(--crit);
  border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px; font-weight: 600;
}
.errbox ul { margin: 0; padding-left: 18px; font-weight: 500; }

/* Totales de la factura */
.totals { display: flex; flex-direction: column; gap: 5px; margin-left: auto; min-width: 260px; font-size: 13.5px; }
.totals .t { display: flex; justify-content: space-between; gap: 20px; }
.totals .t span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.totals .t.grand {
  border-top: 2px solid var(--brass); margin-top: 6px; padding-top: 8px;
  font-size: 17px; font-weight: 750;
}

/* ── STAFF LOCK (PIN) — branded, elegant ───────── */
#lock {
  position: fixed; inset: 0; z-index: 300;
  background: linear-gradient(160deg, #1F2A24, #141A16);   /* overridden inline per hotel */
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#lock .lockwrap { width: 100%; max-width: 340px; text-align: center; }
#lock .lock-logo {
  width: 116px; height: 116px; margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 46px; font-weight: 800; color: #fff;
}
#lock .lock-logo img { width: 100%; height: 100%; object-fit: contain; }
/* A real logo shows on its own — no box — so a transparent PNG stays clean. */
#lock .lock-logo.has-logo { width: 132px; height: 132px; }
#lock .lock-name { color: #fff; font-family: var(--serif); font-size: 24px; font-weight: 600; letter-spacing: .005em; }
#lock .lock-hint { color: rgba(255,255,255,.72); font-size: 13.5px; margin: 6px 0 26px; }
#lock .pin-in {
  width: 100%; text-align: center; font-size: 26px; letter-spacing: .4em;
  font-variant-numeric: tabular-nums; padding: 15px; color: #fff;
  border: 1px solid rgba(255,255,255,.22); border-radius: 15px;
  background: rgba(255,255,255,.10);
}
#lock .pin-in::placeholder { color: rgba(255,255,255,.40); }
#lock .pin-in:focus { outline: none; border-color: rgba(255,255,255,.55); background: rgba(255,255,255,.16); }
#lock .pin-err { color: #FFD5CE; font-size: 12.5px; font-weight: 600; margin-top: 12px; }
#lock .pin-people { color: rgba(255,255,255,.55); font-size: 12px; margin-top: 26px; line-height: 1.7; }
#lock .lock-owner {
  background: none; border: none; color: rgba(255,255,255,.80); font: inherit; font-size: 12.5px;
  cursor: pointer; margin-top: 22px; text-decoration: underline;
}
#lock .lock-owner:hover { color: #fff; }
/* Sidebar foot: lock button + user profile pinned to the bottom */
.side-foot { margin-top: auto; padding-top: 8px; }
.nav.lock-btn { color: #8894A0; }
.side-user {
  display: flex; align-items: center; gap: 10px;
  margin: 6px 8px 2px; padding: 9px 10px; border-radius: 10px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06);
}
.su-av {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: linear-gradient(145deg, var(--brass-br), var(--brass)); color: #1A1206;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 750;
}
.su-info { flex: 1; min-width: 0; }
.su-name { color: #EDF1F5; font-size: 12.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-role { color: #7E8A96; font-size: 10.5px; }
.su-gear {
  background: none; border: none; color: #8894A0; font-size: 15px; cursor: pointer;
  flex: none; padding: 4px; border-radius: 6px;
}
.su-gear:hover { color: #fff; background: var(--ink-2); }

/* ── KITCHEN TICKET (print) ────────────────────── */
#print-area { display: none; }
.ticket { font-family: var(--mono, monospace); color: #000; }
.ticket h2 { font-size: 20px; font-weight: 800; margin: 0 0 4px; }
.ticket .meta { font-size: 12px; letter-spacing: .04em; }
.ticket hr { border: none; border-top: 1px dashed #000; margin: 8px 0; }
.ticket .tline { display: flex; gap: 10px; font-size: 16px; margin: 5px 0; }
.ticket .tline .q { font-weight: 800; min-width: 34px; }
.ticket .tline .nm { flex: 1; }
.ticket .tline .amt { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ticket .tline em { font-size: 13px; }
.ticket .receipt .tline.sum { font-size: 14px; }
.ticket .tline.grand { font-size: 18px; font-weight: 800; border-top: 1px solid #000; padding-top: 5px; margin-top: 5px; }
.ticket .foot { font-size: 11px; text-align: center; margin-top: 6px; }
@media print {
  /* Kitchen ticket / receipt / welcome card: <body> gets .has-print while a
     #print-area is on the page (set in js/print.js). We key off that class, not
     :has(), because some mobile browsers don't support :has() — and without it
     nothing was hidden, so the whole app page printed. */
  body.has-print * { visibility: hidden; }
  body.has-print #print-area, body.has-print #print-area * { visibility: visible !important; }
  body.has-print #print-area { display: block !important; position: absolute; top: 0; left: 0; width: 100%; padding: 8px; }

  /* Otherwise (a report / normal print): drop the app chrome, print the content. */
  body:not(.has-print) #side,
  body:not(.has-print) #topbar,
  body:not(.has-print) #billing { display: none !important; }
  body:not(.has-print) #shell { grid-template-columns: 1fr !important; }
  body:not(.has-print) #main { background: #fff; }
  body:not(.has-print) #view { padding: 6px 0; gap: 12px; }
  body:not(.has-print) .card,
  body:not(.has-print) .kpi { break-inside: avoid; box-shadow: none; }
  body:not(.has-print) #rp-month { display: none; }   /* the selector isn't useful on paper */
}

/* ── RESPONSIVE ────────────────────────────────── */
@media (max-width: 900px) {
  #shell { grid-template-columns: 1fr; }
  #side {
    position: static; height: auto; flex-direction: row; overflow-x: auto;
    align-items: center; padding: 8px; gap: 4px;
  }
  .navgrp { display: none; }
  .logo { flex: none; padding: 6px 12px; align-items: center; gap: 8px; }
  .logo .mark { width: 30px; height: 30px; }
  .logo .nm { font-size: 16px; white-space: nowrap; }
  .nav { width: auto; margin: 0; border-radius: 0; box-shadow: none;
         border-bottom: 2px solid transparent; white-space: nowrap; padding: 8px 12px; }
  .nav.on { box-shadow: none; background: var(--ink-2); border-bottom-color: var(--brass); }
  .side-foot { margin-top: 0; padding-top: 0; display: flex; align-items: center; }
  .side-user { display: none; }
  .grid2 { grid-template-columns: 1fr; }
}
