

/* ---- CSS Variables ---- */
:root {
  --font-main: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'DM Mono', 'Courier New', monospace;
  --bg-primary:    #f8f9fc;
  --bg-secondary:  #ffffff;
  --bg-card:       #ffffff;
  --bg-sidebar:    #1a1f2e;
  --text-primary:  #1a1f2e;
  --text-secondary:#6b7280;
  --text-muted:    #9ca3af;
  --border-color:  #e5e7eb;
  --accent:        #4f46e5;
  --accent-hover:  #4338ca;
  --accent-light:  #eef2ff;
  --success:       #10b981;
  --success-light: #d1fae5;
  --danger:        #ef4444;
  --danger-light:  #fee2e2;
  --warning:       #f59e0b;
  --warning-light: #fef3c7;
  --info:          #3b82f6;
  --info-light:    #dbeafe;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.12);
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;
  --sidebar-width: 260px;
  --topbar-height: 60px;
  /* Tipografía base */
  --fs-xs:   0.72rem;
  --fs-sm:   0.82rem;
  --fs-base: 0.9rem;
  --fs-md:   1rem;
  --fs-lg:   1.15rem;
}

[data-theme="dark"] {
  --bg-primary:    #0f1117;
  --bg-secondary:  #1a1f2e;
  --bg-card:       #1e2436;
  --bg-sidebar:    #111827;
  --text-primary:  #f1f5f9;
  --text-secondary:#94a3b8;
  --text-muted:    #64748b;
  --border-color:  #2d3748;
  --accent:        #6366f1;
  --accent-hover:  #818cf8;
  --accent-light:  #1e1b4b;
  --success-light: #064e3b;
  --danger-light:  #7f1d1d;
  --warning-light: #78350f;
  --info-light:    #1e3a5f;
  --shadow-sm:     0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.5);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-main);
  font-size: var(--fs-base);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
  line-height: 1.6;
  margin: 0;
  /* Evita scroll horizontal global */
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; }

/* ============================================================
   PUBLIC NAVBAR
   ============================================================ */
.public-navbar {
  background: var(--bg-secondary) !important;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 1000;
}
.public-navbar .navbar-brand {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--accent) !important;
}
.public-navbar .nav-link {
  color: var(--text-secondary) !important;
  font-weight: 500;
  font-size: var(--fs-base);
  padding: 0.4rem 0.8rem !important;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.public-navbar .nav-link:hover,
.public-navbar .nav-link.active {
  color: var(--accent) !important;
  background: var(--accent-light);
}
[data-theme="dark"] .public-navbar .navbar-toggler-icon { filter: invert(1); }


/* ---- Ícono según tema (navbar public) ---- */
[data-theme="light"] .icon-dark  { display: none; }
[data-theme="dark"]  .icon-light { display: none; }

/* ============================================================
   HERO
   ============================================================ */
.hero-section {
  background: linear-gradient(135deg, var(--accent) 0%, #10114d 100%);
  color: #fff;
  padding: 70px 0 50px;
  position: relative;
  overflow: hidden;
}
.hero-section::before, .hero-section::after {
  content: ''; position: absolute; border-radius: 50%; pointer-events: none;
}
.hero-section::before { top:-50%; right:-20%; width:500px; height:500px; background:rgba(255,255,255,0.06); }
.hero-section::after  { bottom:-30%; left:-10%; width:400px; height:400px; background:rgba(255,255,255,0.04); }
.hero-section h1 { font-weight: 800; font-size: 2.4rem; line-height: 1.2; position: relative; z-index: 1; }
.hero-section p  { opacity: .9; font-size: 1rem; position: relative; z-index: 1; }
.hero-section .container { position: relative; z-index: 2; }

/* ============================================================
   PRODUCT CARDS
   ============================================================ */
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all 0.3s ease;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--accent); }
.product-card-img {
  width: 100%; height: 200px; object-fit: cover; display: block; background: var(--bg-primary);
}
.product-card-img-placeholder {
  width: 100%; height: 200px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary); color: var(--text-muted); font-size: 2.5rem;
}
.product-card-body {
  padding: 1rem; flex: 1; display: flex; flex-direction: column;
}
.product-card-category {
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--accent); margin-bottom: .3rem;
}
.product-card-title {
  font-weight: 700; font-size: var(--fs-md); color: var(--text-primary);
  margin-bottom: .4rem; line-height: 1.3;
}
.product-card-price {
  font-weight: 800; font-size: 1.2rem; color: var(--accent);
  font-family: var(--font-mono); margin-top: auto; padding-top: .5rem;
}

/* ============================================================
   CATEGORY FILTER
   ============================================================ */
.category-filter { display: flex; gap: .4rem; flex-wrap: wrap; }
.category-btn {
  padding: .35rem .9rem;
  border-radius: 50px; font-size: var(--fs-sm); font-weight: 600;
  border: 2px solid var(--border-color); background: var(--bg-card);
  color: var(--text-secondary); cursor: pointer; transition: all .2s;
  font-family: var(--font-main); white-space: nowrap;
}
.category-btn:hover, .category-btn.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ============================================================
   ADMIN LAYOUT
   ============================================================ */
.admin-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  position: fixed; top: 0; left: 0;
  height: 100vh; overflow-y: auto;
  z-index: 1050;
  transform: translateX(0);
  transition: transform 0.3s ease, width 0.3s ease;
  display: flex; flex-direction: column;
}

.sidebar.collapsed {
  width: 78px;
}
.sidebar.collapsed .sidebar-brand-sub,
.sidebar.collapsed .sidebar-section,
.sidebar.collapsed .sidebar-link {
  display: none;
}
.sidebar.collapsed .sidebar-avatar {
  margin-right: 0;
}

.admin-main.collapsed {
  margin-left: 78px;
}

.sidebar-brand {
  padding: 1.25rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.sidebar-brand-text { font-weight: 800; font-size: 1.15rem; color: #fff; display: block; }
.sidebar-brand-sub  { font-size: var(--fs-xs); color: rgba(255,255,255,.4); text-transform: uppercase; letter-spacing: 1px; display: block; margin-top: 2px; }
.sidebar-nav { padding: .5rem 0; flex: 1; }
.sidebar-section {
  padding: .5rem 1.1rem .15rem;
  font-size: .62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: rgba(255,255,255,.3); margin-top: .25rem;
}
.sidebar-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem 1.1rem; color: rgba(255,255,255,.65);
  font-weight: 500; font-size: var(--fs-sm);
  border-left: 3px solid transparent; text-decoration: none; transition: all .2s;
}
.sidebar-link i { font-size: .95rem; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { color: #fff; background: rgba(255,255,255,.07); }
.sidebar-link.active { color: #fff; background: rgba(99,102,241,.2); border-left-color: var(--accent); }
.sidebar-user {
  padding: .9rem 1.1rem; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: .65rem; flex-shrink: 0;
}
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: .85rem; flex-shrink: 0;
}
.sidebar-user-name { font-size: var(--fs-sm); font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: .68rem; color: rgba(255,255,255,.4); text-transform: uppercase; }

.admin-main {
  margin-left: var(--sidebar-width);
  flex: 1; display: flex; flex-direction: column;
  min-height: 100vh; min-width: 0;
  /* Evita desbordamiento horizontal */
  overflow-x: hidden;
}
.admin-topbar {
  height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center;
  padding: 0 1.25rem; gap: .75rem;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
  /* Evita que el topbar desborde */
  min-width: 0;
}
.topbar-title {
  font-weight: 700; font-size: var(--fs-md);
  color: var(--text-primary); flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.admin-content { padding: 1.25rem; flex: 1; min-width: 0; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: 1rem;
  display: flex; align-items: center; gap: .85rem;
  box-shadow: var(--shadow-sm); transition: all .25s;
  /* Evita que el contenido desborde */
  min-width: 0; overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
  width: 46px; height: 46px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; flex-shrink: 0;
}
.stat-icon.purple { background: var(--accent-light); color: var(--accent); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.red    { background: var(--danger-light);  color: var(--danger); }
.stat-icon.blue   { background: var(--info-light);    color: var(--info); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-value {
  font-size: 1.35rem; font-weight: 800; color: var(--text-primary);
  font-family: var(--font-mono); line-height: 1.1;
  /* Truncate si es muy largo */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-label {
  font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px; margin-top: 2px;
  white-space: nowrap;
}

/* ============================================================
   TABLE CARD
   ============================================================ */
.table-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm);
  /* Muy importante para mobile */
  width: 100%;
}
.table-card-header {
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .6rem; background: var(--bg-card);
}
.table-card-title { font-weight: 700; font-size: var(--fs-md); color: var(--text-primary); }

/* Wrapper que permite scroll horizontal en móvil sin romper el layout */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.table { margin-bottom: 0; color: var(--text-primary); width: 100%; }
.table > :not(caption) > * > * {
  background-color: transparent !important;
  border-bottom-color: var(--border-color) !important;
  color: var(--text-primary) !important;
  padding: .65rem .85rem;
  font-size: var(--fs-sm);
  /* Evita texto cortado pero permite wrap */
  word-break: break-word;
}
.table thead > * > * {
  background-color: var(--bg-primary) !important;
  color: var(--text-muted) !important;
  font-size: var(--fs-xs) !important;
  font-weight: 700 !important;
  text-transform: uppercase; letter-spacing: .8px;
  /* Cabeceras no rompen */
  white-space: nowrap;
}
.table tbody tr:hover > * { background-color: var(--accent-light) !important; }

/* Celda de acciones: botones no se rompen */
.table td:last-child { white-space: nowrap; }

/* ============================================================
   BOTONES
   ============================================================ */
.btn {
  font-family: var(--font-main); font-weight: 600;
  border-radius: var(--radius-sm); font-size: var(--fs-sm);
  /* Evita que los botones rompan el layout */
  white-space: nowrap;
}
.btn-primary { background-color: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.btn-primary:hover { background-color: var(--accent-hover) !important; border-color: var(--accent-hover) !important; }
.btn-outline-primary { color: var(--accent) !important; border-color: var(--accent) !important; background: transparent !important; }
.btn-outline-primary:hover { background-color: var(--accent) !important; color: #fff !important; }

/* ============================================================
   FORMS + VALIDACIONES
   ============================================================ */
.form-control, .form-select {
  background-color: var(--bg-secondary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: var(--fs-base);
  transition: all .2s;
}
.form-control:focus, .form-select:focus {
  background-color: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15) !important;
}
.form-control::placeholder { color: var(--text-muted) !important; opacity: 1; }
.form-label { font-weight: 600; font-size: var(--fs-sm); color: var(--text-secondary); margin-bottom: .3rem; }
.input-group-text {
  background-color: var(--bg-primary) !important;
  border-color: var(--border-color) !important;
  color: var(--text-muted) !important;
}
[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

/* Estados de validación */
.form-control.is-valid, .form-select.is-valid {
  border-color: var(--success) !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2310b981' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e") !important;
  background-repeat: no-repeat;
  background-position: right .75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}
.form-control.is-invalid, .form-select.is-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.12) !important;
}
.invalid-feedback {
  display: none;
  font-size: var(--fs-xs);
  color: var(--danger);
  margin-top: .25rem;
  font-weight: 600;
}
.form-control.is-invalid ~ .invalid-feedback,
.form-select.is-invalid ~ .invalid-feedback,
.was-validated .form-control:invalid ~ .invalid-feedback,
.was-validated .form-select:invalid ~ .invalid-feedback { display: block; }

/* ============================================================
   MODALES — Sistema completo (scroll, responsive, accesible)
   ============================================================ */

/* Estructura base */
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  /* Sin max-height aquí — lo maneja modal-dialog */
}

/* Header fijo arriba */
.modal-header {
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
  padding: .9rem 1.25rem;
  flex-shrink: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
/* Footer fijo abajo */
.modal-footer {
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  padding: .75rem 1.25rem;
  flex-shrink: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
/* Body scrollable */
.modal-body {
  background: var(--bg-card);
  padding: 1.15rem 1.25rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}
.modal-title { font-weight: 700; color: var(--text-primary); font-size: var(--fs-md); }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1); }

/* Scrollbar delgado en modal-body */
.modal-body::-webkit-scrollbar       { width: 4px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* Dialog base — centrado */
.modal-dialog { margin: 1.75rem auto; }
.modal-dialog-centered { align-items: center; }

/* Dialog scrollable — el body ocupa el espacio disponible */
.modal-dialog-scrollable {
  height: calc(100% - 3.5rem);
}
.modal-dialog-scrollable .modal-content {
  max-height: 100%;
  overflow: hidden;
}
.modal-dialog-scrollable .modal-body {
  overflow-y: auto;
}

/* ---- DESKTOP (≥ 769px) ---- */
@media (min-width: 769px) {
  /* Modales grandes: limitar altura al 88% de la pantalla */
  .modal-dialog:not(.modal-sm):not(.modal-dialog-centered) .modal-content,
  .modal-dialog-scrollable .modal-content,
  .modal-dialog-centered .modal-content {
    max-height: 88vh;
  }
  .modal-body {
    max-height: calc(88vh - 120px); /* descontar header+footer */
  }
  .modal-dialog-scrollable {
    height: calc(100% - 3.5rem);
    max-height: 88vh;
  }
}

/* ---- TABLET (≤ 991px) ---- */
@media (max-width: 991px) {
  .modal-dialog { margin: 1rem auto; }
}

/* ---- MOBILE (≤ 768px) ---- */
@media (max-width: 768px) {
  /* Todos los modales suben desde abajo */
  .modal-dialog {
    margin: 0;
    max-width: 100% !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
  }
  .modal-dialog-centered {
    align-items: flex-end;
    min-height: 100%;
  }
  .modal-content {
    border-radius: 1rem 1rem 0 0 !important;
    max-height: 92vh !important;
  }
  .modal-body {
    max-height: calc(92vh - 115px);
  }
  /* Modales pequeños (confirmación) → centrados */
  .modal-dialog.modal-sm {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    width: auto;
    max-width: 320px !important;
    margin: 1.5rem auto;
  }
  .modal-dialog.modal-sm .modal-content {
    border-radius: var(--radius-lg) !important;
    max-height: calc(100vh - 3rem) !important;
  }
  /* Footer botones en columna en móvil */
  .modal-footer { flex-direction: column-reverse; gap: .5rem; }
  .modal-footer .btn { width: 100%; }
}

/* ---- EXTRA SMALL (≤ 480px) ---- */
@media (max-width: 480px) {
  .modal-body { padding: .9rem 1rem; max-height: calc(90vh - 110px); }
  .modal-header { padding: .75rem 1rem; }
  .modal-footer { padding: .65rem 1rem; }
}

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge-status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: .22rem .65rem; border-radius: 50px;
  font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; white-space: nowrap;
}
.badge-active   { background: var(--success-light); color: var(--success); }
.badge-inactive { background: var(--danger-light);  color: var(--danger); }
.badge-admin    { background: var(--accent-light);   color: var(--accent); }
.badge-vendor   { background: var(--info-light);     color: var(--info); }
.badge-efectivo { background: var(--success-light);  color: var(--success); }
.badge-qr       { background: var(--info-light);     color: var(--info); }

/* ============================================================
   THEME TOGGLE
   ============================================================ */
.theme-toggle {
  background: var(--bg-primary); border: 1.5px solid var(--border-color);
  border-radius: 50px; padding: .3rem .8rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary);
  transition: all .2s; white-space: nowrap; font-family: var(--font-main);
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* ============================================================
   ALERTS / FLASH
   ============================================================ */
.alert { border-radius: var(--radius); border: none; font-weight: 500; font-size: var(--fs-sm); }
.alert-success { background: var(--success-light) !important; color: #065f46 !important; }
.alert-danger  { background: var(--danger-light)  !important; color: #991b1b !important; }
.alert-warning { background: var(--warning-light) !important; color: #92400e !important; }
.alert-info    { background: var(--info-light)    !important; color: #1e40af !important; }
[data-theme="dark"] .alert-success { color: #6ee7b7 !important; }
[data-theme="dark"] .alert-danger  { color: #fca5a5 !important; }
[data-theme="dark"] .alert-warning { color: #fde68a !important; }
[data-theme="dark"] .alert-info    { color: #93c5fd !important; }

/* Toast centrado en mobile */
#toastContainer {
  position: fixed !important;
  top: .75rem !important;
  right: .75rem !important;
  left: .75rem !important;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar { position: relative; }
.search-bar .form-control { padding-left: 2.2rem !important; border-radius: 50px !important; }
.search-bar .search-icon {
  position: absolute; left: .75rem; top: 50%;
  transform: translateY(-50%); color: var(--text-muted); pointer-events: none; z-index: 5;
}

/* ============================================================
   GALLERY
   ============================================================ */
.gallery-main img {
  width: 100%; max-height: 380px; object-fit: cover;
  border-radius: var(--radius-lg); display: block;
  border: 1px solid var(--border-color);
}
.gallery-thumbs { display: flex; gap: .4rem; margin-top: .6rem; flex-wrap: wrap; }
.gallery-thumb {
  width: 70px; height: 70px; object-fit: cover;
  border-radius: var(--radius-sm); cursor: pointer;
  border: 2px solid transparent; transition: all .2s;
}
.gallery-thumb.active, .gallery-thumb:hover { border-color: var(--accent); }

/* ============================================================
   CART SIDEBAR
   ============================================================ */
.cart-sidebar {
  position: fixed; right: 0; top: 0;
  height: 100vh; width: 320px;
  background: var(--bg-secondary); border-left: 1px solid var(--border-color);
  z-index: 1060; transform: translateX(100%); transition: transform .3s ease;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
}
.cart-sidebar.open { transform: translateX(0); }
.cart-header {
  padding: .85rem 1rem; border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between;
}
.cart-header h6 { font-weight: 700; margin: 0; color: var(--text-primary); font-size: var(--fs-md); }
.cart-items { flex: 1; overflow-y: auto; padding: .6rem; }
.cart-item {
  display: flex; align-items: flex-start; gap: .6rem; padding: .65rem;
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); margin-bottom: .4rem;
}
.cart-item-name  { font-weight: 600; font-size: var(--fs-sm); color: var(--text-primary); }
.cart-item-price { font-size: var(--fs-xs); color: var(--text-muted); font-family: var(--font-mono); }
.cart-footer { padding: .85rem 1rem; border-top: 1px solid var(--border-color); background: var(--bg-card); }
.cart-total { font-size: 1.4rem; font-weight: 800; color: var(--accent); font-family: var(--font-mono); }

/* ============================================================
   IMAGE PREVIEW
   ============================================================ */
.img-preview-container { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .6rem; }
.img-preview-item { position: relative; width: 80px; height: 80px; }
.img-preview-item img {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: var(--radius-sm); border: 2px solid var(--border-color); display: block;
}
.img-preview-delete {
  position: absolute; top: -7px; right: -7px;
  background: var(--danger); color: #fff; border: none;
  border-radius: 50%; width: 20px; height: 20px;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-size: .65rem; padding: 0;
}

/* ============================================================
   STOCK
   ============================================================ */
.stock-indicator { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); }
.stock-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.stock-high   .stock-dot { background: var(--success); }
.stock-medium .stock-dot { background: var(--warning); }
.stock-low    .stock-dot { background: var(--danger); }
.stock-out    .stock-dot { background: var(--text-muted); }

/* ============================================================
   NAV TABS
   ============================================================ */
.nav-tabs { border-bottom-color: var(--border-color); flex-wrap: nowrap; overflow-x: auto; }
.nav-tabs .nav-link {
  color: var(--text-secondary); border-color: transparent;
  font-weight: 600; font-size: var(--fs-sm); white-space: nowrap;
}
.nav-tabs .nav-link:hover { color: var(--accent); border-color: transparent; background: var(--accent-light); }
.nav-tabs .nav-link.active { color: var(--accent); background: var(--bg-card); border-color: var(--border-color) var(--border-color) var(--bg-card); }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb { font-size: var(--fs-sm); flex-wrap: wrap; }
.breadcrumb-item a { color: var(--accent); }
.breadcrumb-item.active { color: var(--text-muted); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted); }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-money { font-family: var(--font-mono); font-weight: 700; }
.section-title { font-weight: 800; font-size: 1.5rem; letter-spacing: -.5px; color: var(--text-primary); }
.divider { border: none; border-top: 1px solid var(--border-color); margin: 1rem 0; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: .75rem; display: block; }
.empty-state p { font-size: var(--fs-base); font-weight: 500; margin: 0; }

/* Overflow helper para contenido ancho */
.overflow-x-auto { overflow-x: auto; -webkit-overflow-scrolling: touch; }

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

/* Sidebar overlay */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 1040; cursor: pointer;
}
.sidebar-overlay.show { display: block; }

/* Dark mode: select arrow */
[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-accent-bg: rgba(255,255,255,0.03);
}


/* Para pantallas grandes, permitir colapsar el sidebar */
@media (min-width: 992px) {
  .sidebar {
    transform: translateX(0);
    transition: transform 0.3s ease;
  }
  
  .sidebar.collapsed {
    transform: translateX(-100%);
  }
  
  /* Cuando el sidebar está colapsado, ajustar el margen del contenido */
  .sidebar.collapsed + .admin-main,
  .admin-wrapper:has(.sidebar.collapsed) .admin-main {
    margin-left: 0;
  }
}

/* ============================================================
   RESPONSIVE — TABLET (≤ 991px)
   ============================================================ */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { width: var(--sidebar-width); }
  .admin-main { margin-left: 0 !important; }

  .hero-section h1 { font-size: 1.9rem; }

  /* Topbar más compacto */
  .admin-topbar { padding: 0 1rem; }

  /* Tabla: columnas menos importantes se ocultan */
  .table-hide-tablet { display: none !important; }

  /* Stat cards más pequeñas */
  .stat-value { font-size: 1.2rem; }
  .stat-icon  { width: 40px; height: 40px; font-size: 1.05rem; }
}

/* ============================================================
   RESPONSIVE — MOBILE (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {
  /* Tipografía base reduce levemente */
  body { font-size: .88rem; }

  /* Hero */
  .hero-section { padding: 40px 0 30px; }
  .hero-section h1 { font-size: 1.55rem; }
  .hero-section p  { font-size: .9rem; }

  /* Admin padding reducido */
  .admin-content { padding: .85rem; }

  /* Topbar */
  .admin-topbar { height: 54px; gap: .5rem; padding: 0 .85rem; }
  .topbar-title { font-size: var(--fs-base); }

  /* Stat cards en columnas 2×2, texto más pequeño */
  .stat-card   { padding: .75rem; gap: .65rem; }
  .stat-value  { font-size: 1.05rem; }
  .stat-label  { font-size: .62rem; }
  .stat-icon   { width: 38px; height: 38px; font-size: 1rem; border-radius: var(--radius-sm); }

  /* Table card header: stack vertical */
  .table-card-header { flex-direction: column; align-items: flex-start; }
  .table-card-header .search-bar,
  .table-card-header input { width: 100% !important; }
  .table-card-header .d-flex { width: 100%; }
  .table-card-header .btn { width: 100%; justify-content: center; }

  /* Tabla: fuente pequeña, celdas compactas */
  .table > :not(caption) > * > * { padding: .5rem .6rem; font-size: .78rem; }
  .table thead > * > * { font-size: .65rem !important; padding: .45rem .6rem; }

  /* Ocultar columnas de baja prioridad en móvil */
  .table-hide-mobile { display: none !important; }

  /* Botones en tabla: solo icono */
  .btn-icon-only span { display: none; }

  /* Modal fullscreen en mobile */
  .modal-dialog { margin: 0; max-width: 100%; }
  .modal-content { border-radius: var(--radius) var(--radius) 0 0; min-height: 50vh; }
  .modal-dialog-mobile-bottom {
    align-items: flex-end;
    min-height: calc(100% - 0px);
  }

  /* Imágenes de producto en tabla: más pequeñas */
  .table td img { width: 36px !important; height: 36px !important; }

  /* POS: carrito debajo de la lista */
  #tabPOS .row { flex-direction: column; }
  #tabPOS .col-lg-7,
  #tabPOS .col-lg-5 { width: 100%; max-width: 100%; }

  /* Cart sidebar fullwidth */
  .cart-sidebar { width: 100%; }

  /* Nav tabs: scroll horizontal */
  .nav-tabs { gap: 0; }
  .nav-tabs .nav-link { padding: .5rem .75rem; font-size: .78rem; }

  /* Section title */
  .section-title { font-size: 1.25rem; }

  /* Badges más pequeños */
  .badge-status { font-size: .62rem; padding: .18rem .5rem; }

  /* Product cards: altura imagen menor */
  .product-card-img,
  .product-card-img-placeholder { height: 160px; }

  /* Search bar full width en mobile */
  .search-bar { width: 100% !important; }
  .search-bar input { width: 100% !important; }

  /* Gallery thumbnails */
  .gallery-thumb { width: 56px; height: 56px; }

  /* Toast ancho completo */
  #toastContainer { right: .5rem; left: .5rem; top: .5rem; }

  /* Botones en formularios */
  .modal-footer { flex-direction: column-reverse; gap: .5rem; }
  .modal-footer .btn { width: 100%; }

  /* Formulario de login */
  .login-card { padding: 1.75rem 1.25rem; }
}

/* ============================================================
   RESPONSIVE — EXTRA SMALL (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {
  .admin-content { padding: .6rem; }

  .stat-value { font-size: .95rem; }
  .stat-icon  { width: 34px; height: 34px; font-size: .9rem; }

  .hero-section h1 { font-size: 1.35rem; }

  /* Ocultar columna fecha en tablas muy pequeñas */
  .table-hide-xs { display: none !important; }

  /* Tabla con fuente mínima */
  .table > :not(caption) > * > * { font-size: .72rem; padding: .4rem .45rem; }

  .product-card-body { padding: .75rem; }
  .product-card-title { font-size: .9rem; }
  .product-card-price { font-size: 1.05rem; }

  .category-btn { font-size: .75rem; padding: .28rem .7rem; }

  .section-title { font-size: 1.1rem; }
}

/* Modal responsive en mobile */
@media (max-width: 576px) {
  .modal-dialog { margin: .5rem; }
  .modal-lg { max-width: calc(100vw - 1rem); }
  .modal-sm { max-width: calc(100vw - 1rem); }
  .modal-body { padding: 1rem; }
  .modal-header { padding: .85rem 1rem; }
  .modal-footer { padding: .75rem 1rem; flex-wrap: wrap; gap: .5rem; }
  .modal-footer .btn { flex: 1 1 auto; }

  /* POS: carrito abajo del todo en mobile */
  #tabPOS .row { --bs-gutter-y: 1rem; }

  /* Nav tabs scroll en mobile */
  .nav-tabs { overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .nav-tabs .nav-item { flex-shrink: 0; }

  /* Stat cards texto mas compacto */
  .stat-value { font-size: .9rem; }
  .stat-label { font-size: .6rem; }
  .stat-icon  { width: 34px; height: 34px; font-size: .9rem; }

  /* Table card header full width */
  .table-card-header { flex-direction: column; align-items: stretch; }
  .table-card-header .search-bar,
  .table-card-header input.form-control { width: 100% !important; }
  .table-card-header .btn { width: 100%; }
  .table-card-header .d-flex.gap-2 { flex-direction: column; }

  /* Topbar */
  .topbar-title { font-size: .88rem; }
  .theme-toggle span { display: none; }
  .theme-toggle { padding: .3rem .6rem; }
}

/* ============================================================
   CARRUSEL HERO
   ============================================================ */
.carousel-bg {
  height: 480px;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.carousel-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,.35) 0%, rgba(0,0,0,.55) 100%);
}
.carousel-caption-custom {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  z-index: 10;
  padding: 0;
}
.carousel-title {
  font-weight: 800;
  font-size: 2.4rem;
  color: #fff;
  line-height: 1.2;
  text-shadow: 0 2px 8px rgba(0,0,0,.4);
  margin-bottom: .75rem;
}
.carousel-subtitle {
  font-size: 1.05rem;
  color: rgba(255,255,255,.9);
  text-shadow: 0 1px 4px rgba(0,0,0,.3);
  margin-bottom: 0;
}
/* Buscador flotante sobre el carrusel */
.carousel-search-overlay {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  z-index: 20;
  padding-bottom: 2rem;
}
.carousel-search-form { max-width: 560px; margin: 0 auto; }
.carousel-search-inner {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,.95);
  border-radius: 50px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  padding: .3rem .3rem .3rem 1rem;
}
.carousel-search-icon { color: var(--text-muted); margin-right: .5rem; flex-shrink: 0; }
.carousel-search-input {
  flex: 1; border: none; outline: none;
  background: transparent; font-family: var(--font-main);
  font-size: .95rem; color: var(--text-primary);
  padding: .4rem 0;
}
.carousel-search-input::placeholder { color: var(--text-muted); }
.carousel-search-btn {
  background: var(--accent); color: #fff;
  border: none; border-radius: 50px;
  padding: .5rem 1.4rem; font-weight: 700;
  font-family: var(--font-main); font-size: .88rem;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background .2s;
}
.carousel-search-btn:hover { background: var(--accent-hover); }
.carousel-indicators [data-bs-target] {
  width: 8px; height: 8px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.5);
  transition: background .2s, transform .2s;
}
.carousel-indicators .active { background: #fff; transform: scale(1.3); }
.carousel-control-prev-icon,
.carousel-control-next-icon { filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
[data-bs-theme="dark"] .carousel-search-inner { background: rgba(30,36,54,.95); }
[data-theme="dark"] .carousel-search-inner { background: rgba(30,36,54,.95); }
[data-theme="dark"] .carousel-search-input { color: #f1f5f9; }

/* ============================================================
   CATEGORY CHIPS (nuevo diseño)
   ============================================================ */
.cat-chip {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: .82rem;
  transition: all .2s;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-chip i { color: var(--accent); flex-shrink: 0; }
.cat-chip:hover,
.cat-chip.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.cat-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   FOOTER MEJORADO
   ============================================================ */
.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 2.5rem 0 1.5rem;
  margin-top: 3rem;
}
.site-footer-brand { font-weight: 800; font-size: 1.1rem; color: var(--accent); }
.site-footer-text  { font-size: .84rem; color: var(--text-muted); margin-top: .25rem; }
.site-footer-contact a {
  color: var(--text-secondary); font-size: .85rem; text-decoration: none;
  display: flex; align-items: center; gap: .4rem; margin-bottom: .3rem;
  transition: color .2s;
}
.site-footer-contact a:hover { color: var(--accent); }
.site-footer-bottom {
  border-top: 1px solid var(--border-color);
  margin-top: 1.5rem;
  padding-top: 1rem;
  text-align: center;
  font-size: .8rem;
  color: var(--text-muted);
}

/* ============================================================
   FIXES RESPONSIVOS ADICIONALES
   ============================================================ */
/* Carrusel mobile */
@media (max-width: 768px) {
  .carousel-bg { height: 320px; }
  .carousel-title { font-size: 1.55rem; }
  .carousel-subtitle { font-size: .9rem; }
  .carousel-search-overlay { padding-bottom: 1rem; }
  .carousel-search-inner { border-radius: var(--radius); }
  .carousel-search-form { max-width: calc(100% - 2rem); margin: 0 1rem; }
}
@media (max-width: 480px) {
  .carousel-bg { height: 260px; }
  .carousel-title { font-size: 1.3rem; }
  .carousel-search-inner { flex-wrap: wrap; border-radius: var(--radius-sm); padding: .4rem; }
  .carousel-search-input { width: 100%; }
  .carousel-search-btn   { width: 100%; border-radius: var(--radius-sm); text-align: center; }
}

/* Product card mobile — 2 columnas */
@media (max-width: 576px) {
  .product-card-img,
  .product-card-img-placeholder { height: 140px; }
  .product-card-title  { font-size: .82rem; }
  .product-card-body   { padding: .6rem; }
  .product-card-category { font-size: .65rem; }
}

/* Cat chips overflow scroll en mobile */
@media (max-width: 576px) {
  .category-filter { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .25rem; }
  .category-filter::-webkit-scrollbar { height: 3px; }
}

/* POS carrito mobile: botón flotante para scroll */
@media (max-width: 991px) {
  .pos-cart-fab {
    display: flex !important;
  }
}
.pos-cart-fab {
  display: none;
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 500;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: .7rem 1.2rem;
  font-weight: 700;
  font-size: .9rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  cursor: pointer;
  align-items: center;
  gap: .4rem;
  font-family: var(--font-main);
  transition: background .2s, transform .1s;
}
.pos-cart-fab:active { transform: scale(.96); }
.pos-cart-fab .cart-count-fab {
  background: #fff;
  color: var(--accent);
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: .75rem;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
}


/* ============================================================
   HISTORIAL VENTAS — badge de color
   ============================================================ */
.venta-color-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  padding: 1px 7px 1px 4px;
  font-size: .68rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  vertical-align: middle;
}
.venta-color-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,.2);
  flex-shrink: 0;
  display: inline-block;
}

/* ============================================================
   POS — tabla responsive
   ============================================================ */
#posTable td, #posTable th { vertical-align: middle; }
@media (max-width: 576px) {
  #posTable .btn { font-size: .68rem; padding: .18rem .38rem; }
}

/* ============================================================
   CARRITO FAB (botón flotante móvil)
   ============================================================ */
.pos-cart-fab {
  display: none;
  position: fixed;
  bottom: 1.25rem; right: 1.25rem;
  z-index: 500;
  background: var(--accent); color: #fff;
  border: none; border-radius: 50px;
  padding: .65rem 1.1rem;
  font-weight: 700; font-size: .88rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  cursor: pointer;
  align-items: center; gap: .4rem;
  font-family: var(--font-main);
  transition: background .2s, transform .1s;
}
.pos-cart-fab:active { transform: scale(.96); }
@media (max-width: 991px) { .pos-cart-fab { display: flex; } }

/* ============================================================
   ICONOS TEMA — Ahora manejado por PHP condicional
   ============================================================ */

[data-theme="light"] .icon-dark  { display: none; }
[data-theme="dark"]  .icon-light { display: none; }
