/* ============================================================
   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;
}

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

body {
  font-family: 'Open Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ── 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;
}
.sidebar-brand {
  padding: 18px 16px 14px;
  font-size: 17px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.12);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-brand .logo-text   { color: #fff; }
.sidebar-brand .logo-accent { color: var(--accent); }
.sidebar-brand img.logo-img {
  width: 32px; height: 32px;
  object-fit: contain;
  border-radius: 6px;
}

.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; }

.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;
}

.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: 10px;
  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: 10px;
  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: 6px;
  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: 6px;
  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: 12px;
  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: 8px;
  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;
  background: linear-gradient(135deg, var(--primary) 0%, #0f2540 100%);
}
.login-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 40px 36px;
  width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--primary); }
.login-logo p  { font-size: 13px; color: var(--text-muted); }
.btn-login { width: 100%; background: var(--primary); color: #fff; padding: 11px; border-radius: 6px; font-size: 14px; 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: 10px;
  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: 8px;
}
.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: 6px;
  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: 10px;
  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: 10px;
  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: 8px;
  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: 8px;
  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: 8px;
  cursor: pointer;
}

/* ── Alert sin caja ── */
.alert {
  padding: 14px 18px;
  border-radius: 8px;
  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; }
}
