/* ============================================================
   MINIMERCADO - ESTILOS DEL TERMINAL POS (TABLET)
   Diseño: Modo oscuro, táctil, alto contraste, botones grandes
   Sin scrollbars innecesarios — todo cabe en pantalla
   ============================================================ */

:root {
  --pos-bg:         #0a0c10;
  --pos-panel:      #111318;
  --pos-card:       #1a1d26;
  --pos-card-2:     #1f2232;
  --pos-border:     rgba(255,255,255,.08);
  --pos-text:       #e2e8f0;
  --pos-muted:      #64748b;
  --pos-accent:     #2563eb;
  --pos-success:    #22c55e;
  --pos-warning:    #f59e0b;
  --pos-danger:     #ef4444;
  --pos-info:       #06b6d4;
  --pos-header-h:   58px;
  --pos-right-w:    340px;
  --pos-radius:     12px;
  --pos-radius-lg:  18px;
  --transition:     .18s ease;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; overflow: hidden; }

body.pos-body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--pos-bg);
  color: var(--pos-text);
  display: flex;
  flex-direction: column;
  user-select: none;
}

/* ─────────────────────────────
   HEADER
───────────────────────────── */
.pos-header {
  height: var(--pos-header-h);
  background: var(--pos-panel);
  border-bottom: 1px solid var(--pos-border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  flex-shrink: 0;
  z-index: 10;
}

.pos-header-left, .pos-header-right {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 200px;
}

.pos-header-right { justify-content: flex-end; }
.pos-header-center { flex: 1; text-align: center; }

.pos-store-name { font-size: 1.1rem; font-weight: 800; color: #fff; }
.pos-cajero     { font-size: .75rem; color: var(--pos-muted); }
.pos-transaccion { font-size: .8rem; color: var(--pos-muted); font-family: monospace; }
.pos-datetime   { font-size: .9rem; color: var(--pos-text); font-weight: 600; }

.pos-connection { font-size: .8rem; font-weight: 600; display: flex; align-items: center; gap: .35rem; }
.pos-connection.connected    { color: var(--pos-success); }
.pos-connection.disconnected { color: var(--pos-danger); }

/* ─────────────────────────────
   MAIN LAYOUT
───────────────────────────── */
.pos-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* COLUMNA IZQUIERDA */
.pos-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: .75rem;
  gap: .75rem;
}

/* COLUMNA DERECHA */
.pos-right {
  width: var(--pos-right-w);
  background: var(--pos-panel);
  border-left: 1px solid var(--pos-border);
  display: flex;
  flex-direction: column;
  padding: .75rem;
  gap: .75rem;
  overflow-y: auto;
  flex-shrink: 0;
}

/* ─────────────────────────────
   BUSCADOR
───────────────────────────── */
.pos-search-bar { flex-shrink: 0; }

.pos-search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--pos-card);
  border: 2px solid var(--pos-border);
  border-radius: var(--pos-radius-lg);
  padding: .5rem .75rem;
  gap: .75rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.pos-search-input-wrap:focus-within {
  border-color: var(--pos-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.25);
}

.pos-search-icon { font-size: 1.4rem; color: var(--pos-muted); flex-shrink: 0; }

.pos-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 1.1rem;
  font-family: inherit;
  color: var(--pos-text);
  min-width: 0;
}

.pos-search-input::placeholder { color: var(--pos-muted); }

.pos-btn-search {
  background: var(--pos-accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: .5rem 1rem;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: .02em;
  transition: filter var(--transition);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: .35rem;
}

.pos-btn-search:hover { filter: brightness(1.15); }

/* RESULTADOS DE BUSQUEDA */
.pos-search-results {
  background: var(--pos-card);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius);
  overflow: hidden;
  flex-shrink: 0;
  max-height: 260px;
  overflow-y: auto;
}

.pos-search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .5rem 1rem;
  background: var(--pos-card-2);
  font-size: .8rem;
  font-weight: 600;
  color: var(--pos-muted);
  border-bottom: 1px solid var(--pos-border);
}

