/* ============================================================
   KioscoPOS — Estilos Globales
   ============================================================ */

:root {
  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-light: #818cf8;
  --success:       #22c55e;
  --danger:        #ef4444;
  --warning:       #f59e0b;
  --info:          #06b6d4;

  --bg-dark:       #0f1117;
  --bg-sidebar:    #1a1d27;
  --bg-card:       #1e2130;
  --bg-input:      #252840;
  --bg-hover:      #2a2e42;

  --text:          #e2e8f0;
  --text-muted:    #64748b;
  --text-dim:      #94a3b8;

  --border:        #2d3148;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 4px 24px rgba(0,0,0,.4);

  --sidebar-w:     240px;
  --topbar-h:      60px;
}

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

html { font-size: 15px; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  display: flex;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s ease;
  border-right: 1px solid var(--border);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}
.sidebar-logo { font-size: 1.6rem; }
.sidebar-title { font-weight: 700; font-size: 1.05rem; color: var(--primary-light); flex: 1; }
.sidebar-close { display: none; background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .5rem; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  font-size: .88rem;
  transition: all .15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-item .nav-icon { font-size: 1.1rem; width: 22px; text-align: center; }

.nav-separator {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: .75rem 1rem .25rem;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem;
  flex-shrink: 0;
}
.user-name { font-size: .85rem; font-weight: 600; }
.user-role { font-size: .72rem; color: var(--text-muted); }
.btn-logout {
  margin-left: auto;
  background: none; border: none;
  color: var(--text-muted); font-size: 1.1rem;
  cursor: pointer; text-decoration: none;
  padding: .25rem;
}
.btn-logout:hover { color: var(--danger); }

/* ---- OVERLAY MOBILE ---- */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 199;
}
.sidebar-overlay.show { display: block; }

/* ---- TOPBAR ---- */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  z-index: 100;
}
.menu-toggle {
  display: none;
  background: none; border: none;
  color: var(--text); font-size: 1.3rem;
  cursor: pointer;
}
.topbar-title { font-size: 1rem; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.caja-status { font-size: .78rem; padding: .25rem .7rem; border-radius: 20px; }
.caja-status.open   { background: rgba(34,197,94,.15); color: var(--success); }
.caja-status.closed { background: rgba(239,68,68,.15); color: var(--danger); }
.fecha-hora { color: var(--text-muted); font-size: .82rem; }

/* ---- MAIN ---- */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 1.5rem;
  flex: 1;
  min-height: calc(100vh - var(--topbar-h));
}

/* ---- CARDS ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.card-title { font-size: 1rem; font-weight: 600; }

/* ---- STATS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
}
.stat-label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .5rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; }
.stat-sub   { font-size: .75rem; color: var(--text-muted); margin-top: .2rem; }
.stat-up   { color: var(--success); }
.stat-down { color: var(--danger); }

/* ---- TABLAS ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  padding: .65rem .9rem;
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody td { padding: .65rem .9rem; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .82rem; color: var(--text-dim); margin-bottom: .35rem; }
.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .55rem .9rem;
  font-size: .9rem;
  outline: none;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--primary); }
select.form-control option { background: var(--bg-dark); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ---- BOTONES ---- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 600;
  border: none; cursor: pointer;
  text-decoration: none;
  transition: all .15s;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.9); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.9); }
.btn-warning  { background: var(--warning); color: #000; }
.btn-secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary-light); }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1rem; padding: .25rem; }
.btn-icon:hover { color: var(--text); }

/* ---- BADGES ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: .15rem .55rem;
  border-radius: 20px;
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase;
}
.badge-success { background: rgba(34,197,94,.15); color: var(--success); }
.badge-danger  { background: rgba(239,68,68,.15); color: var(--danger); }
.badge-warning { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-info    { background: rgba(6,182,212,.15); color: var(--info); }
.badge-primary { background: rgba(99,102,241,.15); color: var(--primary-light); }

/* ---- ALERTS ---- */
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .88rem; }
.alert-danger  { background: rgba(239,68,68,.15); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.alert-success { background: rgba(34,197,94,.15);  color: #86efac;  border: 1px solid rgba(34,197,94,.3); }
.alert-warning { background: rgba(245,158,11,.15); color: #fcd34d;  border: 1px solid rgba(245,158,11,.3); }
.alert-info    { background: rgba(6,182,212,.15);  color: #67e8f9;  border: 1px solid rgba(6,182,212,.3); }

/* ---- MODAL ---- */
.modal-bg {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-body   { padding: 1.25rem; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: .75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; }

/* ---- TABS ---- */
.tabs { display: flex; gap: .25rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.tab {
  padding: .6rem 1.25rem;
  font-size: .88rem; font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  transition: all .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-light); border-bottom-color: var(--primary); }

/* ---- POS ESPECÍFICO ---- */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 1rem; height: calc(100vh - var(--topbar-h) - 3rem); }
.pos-products { overflow-y: auto; }
.pos-cart { display: flex; flex-direction: column; overflow: hidden; }

.search-bar { position: relative; margin-bottom: 1rem; }
.search-bar input { padding-left: 2.5rem; }
.search-bar .search-icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

.category-pills { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.pill {
  padding: .3rem .85rem;
  border-radius: 20px;
  font-size: .78rem; font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  transition: all .15s;
}
.pill:hover, .pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem .75rem;
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.product-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.product-card:active { transform: scale(.97); }
.product-name { font-size: .82rem; font-weight: 600; margin-bottom: .3rem; line-height: 1.3; }
.product-price { font-size: 1rem; font-weight: 700; color: var(--primary-light); }
.product-stock { font-size: .7rem; color: var(--text-muted); margin-top: .2rem; }

.cart-items { flex: 1; overflow-y: auto; padding: .25rem 0; }
.cart-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
}
.cart-item-name { flex: 1; font-size: .85rem; font-weight: 500; }
.cart-item-qty { display: flex; align-items: center; gap: .3rem; }
.qty-btn {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text);
  cursor: pointer; font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
}
.qty-btn:hover { background: var(--primary); border-color: var(--primary); }
.cart-item-subtotal { font-size: .85rem; font-weight: 700; min-width: 75px; text-align: right; }
.cart-item-delete { color: var(--text-muted); font-size: .9rem; cursor: pointer; }
.cart-item-delete:hover { color: var(--danger); }

.cart-total { border-top: 2px solid var(--border); padding: 1rem 0; }
.total-row { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: .35rem; color: var(--text-dim); }
.total-row.final { font-size: 1.3rem; font-weight: 800; color: var(--text); }

/* ---- PAGO ---- */
.payment-methods { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin: 1rem 0; }
.pay-method {
  padding: .75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  font-size: .82rem; font-weight: 600;
  transition: all .15s;
}
.pay-method:hover { border-color: var(--primary-light); }
.pay-method.selected { border-color: var(--primary); background: rgba(99,102,241,.15); color: var(--primary-light); }
.pay-method .pay-icon { font-size: 1.4rem; display: block; margin-bottom: .2rem; }

/* ---- CHARTS ---- */
.chart-wrap { position: relative; height: 260px; }

/* ---- DASHBOARD GRID ---- */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }

/* ---- PROGRESS BAR ---- */
.progress { background: var(--bg-hover); border-radius: 20px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; background: var(--primary); transition: width .5s; }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .topbar { left: 0; }
  .menu-toggle { display: block; }
  .main-content { margin-left: 0; }
  .pos-layout { grid-template-columns: 1fr; height: auto; }
  .pos-cart { min-height: 420px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .main-content { padding: 1rem .75rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .products-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- UTIL ---- */
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--primary-light) !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; } .gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
