/* ============================================================
   FRUVER - Variables de tema (cargadas dinámicamente)
   ============================================================ */
:root {
  --primary:    #1a3a5c;
  --primary-lt: #2563eb;
  --accent:     #f59e0b;
  --success:    #16a34a;
  --danger:     #dc2626;
  --warning:    #d97706;
  --bg:         #f1f5f9;
  --surface:    #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --text-muted: #64748b;
  --sidebar-w:  220px;
  /* Tokens de forma y tipografia alineados con generalFormat (30-jul-2026). Fruver usaba
     'Open Sans' fija y radios propios (9/10/12px), asi que el POS se veia de otra familia que
     el resto de productos aunque compartieran la paleta. Se declaran como variables -no
     escritas a mano en cada regla- para que el dia que el POS venda tipografia configurable
     baste con servirlas desde la BD, como hace la base. */
  --radius:       8px;
  --font-body:    "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-heading: "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-size:    14px;
}

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: var(--font-size);
}

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s ease;
}
/* Brand del sidebar - mismo patrón que generalFormat y conjuntos: el LOGO del cliente
   (no un emoji nuestro) + el nombre que viene de la BD. El producto es white-label: un
   icono fijo le pone nuestra marca encima a su sistema (regla de oro 10). */
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.10);
  display: flex;
  align-items: center;
  gap: 11px;
}
.sidebar-brand img {
  width: 38px; height: 38px;
  object-fit: contain;
  border-radius: var(--radius);
  background: rgba(255,255,255,.12);
  padding: 4px;
}
.brand-text   { font-size: .92rem; font-weight: 800; color: #fff; line-height: 1.15; }
.brand-accent { color: var(--accent); }

.sidebar-nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.45);
  padding: 12px 16px 4px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  color: rgba(255,255,255,.82);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.08);
  border-left-color: var(--accent);
  color: #fff;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-icon { display: inline-flex; width: 18px; justify-content: center; flex-shrink: 0; }

/* Banner "Administrando X" DENTRO del sidebar (staff dentro de una tienda), no como banner
   superior - calca a generalFormat. */
.admin-banner {
  margin: 8px 12px;
  padding: 8px 12px;
  background: rgba(245,158,11,.15);
  border: 1px solid rgba(245,158,11,.4);
  border-radius: var(--radius);
  color: rgba(255,255,255,.85);
  font-size: 11px;
  line-height: 1.3;
}
.admin-banner strong { color: var(--accent); font-size: 13px; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 12px;
  color: rgba(255,255,255,.55);
}
.sidebar-footer strong { display: block; color: rgba(255,255,255,.85); font-size: 13px; }

/* ── Main content ── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* min-width:0 es OBLIGATORIO, no cosmético: un flex item vale por defecto
     min-width:auto, o sea el ancho de su contenido. Sin esto, una tabla ancha
     estira .main-content por encima del viewport en móvil y el overflow-x:auto
     de .table-wrap NUNCA se activa - el wrapper queda de adorno y la página
     entera scrollea en horizontal. */
  min-width: 0;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); }

.page-content { padding: 24px; flex: 1; }

/* ── Cards / Panels ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Stat cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-sub   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-lt); }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary-lt); }
.input-group { display: flex; gap: 0; }
.input-group input { border-radius: 6px 0 0 6px; }
.input-group .btn  { border-radius: 0 6px 6px 0; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }
.badge-muted   { background: #f1f5f9; color: var(--text-muted); }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Hamburger (mobile) ── */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text);
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 150;
}

/* ── Alerts / Toast ── */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 9999;
  opacity: 0;
  transform: translateY(20px);
  transition: all .25s;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.danger  { background: var(--danger); }
