/* =====================================================================
   Evie Hair POS — hoja de estilos unica
   ===================================================================== */

:root {
  --bg:        #16110f;
  --surface:   #211a17;
  --surface-2: #2c2320;
  --line:      #3b302b;
  --text:      #f5ede8;
  --muted:     #a89890;
  --accent:    #c9a227;
  --accent-dk: #a3821b;
  --ok:        #4caf7d;
  --warn:      #e0a33c;
  --danger:    #d9534f;
  --radius:    14px;
  --shadow:    0 10px 30px rgba(0,0,0,.35);
  --font:      system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted  { color: var(--muted); }
.error  { color: var(--danger); min-height: 1.2em; font-size: .9rem; }
.right  { text-align: right; }
.center { text-align: center; }

/* ---------- LOGIN ---------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}
.login-card h1 { margin: 0; font-size: 1.9rem; letter-spacing: -.02em; }
.login-card h1 span { color: var(--accent); }
.login-card p.muted { margin: -10px 0 8px; }

label {
  display: grid;
  gap: 6px;
  font-size: .85rem;
  color: var(--muted);
}

input, select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
textarea { resize: vertical; min-height: 70px; }

/* ---------- BOTONES ---------- */
.btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  padding: 10px 16px;
  transition: .15s;
}
.btn:hover  { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #241c05;
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-dk); }
.btn.ghost   { background: transparent; }
.btn.danger  { color: var(--danger); }
.btn.small   { padding: 6px 11px; font-size: .85rem; }
.btn.block   { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- TOPBAR ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-wrap: wrap;
}
.brand { font-size: 1.25rem; font-weight: 700; letter-spacing: -.02em; }
.brand span { color: var(--accent); }

.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tab {
  background: transparent;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  padding: 9px 16px;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { background: var(--surface-2); color: var(--accent); font-weight: 600; }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }

/* ---------- LAYOUT ---------- */
.split {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.card h2 { margin: 0 0 14px; font-size: 1.05rem; }
.card h3 { margin: 18px 0 10px; font-size: .95rem; color: var(--muted); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- PRODUCTOS ---------- */
.prod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.prod {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  padding: 14px;
  text-align: left;
  transition: .15s;
  color: var(--text);
  font: inherit;
}
.prod:hover { border-color: var(--accent); transform: translateY(-2px); }
.prod .largo { font-size: 1.3rem; font-weight: 700; }
.prod .color { color: var(--muted); font-size: .85rem; margin: 2px 0 8px; }
.prod .precio { color: var(--accent); font-weight: 600; }
.prod .stock { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.prod.sin-stock { opacity: .5; }
.prod .xl {
  display: inline-block;
  background: var(--accent);
  color: #241c05;
  border-radius: 5px;
  font-size: .65rem;
  font-weight: 700;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ---------- CARRITO ---------- */
.cart-items { display: grid; gap: 8px; margin-bottom: 14px; }
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
}
.cart-item .nombre { font-size: .9rem; }
.cart-item .sub { color: var(--muted); font-size: .78rem; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  height: 28px;
  width: 28px;
}
.qty input {
  width: 54px;
  padding: 4px 6px;
  text-align: center;
}

.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.quick button {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: .8rem;
  padding: 5px 10px;
}
.quick button:hover { border-color: var(--accent); color: var(--text); }

.totales {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
  display: grid;
  gap: 6px;
}
.totales .line { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted); }
.totales .line.total {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 4px;
}
.totales .line.total span:last-child { color: var(--accent); }

/* ---------- TABLAS ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.alerta td { background: rgba(217,83,79,.12); }

td input.inline {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 5px 8px;
  text-align: right;
  width: 100px;
  font-variant-numeric: tabular-nums;
}
td input.inline:hover  { border-color: var(--line); }
td input.inline:focus  { background: var(--surface-2); border-color: var(--accent); outline: none; }
td input.inline.sucio  { border-color: var(--warn); }

/* ---------- PILDORAS ---------- */
.pill {
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  padding: 3px 9px;
  display: inline-block;
  white-space: nowrap;
}
.pill.ok      { background: rgba(76,175,125,.18); color: var(--ok); }
.pill.warn    { background: rgba(224,163,60,.18); color: var(--warn); }
.pill.danger  { background: rgba(217,83,79,.18);  color: var(--danger); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }

/* ---------- KPIs ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.kpi {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 16px;
}
.kpi .label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi .valor { font-size: 1.6rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .valor.accent { color: var(--accent); }
.kpi .valor.ok     { color: var(--ok); }
.kpi .valor.danger { color: var(--danger); }

/* ---------- MODAL ---------- */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 88dvh;
  overflow-y: auto;
  padding: 22px;
  width: min(560px, 100%);
}
.modal h2 { margin: 0 0 16px; font-size: 1.1rem; }
.modal .acciones { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---------- COMPROBANTE ---------- */
.recibo {
  background: #fffdf8;
  color: #241c05;
  border-radius: 12px;
  padding: 24px;
  font-size: .9rem;
}
.recibo h3 { margin: 0; text-align: center; font-size: 1.3rem; color: #241c05; }
.recibo .ig { text-align: center; color: #7a6a45; margin: 2px 0 16px; font-size: .82rem; }
.recibo table { font-size: .85rem; }
.recibo th, .recibo td { border-bottom: 1px solid #e6dfcc; color: #241c05; }
.recibo th { color: #7a6a45; }
.recibo .total-final {
  display: flex;
  justify-content: space-between;
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 2px solid #241c05;
}

/* ---------- TOASTS ---------- */
.toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: grid;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  font-size: .9rem;
  animation: slide .2s ease;
}
.toast.ok    { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
@keyframes slide { from { opacity: 0; transform: translateX(20px); } }

.empty { color: var(--muted); padding: 28px; text-align: center; }

/* =====================================================================
   CELULAR
   La barra de abajo reemplaza a las pestañas de arriba: el pulgar llega
   ahi sin estirarse, que es como se usa esto de verdad — de pie, con el
   telefono en una mano y el cabello en la otra.
   ===================================================================== */

.navmovil { display: none; }

@media (max-width: 760px) {
  main { padding: 12px 12px 92px; }          /* espacio para la barra */

  /* --- barra superior compacta --- */
  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar .tabs { display: none; }
  .brand { font-size: 1.1rem; flex: 1; }

  /* --- barra inferior --- */
  .navmovil {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 50;
  }
  .navmovil .tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 7px 2px;
    font-size: .68rem;
    border-radius: 10px;
  }
  .navmovil .tab span { font-size: 1.15rem; line-height: 1; }
  .navmovil .tab.active { background: transparent; }

  /* --- targets tactiles y cero zoom al enfocar en iOS --- */
  input, select, textarea { font-size: 16px; padding: 12px 14px; }
  .btn { padding: 12px 18px; }
  .btn.small { padding: 9px 14px; font-size: .85rem; }

  /* --- contenido --- */
  .card { padding: 14px; border-radius: 12px; }
  .split { gap: 14px; }
  .grid-2 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
  .kpi { padding: 12px; }
  .kpi .valor { font-size: 1.3rem; }

  .prod-grid { grid-template-columns: repeat(auto-fill, minmax(115px, 1fr)); gap: 8px; }
  .prod { padding: 11px; }
  .prod .largo { font-size: 1.1rem; }

  .qty button { height: 38px; width: 38px; font-size: 1.1rem; }
  .qty input { width: 52px; }

  /* A 375 px las tres columnas no caben y el nombre se parte en pedazos.
     Nombre arriba, cantidad y precio abajo. */
  .cart-item {
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
  }
  .cart-item > :first-child { grid-column: 1 / -1; }
  .cart-item .nombre { font-size: .95rem; }

  .quick button { padding: 9px 13px; font-size: .85rem; }

  table { font-size: .85rem; }
  th, td { padding: 9px 10px; }
  td input.inline { width: 84px; padding: 9px 8px; }

  .modal { padding: 18px; border-radius: 14px; max-height: 92dvh; }
  .modal .acciones { flex-wrap: wrap; }
  .modal .acciones .btn { flex: 1; min-width: 120px; }

  .toast-root { left: 12px; right: 12px; bottom: 86px; }

  /* Probe a dejar el total pegado al fondo, pero al hacer scroll tapaba los
     botones de cantidad. Mejor que viva en su lugar, solo mas destacado. */
  #panel .totales {
    background: var(--surface-2);
    border-radius: 10px;
    margin-top: 14px;
    padding: 12px 14px;
  }
  .totales .line.total { font-size: 1.4rem; }
}

@media (max-width: 420px) {
  .prod-grid { grid-template-columns: 1fr 1fr; }
  .navmovil .tab { font-size: .62rem; }
}

@media print {
  body * { visibility: hidden; }
  .recibo, .recibo * { visibility: visible; }
  .recibo { position: absolute; inset: 0; }
}