.pos-close-search {
  background: none;
  border: none;
  color: var(--pos-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 .25rem;
}

.pos-search-list { display: flex; flex-direction: column; }

.pos-search-item {
  display: flex;
  align-items: center;
  padding: .75rem 1rem;
  gap: 1rem;
  border-bottom: 1px solid var(--pos-border);
  cursor: pointer;
  transition: background var(--transition);
}

.pos-search-item:hover { background: var(--pos-card-2); }
.pos-search-item:last-child { border-bottom: none; }

.pos-search-item-info { flex: 1; }
.pos-search-item-nombre { font-weight: 600; font-size: .95rem; }
.pos-search-item-codigo { font-size: .75rem; color: var(--pos-muted); font-family: monospace; }
.pos-search-item-precio { font-size: 1.1rem; font-weight: 800; color: var(--pos-success); }
.pos-search-item-stock  { font-size: .75rem; color: var(--pos-muted); }
.stock-cero { color: var(--pos-danger) !important; }

/* ─────────────────────────────
   CARRITO
───────────────────────────── */
.pos-cart-container {
  flex: 1;
  background: var(--pos-card);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.pos-cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .6rem 1rem;
  background: var(--pos-card-2);
  border-bottom: 1px solid var(--pos-border);
  font-weight: 700;
  font-size: .9rem;
  flex-shrink: 0;
}

.pos-cart-badge {
  background: var(--pos-accent);
  color: #fff;
  border-radius: 20px;
  padding: .15rem .65rem;
  font-size: .75rem;
  font-weight: 700;
}

.pos-cart-table-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
}

.pos-cart-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}

.pos-cart-table thead {
  position: sticky;
  top: 0;
  background: var(--pos-card-2);
  z-index: 1;
}

.pos-cart-table thead th {
  padding: .45rem .75rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--pos-muted);
  border-bottom: 1px solid var(--pos-border);
  white-space: nowrap;
}

.text-right { text-align: right !important; }
.text-center { text-align: center !important; }

.pos-cart-table tbody tr {
  border-bottom: 1px solid var(--pos-border);
  cursor: pointer;
  transition: background var(--transition);
}

.pos-cart-table tbody tr:hover { background: rgba(255,255,255,.03); }
.pos-cart-table tbody tr.selected { background: rgba(37,99,235,.15); }
.pos-cart-table tbody td { padding: .6rem .75rem; vertical-align: middle; }

.pos-cart-empty {
  text-align: center;
  padding: 3rem 1rem !important;
  color: var(--pos-muted);
  cursor: default !important;
}

.pos-cart-empty i {
  display: block;
  font-size: 2.5rem;
  margin-bottom: .75rem;
  opacity: .3;
}

.pos-cart-empty span { font-size: .9rem; line-height: 1.6; }
.pos-cart-desc { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pos-cart-total { font-weight: 700; color: var(--pos-success); }

.pos-badge {
  font-size: .65rem;
  background: rgba(6,182,212,.15);
  color: var(--pos-info);
  border: 1px solid rgba(6,182,212,.3);
  border-radius: 6px;
  padding: .1rem .35rem;
  font-weight: 700;
}

/* Botones de cantidad */
.pos-qty-btn {
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid var(--pos-border);
  background: var(--pos-card-2);
  color: var(--pos-text);
  font-size: 1rem;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pos-qty-btn:active { transform: scale(.9); }
.pos-qty-btn:hover  { background: rgba(255,255,255,.1); }

.pos-qty-val {
  display: inline-block;
  min-width: 36px;
  text-align: center;
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  padding: .1rem .3rem;
  border-radius: 6px;
  transition: background var(--transition);
}

.pos-qty-val:hover { background: rgba(37,99,235,.2); color: var(--pos-accent); }

/* ─────────────────────────────
   PANEL DERECHO — CARDS
───────────────────────────── */
.pos-card {
  background: var(--pos-card);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius);
  padding: .85rem;
  flex-shrink: 0;
}

.pos-card-title {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--pos-muted);
  margin-bottom: .65rem;
}

/* TIPO DE VENTA */
.pos-tipo-venta {
  display: flex;
  gap: .4rem;
  margin-bottom: .5rem;
}

.pos-tipo-btn {
  flex: 1;
  background: rgba(255,255,255,.05);
  border: 2px solid rgba(255,255,255,.1);
  border-radius: 10px;
  color: var(--pos-muted);
  font-size: .75rem;
  font-weight: 700;
  font-family: inherit;
  padding: .55rem .5rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
}

.pos-tipo-btn.active {
  background: rgba(37,99,235,.2);
  border-color: var(--pos-accent);
  color: #93c5fd;
}

.pos-tipo-btn:hover:not(.active) { background: rgba(255,255,255,.08); color: var(--pos-text); }

/* RUT SEARCH */
.pos-rut-search {
  display: flex;
  gap: .5rem;
  margin-top: .5rem;
}