.toast.warning { background: var(--warning); }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Fondo claro (menos desgaste visual): base azul muy pálida + glow sutil de marca en la
     esquina. Alineado a generalFormat/conjuntos, en vez del degradado azul oscuro anterior. */
  background:
    radial-gradient(circle at bottom right, color-mix(in srgb, var(--primary) 14%, transparent) 0%, transparent 42%),
    linear-gradient(160deg, #f7faff 0%, #eef4fd 55%, #e7f0fc 100%);
}
/* Tamaños y espacios calcados de generalFormat/conjuntos (login unificado). */
.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 36px 32px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.login-logo { text-align: center; margin-bottom: 20px; }
.login-logo img { max-height: 60px; max-width: 180px; object-fit: contain; }
.login-logo h1 { font-size: 1rem; font-weight: 700; color: var(--text); margin: 0 0 4px; }
.login-logo p  { font-size: 0.72rem; color: var(--text-muted); margin: 0 0 22px; }
/* Labels e inputs del login calcados de generalFormat (solo dentro de .login-card, para no
   alterar el resto de formularios del POS, que ya están en producción). */
.login-card .form-group { margin-bottom: 16px; }
.login-card label { font-size: 0.75rem; color: var(--text); margin-bottom: 5px; }
.login-card input { font-size: 0.82rem; }
.btn-login { width: 100%; background: var(--primary); color: #fff; padding: 10px 22px; border-radius: var(--radius); font-size: 0.9rem; font-weight: 600; border: none; cursor: pointer; }
.btn-login:hover { background: var(--primary-lt); }

/* ── POS specific ── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  height: calc(100vh - 57px);
  padding: 16px;
  overflow: hidden;
}
.pos-left { display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.pos-right { display: flex; flex-direction: column; gap: 12px; overflow: hidden; }

.pos-search {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.pos-search .search-row { display: flex; gap: 8px; }
.pos-search input {
  flex: 1;
  font-size: 16px;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
}
.pos-search input:focus { border-color: var(--primary-lt); }
.search-results {
  margin-top: 10px;
  max-height: 200px;
  overflow-y: auto;
  display: none;
}
.search-results.open { display: block; }
.search-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: var(--radius);
  border-bottom: 1px solid var(--border);
}
.search-item:hover { background: #f1f5f9; }
.search-item-name { font-weight: 600; font-size: 13px; }
.search-item-precio { color: var(--primary-lt); font-weight: 700; }
.search-item-unidad { font-size: 11px; color: var(--text-muted); }

.pos-cart {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pos-cart-header {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cart-items { flex: 1; overflow-y: auto; padding: 8px 0; }
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid #f1f5f9;
}
.cart-item:last-child { border-bottom: none; }
.cart-item-name { font-size: 13px; font-weight: 600; }
.cart-item-detail { font-size: 11px; color: var(--text-muted); }
.cart-qty {
  display: flex;
  align-items: center;
  gap: 4px;
}
.cart-qty button {
  width: 24px; height: 24px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cart-qty input {
  width: 48px;
  text-align: center;
  padding: 2px 4px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.cart-item-total { font-weight: 700; font-size: 13px; white-space: nowrap; }
.cart-item-del { color: var(--danger); cursor: pointer; background: none; border: none; font-size: 16px; }

.pos-totals {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.total-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
  color: var(--text-muted);
}
.total-row.grand {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  border-top: 2px solid var(--border);
  margin-top: 8px;
  padding-top: 10px;
}
.descuento-row { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.descuento-row input { width: 70px; text-align: right; }

.pago-section { display: flex; flex-direction: column; gap: 8px; }
.metodo-btns { display: flex; gap: 6px; }
.metodo-btn {
  flex: 1;
  padding: 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  transition: all .15s;
}
.metodo-btn.active { border-color: var(--primary); background: #e8eef7; color: var(--primary); }

.btn-cobrar {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 800;
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s;
}
.btn-cobrar:hover { background: #15803d; }
.btn-cobrar:disabled { background: var(--text-muted); cursor: not-allowed; }

.btn-cancelar-venta {
  width: 100%;
  padding: 9px;
  font-size: 13px;
  font-weight: 600;
  background: #fee2e2;
  color: var(--danger);
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  cursor: pointer;
}

/* ── Alert sin caja ── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 12px;
}
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #14532d; border: 1px solid #86efac; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0; }
  .hamburger { display: block; }
  .pos-layout { grid-template-columns: 1fr; height: auto; }
  .pos-right { order: -1; }
}
