@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* =============================================
   TOKENS / VARIABLES (Paleta oficial del logo de Alianza)
   ============================================= */
:root {
  --bg-dark:          #f8fafc;
  --bg-card:          #ffffff;
  --bg-card2:         #f1f5f9;
  --border:           #e2e8f0;
  
  /* Colores del Logo Oficial */
  --brand-red:        #dc2626;
  --brand-red-hover:  #b91c1c;
  --brand-red-glow:   rgba(220,38,38,0.06);
  
  --brand-blue:       #003d6d;
  --brand-blue-hover: #00294a;
  --brand-blue-glow:  rgba(0,61,109,0.06);
  
  --brand-gold:       #d97706;
  --brand-gold-glow:  rgba(217,119,6,0.06);

  /* Variables Generales */
  --accent:           var(--brand-red);
  --accent-hover:     var(--brand-red-hover);
  --accent-glow:      var(--brand-red-glow);
  --green:            #16a34a;
  --green-bg:         rgba(22,163,74,0.06);
  --red:              var(--brand-red);
  --red-bg:           var(--brand-red-glow);
  --yellow:           var(--brand-gold);
  --yellow-bg:        var(--brand-gold-glow);
  
  --text:             #0f172a;
  --text-muted:       #475569;
  --text-dim:         #94a3b8;
  --radius:           12px;
  --radius-sm:        8px;
  --shadow:           0 4px 20px rgba(15,23,42,0.04);
  --shadow-hover:     0 12px 30px rgba(0,61,109,0.08);
  --transition:       0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input, select, textarea { font-family: inherit; outline: none; }

/* =============================================
   SCROLLBAR
   ============================================= */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; border: 2.5px solid var(--bg-dark); }

/* =============================================
   LAYOUT
   ============================================= */
.app-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 60px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

/* TOPBAR */
.topbar {
  grid-column: 1 / -1;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-red), var(--text-dim), var(--brand-red));
  background-size: 200% 100%;
  animation: topbarBorderAnim 4s linear infinite;
}
@keyframes topbarBorderAnim {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 200% 0%;
  }
}
.topbar-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-brand span { color: var(--text-muted); font-weight: 400; font-size: 13px; }
.topbar-logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  background: white;
  padding: 2px;
  border-radius: 50%;
  border: 1px solid var(--border);
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.badge-usuario {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 500;
}
.badge-rol {
  background: var(--accent-glow);
  color: var(--accent);
  border-radius: 99px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* SIDEBAR */
.sidebar {
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  text-decoration: none;
  border-left: 4px solid transparent;
}

.nav-icon {
  display: none !important;
}

/* Color único rojo para hover y active en la barra lateral */
.nav-item:hover {
  background: rgba(220, 38, 38, 0.05) !important;
  color: var(--brand-red) !important;
  border-left-color: var(--brand-red) !important;
}
.nav-item.active {
  background: rgba(220, 38, 38, 0.08) !important;
  color: var(--brand-red) !important;
  border-left-color: var(--brand-red) !important;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 16px;
}

/* MAIN CONTENT */
.main-content {
  padding: 28px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.main-content > * {
  flex-shrink: 0;
}


/* =============================================
   CARDS
   ============================================= */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* =============================================
   STAT CARDS
   ============================================= */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-value.green { color: var(--green); }
.stat-value.accent { color: var(--accent); }
.stat-icon { font-size: 24px; margin-bottom: 4px; }

/* =============================================
   BOTONES
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 20px var(--accent-glow); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-card2); color: var(--text); }
.btn-green { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.btn-green:hover { background: var(--green); color: #fff; }
.btn-red { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.btn-red:hover { background: var(--red); color: #fff; }
.btn-yellow { background: var(--yellow-bg); color: var(--yellow); border: 1px solid rgba(245,158,11,0.3); }
.btn-yellow:hover { background: var(--yellow); color: #fff; }
.btn-lg { padding: 13px 24px; font-size: 15px; border-radius: var(--radius); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* =============================================
   FORMULARIOS
   ============================================= */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  transition: var(--transition);
  width: 100%;
}
input.form-control, select.form-control {
  height: 42px;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-control::placeholder { color: var(--text-dim); }
.form-control-lg { padding: 13px 16px; font-size: 16px; border-radius: var(--radius); }
input.form-control-lg, select.form-control-lg {
  height: 50px;
}
.form-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }

/* =============================================
   TABLAS
   ============================================= */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--bg-dark);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: var(--transition); }
tbody tr:hover { background: var(--bg-card2); }
tbody tr:last-child { border-bottom: none; }
tbody td { padding: 11px 14px; color: var(--text); }

/* =============================================
   BADGES
   ============================================= */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-blue { background: var(--accent-glow); color: var(--accent); }

/* =============================================
   TOAST / NOTIFICACIONES
   ============================================= */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}