.pos-input-sm {
  flex: 1;
  background: var(--pos-card-2);
  border: 1px solid var(--pos-border);
  border-radius: 8px;
  color: var(--pos-text);
  padding: .45rem .65rem;
  font-size: .85rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.pos-input-sm:focus { border-color: var(--pos-accent); }

.pos-cliente-info {
  margin-top: .5rem;
  background: rgba(37,99,235,.1);
  border: 1px solid rgba(37,99,235,.3);
  border-radius: 8px;
  padding: .5rem .75rem;
}

.pos-cliente-nombre { font-weight: 700; font-size: .95rem; color: #93c5fd; }
.pos-cliente-rut    { font-size: .8rem; color: var(--pos-muted); }
.pos-link-btn { background: none; border: none; color: var(--pos-muted); font-size: .75rem; cursor: pointer; text-decoration: underline; margin-top: .2rem; }

/* TOTALES */
.pos-totales-card { }

.pos-total-row {
  display: flex;
  justify-content: space-between;
  padding: .25rem 0;
  font-size: .85rem;
  color: var(--pos-muted);
  border-bottom: 1px solid rgba(255,255,255,.04);
}

.pos-total-final {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .65rem 0 0;
  margin-top: .25rem;
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--pos-success);
}

/* BOTONES DE ACCION */
.pos-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: .5rem;
  flex-shrink: 0;
}

.pos-btn {
  border: none;
  border-radius: var(--pos-radius);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  letter-spacing: .02em;
}

.pos-btn:active { transform: scale(.96); }

.pos-btn-primary  { background: var(--pos-accent);   color: #fff; }
.pos-btn-success  { background: #16a34a; color: #fff; }
.pos-btn-danger   { background: var(--pos-danger);   color: #fff; }
.pos-btn-warning  { background: var(--pos-warning);  color: #000; }
.pos-btn-secondary { background: rgba(255,255,255,.1); color: var(--pos-text); border: 1px solid var(--pos-border); }
.pos-btn-outline  { background: transparent; color: var(--pos-text); border: 1px solid var(--pos-border); }

.pos-btn-primary:hover  { filter: brightness(1.12); }
.pos-btn-success:hover  { filter: brightness(1.12); }
.pos-btn-danger:hover   { filter: brightness(1.12); }
.pos-btn-warning:hover  { filter: brightness(1.12); }

.pos-btn-lg  { padding: .65rem .5rem; font-size: .85rem; }
.pos-btn-xl  { padding: 1rem .5rem; font-size: 1.1rem; grid-column: 1 / -1; }
.pos-btn-full { width: 100%; }

/* Boton eliminar item */
.pos-btn-icon {
  background: transparent;
  border: 1px solid var(--pos-border);
  color: var(--pos-muted);
  width: 34px; height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
}

.pos-btn-icon:hover { color: #fff; border-color: var(--pos-danger); background: rgba(239,68,68,.2); }

.pos-btn-icon-sm {
  background: transparent;
  border: none;
  color: var(--pos-muted);
  width: 26px; height: 26px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  transition: all var(--transition);
}

.pos-btn-icon-sm.pos-btn-danger:hover { color: var(--pos-danger); background: rgba(239,68,68,.15); }

/* ─────────────────────────────
   MODALES
───────────────────────────── */
.pos-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.pos-modal {
  background: var(--pos-card);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0,0,0,.5);
}

.pos-modal-lg { max-width: 520px; }

.pos-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--pos-border);
  flex-shrink: 0;
}

.pos-modal-header h2 { font-size: 1.15rem; font-weight: 700; }

.pos-modal-close {
  background: none;
  border: none;
  color: var(--pos-muted);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.pos-modal-body { padding: 1.25rem 1.5rem; flex: 1; }
.pos-modal-subtitle { font-size: .9rem; color: var(--pos-muted); margin-bottom: 1rem; font-weight: 600; }

.pos-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--pos-border);
  flex-shrink: 0;
}

.pos-modal-footer .pos-btn { min-width: 120px; height: 48px; font-size: .9rem; }
.pos-modal-footer-stack { flex-direction: column; }
.pos-modal-footer-stack .pos-btn { min-width: unset; }

/* NUMPAD */
.pos-numpad-display {
  background: var(--pos-card-2);
  border: 2px solid var(--pos-border);
  border-radius: 12px;
  text-align: right;
  padding: .75rem 1.25rem;
  font-size: 2rem;
  font-weight: 800;
  font-family: 'Inter', monospace;
  margin-bottom: 1rem;
  letter-spacing: .04em;
  color: #fff;
}

.pos-numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
}

