/* ============================================================
   Gourmetería San José POS — estilos
   Blanco / azul marino #000080 / azul acento #1565c0 (del logo)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@500;600;700&family=Source+Sans+3:wght@400;600;700&display=swap');

:root {
  --navy: #000080;
  --navy-dark: #000060;
  --navy-08: rgba(0, 0, 128, .08);
  --navy-15: rgba(0, 0, 128, .15);
  --gold: #1565c0;
  --white: #ffffff;
  --bg: #ffffff;
  --bg-soft: #f6f7fb;
  --text: #1b1b2f;
  --muted: #6a6f85;
  --danger: #b3261e;
  --ok: #1a7d3c;
  --radius: 10px;
  --font-display: 'Barlow', system-ui, sans-serif;
  --font-body: 'Source Sans 3', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

h1, h2, h3, .display { font-family: var(--font-display); color: var(--navy); }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px;
  background: var(--navy);
  border-bottom: 3px solid var(--gold);
}
.topbar img.logo { height: 64px; filter: brightness(0) invert(1); }
.topbar .spacer { flex: 1; }
.topbar .user-chip {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; color: #fff;
}
.topbar .user-chip small { color: rgba(255,255,255,.72); font-weight: 400; display: block; }
.topbar .btn { border-color: #fff; color: #fff; background: transparent; }
.topbar .btn:hover { background: rgba(255,255,255,.14); }
.topbar .badge { background: rgba(255,255,255,.18); color: #fff; }
.topbar .badge.ok { background: rgba(140,230,175,.3); color: #ecfff4; }
.topbar a.btn { text-decoration: none; }

/* ---------- Navegación admin ---------- */
.nav {
  display: flex; gap: 4px; padding: 0 20px;
  background: var(--white); border-bottom: 1px solid var(--navy-15);
  overflow-x: auto;
}
.nav a {
  padding: 12px 16px; text-decoration: none; color: var(--muted);
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  border-bottom: 3px solid transparent; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .04em;
}
.nav a.active, .nav a:hover { color: var(--navy); border-bottom-color: var(--gold); }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius);
  border: 1.5px solid var(--navy); background: var(--white); color: var(--navy);
  font-weight: 700; font-family: var(--font-display); font-size: 14px;
  transition: background .12s, color .12s;
}
.btn:hover { background: var(--navy-08); }
.btn.primary { background: var(--navy); color: var(--white); }
.btn.primary:hover { background: var(--navy-dark); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(179,38,30,.08); }
.btn.big { padding: 16px 22px; font-size: 17px; width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 5px; color: var(--navy); font-size: 13.5px; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1.5px solid #c9cde0; background: var(--white);
}
.field input:focus, .field select:focus { outline: 2px solid var(--navy); outline-offset: 1px; border-color: var(--navy); }

/* ---------- Tarjetas / tablas ---------- */
.card {
  background: var(--white); border: 1px solid var(--navy-15);
  border-radius: var(--radius); padding: 18px;
}
.card h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid #e8eaf2; }
th {
  font-family: var(--font-display); font-size: 12.5px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted); border-bottom: 2px solid var(--navy-15);
}
tr:hover td { background: var(--bg-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.kpi { border-left: 4px solid var(--gold); }
.kpi .label { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.kpi .value { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--navy); margin-top: 4px; }
.kpi .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 700; }
.badge.navy { background: var(--navy-08); color: var(--navy); }
.badge.ok { background: rgba(26,125,60,.1); color: var(--ok); }
.badge.rojo { background: rgba(179,38,30,.1); color: var(--danger); }

/* Barras de gráfica simples */
.bar-row { display: grid; grid-template-columns: 110px 1fr 90px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13.5px; }
.bar-track { background: var(--bg-soft); border-radius: 6px; height: 22px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--navy); border-radius: 6px; min-width: 2px; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--navy); }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(10,10,40,.45);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-back.open { display: flex; }
.modal {
  background: var(--white); border-radius: 14px; border-top: 5px solid var(--navy);
  width: 100%; max-width: 460px; padding: 22px; max-height: 92vh; overflow-y: auto;
}
.modal h2 { margin-bottom: 14px; font-size: 20px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: var(--white); padding: 12px 22px;
  border-radius: 99px; font-weight: 600; display: none; z-index: 99;
  box-shadow: 0 6px 20px rgba(0,0,64,.3);
}
#toast.error { background: var(--danger); }
#toast.show { display: block; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--white);
  background-image: linear-gradient(var(--navy-08) 1px, transparent 1px),
                    linear-gradient(90deg, var(--navy-08) 1px, transparent 1px);
  background-size: 48px 48px;
}
.login-card {
  background: var(--white); border: 1px solid var(--navy-15); border-top: 5px solid var(--navy);
  border-radius: 16px; padding: 36px; width: 100%; max-width: 400px;
  box-shadow: 0 14px 40px rgba(0,0,64,.12); text-align: center;
}
.login-card img { width: 94%; margin-bottom: 8px; }
.login-card .tag {
  font-family: var(--font-display); text-transform: uppercase; letter-spacing: .18em;
  color: var(--gold); font-weight: 700; font-size: 12px; margin-bottom: 24px;
}
.login-card form { text-align: left; }

/* ---------- POS ---------- */
.pos-layout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  /* minmax(0,1fr) fija la fila a la altura de pantalla y evita que crezca con
     el contenido; así el carrito scrollea y los totales quedan siempre fijos */
  grid-template-rows: minmax(0, 1fr);
  height: calc(100vh - 87px);
}
.pos-left { padding: 12px; overflow-y: auto; background: var(--bg-soft); }
.pos-right {
  background: var(--white); border-left: 1px solid var(--navy-15);
  display: flex; flex-direction: column; overflow: hidden;
}
#buscador {
  width: 100%; padding: 9px 14px; font-size: 15px; border-radius: var(--radius);
  border: 2px solid var(--navy); margin-bottom: 8px;
}
.cat-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.cat-btn {
  padding: 5px 12px; border-radius: 99px; border: 1.5px solid var(--navy-15);
  background: var(--white); color: var(--muted); font-weight: 600; font-size: 13px;
}
.cat-btn.active { background: var(--navy); border-color: var(--navy); color: var(--white); }

.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
.prod-card {
  background: var(--white); border: 1px solid var(--navy-15); border-radius: 8px;
  padding: 8px 10px; cursor: pointer; transition: border-color .1s, transform .05s;
  display: flex; flex-direction: column; gap: 2px; text-align: left;
}
.prod-card:hover { border-color: var(--navy); }
.prod-card:active { transform: scale(.98); }
.prod-card .nombre { font-weight: 600; font-size: 13px; line-height: 1.2; }
.prod-card .precio { font-family: var(--font-display); font-weight: 700; color: var(--navy); font-size: 15px; }
.prod-card .meta { font-size: 11px; color: var(--muted); }

.carrito-head {
  padding: 14px 16px; border-bottom: 2px solid var(--navy);
  font-family: var(--font-display); font-weight: 700; color: var(--navy);
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}
/* min-height:0 permite que el carrito se encoja y scrollee en vez de empujar
   los totales fuera de pantalla cuando la lista es larga */
#carrito { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 12px; }
/* Fila del carrito: una sola línea larga y delgada — nombre | controles | importe.
   Letra chica para que el cliente lea claro todo lo que lleva. */
.linea {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px;
  padding: 4px 10px; border-bottom: 1px solid #eef0f6;
}
.linea .nombre { font-weight: 600; font-size: 12px; line-height: 1.2; }
.linea .importe {
  font-weight: 700; color: var(--navy); text-align: right; font-size: 13px;
  font-variant-numeric: tabular-nums; order: 3; min-width: 62px;
}
.linea .controles { display: flex; align-items: center; gap: 4px; order: 2; }
.linea .controles button {
  width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--navy-15);
  background: var(--white); font-weight: 700; color: var(--navy); font-size: 13px;
  display: flex; align-items: center; justify-content: center;
}
.linea .controles input.cant {
  width: 46px; text-align: center; padding: 2px; border: 1.5px solid #c9cde0; border-radius: 6px; font-size: 11.5px;
}
.linea .controles span { font-size: 10.5px !important; white-space: nowrap; }
.linea .controles .quitar { color: var(--danger); border-color: transparent; background: none; font-size: 14px; }
.pos-totales { padding: 14px 16px; border-top: 2px solid var(--navy); background: var(--bg-soft); flex-shrink: 0; }
.tot-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 15px; }
.tot-row.grande { font-family: var(--font-display); font-size: 28px; font-weight: 700; color: var(--navy); }

.pago-metodos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.pago-btn { padding: 12px 6px; border-radius: var(--radius); border: 1.5px solid var(--navy-15); background: var(--white); font-weight: 700; color: var(--muted); }
.pago-btn.active { border-color: var(--navy); background: var(--navy-08); color: var(--navy); }
.cambio-display { font-family: var(--font-display); font-size: 30px; font-weight: 700; color: var(--ok); text-align: center; margin: 8px 0; }

/* ---------- Ticket (impresión térmica 80mm) ---------- */
#ticket { display: none; }
/* (Se eliminó un bloque global @media print del ticket que era código muerto
   y se colaba en otras páginas —como Etiquetas— rompiendo su impresión. El
   ticket del POS se imprime en su propio iframe con estilos propios, y cada
   página que imprime —Etiquetas— define su propio @media print.) */

/* ---------- Layout general admin ---------- */
.page { padding: 20px; max-width: 1200px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; }
.page-head .spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mt { margin-top: 16px; }

@media (max-width: 900px) {
  .pos-layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; height: auto; }
  .pos-right { border-left: none; border-top: 2px solid var(--navy); }
  .grid-2 { grid-template-columns: 1fr; }
}