.toast {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 18px;
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  font-size: 14px;
}
.toast.success { border-color: rgba(34,197,94,0.4); }
.toast.error { border-color: rgba(239,68,68,0.4); }
.toast-icon { font-size: 18px; }
@keyframes slideIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* =============================================
   LOGIN PAGE
   ============================================= */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(rgba(13, 15, 20, 0.65), rgba(13, 15, 20, 0.75)), url('/img/junta.jpg') no-repeat center center / cover;
}
.login-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  color: #0f172a;
}
.login-logo {
  text-align: center;
  margin-bottom: 24px;
}
.login-logo-img {
  width: 90px;
  height: 90px;
  object-fit: contain;
  background: white;
  padding: 8px;
  border-radius: 50%;
  border: 2px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  margin: 0 auto 16px;
  display: block;
}
.login-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
}
.login-logo p {
  font-size: 13px;
  color: #475569;
  margin-top: 4px;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-error {
  background: var(--red-bg);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--red);
  display: none;
}

/* =============================================
   POS / VENTAS RAPIDAS
   ============================================= */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  height: calc(100vh - 60px - 56px);
}
.pos-search-bar {
  position: relative;
  margin-bottom: 16px;
}
.pos-search-bar input {
  padding-left: 44px;
  font-size: 16px;
  height: 50px;
}
.pos-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--text-dim);
  pointer-events: none;
}
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  overflow-y: auto;
  max-height: 100%;
}
.product-btn {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}
.product-btn:hover { border-color: var(--accent); background: var(--accent-glow); transform: translateY(-2px); }
.product-btn.out-of-stock { opacity: 0.4; cursor: not-allowed; }
.product-btn-name { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.3; }
.product-btn-price { font-size: 15px; font-weight: 700; color: var(--green); }
.product-btn-stock { font-size: 11px; color: var(--text-muted); }

/* CARRITO */
.cart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.cart-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
}
.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cart-item {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cart-item-name { font-size: 13px; font-weight: 500; flex: 1; }
.cart-item-controls { display: flex; align-items: center; gap: 6px; }
.qty-btn {
  width: 26px;
  height: 26px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}
.qty-btn:hover { background: var(--accent); border-color: var(--accent); }
.qty-value { font-size: 14px; font-weight: 600; min-width: 24px; text-align: center; }
.cart-item-total { font-size: 13px; font-weight: 600; color: var(--green); min-width: 60px; text-align: right; }
.cart-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cart-total-line {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 700;
}
.cart-total-line span:last-child { color: var(--green); }
.pago-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.pago-btn {
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-dark);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.pago-btn.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }

/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow);
  animation: scaleIn 0.2s ease;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; color: var(--text-muted); font-size: 20px; cursor: pointer; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { display: flex; flex-direction: column; gap: 14px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* =============================================
   UTILIDADES
   ============================================= */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-accent { color: var(--accent); }
.font-bold { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }

/* =============================================
   CATEGORIA CHIPS
   ============================================= */
.category-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.chip {
  padding: 6px 14px;
  border-radius: 99px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.22s ease;
}
.chip:hover {
  background: var(--brand-red-glow);
  border-color: var(--brand-red);
  color: var(--brand-red);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(220, 38, 38, 0.08);
}
.chip.active {
  background: var(--brand-red-glow);
  border-color: var(--brand-red);
  color: var(--brand-red);
  font-weight: 700;
  transform: translateY(-1px);
}

/* =============================================
   ELEGANT INTERACTIVITY & BRAND ANIMATIONS
   ============================================= */

/* Botones Premium con escala al presionar y sombras dinámicas */
.btn {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.btn:active {
  transform: scale(0.96);
}
.btn-primary:hover {
  background: var(--brand-red-hover);
  box-shadow: 0 8px 24px rgba(220, 38, 38, 0.2);
}

/* Tarjetas e indicadores con efectos 3D sutiles y línea de gradiente superior */
.card {
  position: relative;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--brand-blue);
}

.stat-card {
  position: relative;
  overflow: hidden;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(to right, var(--brand-red), var(--brand-blue), var(--brand-gold));
  opacity: 0;
  transition: all 0.22s ease;
}
.stat-card:hover::before {
  opacity: 1;
}
.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-hover);
  border-color: var(--brand-blue);
}

/* Tablas interactivas con indicador de borde izquierdo en fila */
tbody tr {
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}
tbody tr:hover {
  background: var(--bg-card2);
  border-left: 3px solid var(--brand-blue);
}

/* Scrollbar interactivo con colores de marca */
::-webkit-scrollbar-thumb {
  background: var(--border);
  transition: background 0.3s ease;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--brand-blue);
}

/* Campos de entrada con foco brillante azul de la UTP */
.form-control:focus {
  border-color: var(--brand-blue) !important;
  box-shadow: 0 0 0 4px var(--brand-blue-glow) !important;
  background: #ffffff;
}

/* Efectos de Hover para enlaces de la barra lateral */
.nav-item {
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-item:hover {
  transform: translateX(4px);
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .pos-layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
}
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  body { background: white; color: black; }
  .card { border: 1px solid #ddd; }
}