.pos-numpad-btn {
  height: 64px;
  background: var(--pos-card-2);
  border: 1px solid var(--pos-border);
  border-radius: 12px;
  color: var(--pos-text);
  font-size: 1.25rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.pos-numpad-btn:hover  { background: rgba(255,255,255,.1); }
.pos-numpad-btn:active { transform: scale(.93); background: var(--pos-accent); color: #fff; }
.pos-numpad-fn { background: rgba(255,255,255,.06); font-size: 1rem; color: var(--pos-muted); }

/* MODAL CONFIRMAR VENTA */
.pos-confirm-totales {
  background: var(--pos-card-2);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.pos-confirm-row {
  display: flex;
  justify-content: space-between;
  padding: .3rem 0;
  font-size: .9rem;
  color: var(--pos-muted);
  border-bottom: 1px solid rgba(255,255,255,.04);
}

.pos-confirm-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: .75rem;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--pos-success);
}

.pos-confirm-cliente {
  text-align: center;
  font-size: .9rem;
  color: var(--pos-muted);
}

/* MODAL EXITO */
.pos-modal-success {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.pos-success-icon {
  font-size: 4rem;
  color: var(--pos-success);
  margin-bottom: 1rem;
  animation: successPop .4s ease;
}

@keyframes successPop {
  0%   { transform: scale(0); opacity: 0; }
  70%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.pos-modal-success h2 { font-size: 1.8rem; font-weight: 900; margin-bottom: .5rem; }
.pos-success-trx  { font-family: monospace; font-size: 1rem; color: var(--pos-muted); margin-bottom: .5rem; }
.pos-success-total { font-size: 2.2rem; font-weight: 900; color: var(--pos-success); }

/* ─────────────────────────────
   FORMULARIOS EN POS
───────────────────────────── */
.pos-form-group { margin-bottom: .85rem; }
.pos-form-group label { display: block; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--pos-muted); margin-bottom: .35rem; }

.pos-input {
  width: 100%;
  background: var(--pos-card-2);
  border: 2px solid var(--pos-border);
  border-radius: 10px;
  color: var(--pos-text);
  padding: .7rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.pos-input:focus { border-color: var(--pos-accent); box-shadow: 0 0 0 3px rgba(37,99,235,.25); }
.pos-input::placeholder { color: rgba(100,116,139,.5); }

/* ALERTS */
.pos-alert { border-radius: 10px; padding: .65rem 1rem; font-size: .875rem; font-weight: 500; }
.pos-alert-danger  { background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.pos-alert-warning { background: rgba(245,158,11,.15); border: 1px solid rgba(245,158,11,.3); color: #fcd34d; }

/* TOAST DEL POS */
.pos-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  border: 1px solid rgba(255,255,255,.12);
  color: var(--pos-text);
  padding: .7rem 1.5rem;
  border-radius: 30px;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  z-index: 9999;
  white-space: nowrap;
  animation: fadeInUp .25s ease;
  min-width: 220px;
  text-align: center;
}

.pos-toast-success { background: #14532d; border-color: #16a34a; color: #86efac; }
.pos-toast-danger  { background: #450a0a; border-color: #ef4444; color: #fca5a5; }
.pos-toast-warning { background: #451a03; border-color: #f59e0b; color: #fcd34d; }

@keyframes fadeInUp { from { opacity:0; transform: translateX(-50%) translateY(12px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }

/* ─────────────────────────────
   LOGIN DEL POS
───────────────────────────── */
.pos-login-body {
  min-height: 100vh;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #0f172a 0%, #020617 100%);
}

.pos-login-container { width: 100%; max-width: 420px; padding: 1.5rem; }

.pos-login-card {
  background: var(--pos-card);
  border: 1px solid var(--pos-border);
  border-radius: var(--pos-radius-lg);
  padding: 2.5rem 2rem;
}

.pos-login-header { text-align: center; margin-bottom: 2rem; }
.pos-login-icon {
  font-size: 3.5rem;
  color: var(--pos-accent);
  display: block;
  margin-bottom: 1rem;
}
.pos-login-header h1 { font-size: 1.5rem; font-weight: 800; color: #fff; }
.pos-login-header p  { color: var(--pos-muted); font-size: .875rem; }

.pos-login-footer { margin-top: 1.5rem; text-align: center; }
.pos-link  { color: var(--pos-muted); font-size: .8rem; }
.pos-link:hover { color: var(--pos-text); }
.pos-login-version { font-size: .7rem; color: rgba(100,116,139,.5); margin-bottom: .5rem; }

/* ─────────────────────────────
   SCROLLBARS PERSONALIZADOS
───────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }
