/* =========================================
   VARIABLES Y RESET
   ========================================= */
:root {
  /* 🌙 MODO OSCURO - Paleta del Login */
  --bg-dark: #1a1a2e;
  --surface: #2d2d44;
  --surface-light: #3f3f5f;
  --primary: #7c3aed;
  --primary-hover: #a855f7;
  --primary-rgb: 124, 58, 237;
  --danger: #ef4444;
  --danger-rgb: 239, 68, 68;
  --success: #10b981;
  --success-rgb: 16, 185, 129;
  --amber: #f59e0b;
  --amber-rgb: 245, 158, 11;
  --blue: #3b82f6;
  --blue-rgb: 59, 130, 246;
  --green-light: #22c55e;
  --whatsapp: #25d366;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --border: #52526e;
  --row-hover: rgba(255, 255, 255, 0.04);
  --row-active: rgba(255, 255, 255, 0.08);
  --overlay-subtle: rgba(255, 255, 255, 0.05);
  --overlay-medium: rgba(255, 255, 255, 0.1);
  --overlay-strong: rgba(255, 255, 255, 0.15);
  --card-shadow:
    0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
  --border-radius-sm: 0.5rem; /* 8px */
  --border-radius-md: 0.75rem; /* 12px */
  --border-radius-lg: 1.25rem; /* 20px */

  /* 🎨 TIPOGRAFÍA FLUIDA PREMIUM (clamp) */
  --h1-size: clamp(1.5rem, 4vw, 2.25rem);
  --h2-size: clamp(1.25rem, 3vw, 1.75rem);
  --h3-size: clamp(1.1rem, 2.5vw, 1.5rem);
  --h4-size: clamp(1rem, 2vw, 1.25rem);
  --body-size: clamp(0.875rem, 1.5vw, 1rem);
  --small-size: clamp(0.75rem, 1.2vw, 0.875rem);

  /* 🌊 SCROLL SUAVE */
  scroll-behavior: smooth;
}

body.light-mode {
  /* ☀️ MODO CLARO */
  --bg-dark: #f5f5fa;
  --surface: #ffffff;
  --surface-light: #f0f0f5;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --primary-rgb: 124, 58, 237;
  --danger: #ef4444;
  --danger-rgb: 239, 68, 68;
  --success: #10b981;
  --success-rgb: 16, 185, 129;
  --amber: #d97706;
  --amber-rgb: 245, 158, 11;
  --blue: #2563eb;
  --blue-rgb: 37, 99, 235;
  --green-light: #16a34a;
  --whatsapp: #25d366;
  --text: #1f1f2e;
  --text-muted: #6b7280;
  --border: #e2e4e9;
  --row-hover: rgba(0, 0, 0, 0.03);
  --row-active: rgba(0, 0, 0, 0.06);
  --overlay-subtle: rgba(0, 0, 0, 0.03);
  --overlay-medium: rgba(0, 0, 0, 0.06);
  --overlay-strong: rgba(0, 0, 0, 0.1);
  --card-shadow:
    0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.03);
}

* {
  box-sizing: border-box;
  font-family: "Inter", system-ui, sans-serif;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text);
  line-height: 1.5;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--primary-rgb), 0.25) transparent;
}

body::-webkit-scrollbar {
  width: 8px;
}

body::-webkit-scrollbar-track {
  background: transparent;
}

body::-webkit-scrollbar-thumb {
  background: rgba(var(--primary-rgb), 0.25);
  border-radius: 4px;
}

body::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--primary-rgb), 0.4);
}

/* =========================================
   COMPONENTES UNIVERSALES (BOTONES E INPUTS)
   ========================================= */
.btn {
  padding: 0.8rem 1.4rem; /* Restaurado */
  border-radius: var(--border-radius-md);
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  background-color: var(--text-muted);
  color: var(--bg-dark);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}
.btn-danger:hover {
  opacity: 0.9;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 5px;
  border-radius: var(--border-radius-sm);
  transition: 0.2s;
  text-decoration: none; /* Elimina el subrayado en enlaces (WhatsApp) */
}

.btn-icon:hover {
  background: var(--overlay-medium);
  color: var(--text);
}

input,
select,
textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  background-color: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--border-radius-md);
  color: var(--text);
  outline: none;
  font-size: 0.95rem;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
}

.form-check-input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.form-check-label {
  cursor: pointer;
  user-select: none;
}

/* =========================================
   TARJETAS Y LAYOUT
   ========================================= */
.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-lg);
  padding: 1.1rem; /* Reducido de 1.5rem para ganar espacio */
  margin-bottom: 1.25rem;
  box-shadow: var(--card-shadow);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--border-radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.2s;
}

.stat-card:hover {
  border-color: var(--primary);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
}

/* =========================================
   TABLAS PROFESIONALES
   ========================================= */
.stock-table {
  width: 100%;
  border-collapse: collapse;
}

.stock-table thead th {
  text-align: left;
  padding: 12px 15px; /* Restaurado */
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-muted);
  font-size: 0.8rem; /* Restaurado */
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap; /* Evita que los títulos se rompan en dos líneas */
}

.stock-table tbody td {
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem; /* Restaurado */
  vertical-align: middle; /* Alinea verticalmente el contenido */
}

.stock-table tbody tr {
  transition: background 0.2s;
}

.stock-table tbody tr:hover {
  background: var(--row-hover);
}

/* =========================================
   SISTEMA DE MODALES UNIFICADO
   ========================================= */

/* Fix: Asegurar que modales ocultos no bloqueen interacción */
.modal-overlay,
.modal {
  pointer-events: none;
}

.modal-overlay[style*="display: flex"],
.modal[style*="display: flex"],
.modal-overlay.active,
.modal.active {
  pointer-events: auto;
}

/* Base: Overlay para todos los modales */
.modal-overlay,
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  padding: 20px;
  animation: modalOverlayFade 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  backdrop-filter: blur(4px);
  background-color: rgba(0, 0, 0, 0.7);
  padding: 0;
}

/* Base: Contenido del modal */
.modal-content {
  background-color: var(--surface);
  width: 95%;
  max-width: 800px;
  max-height: 95vh;
  border-radius: var(--border-radius-lg);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.5),
    0 0 0 1px var(--border);
  overflow: hidden;
  animation: modalPopIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal > .modal-content {
  max-width: 90%;
  max-height: 90vh;
  box-shadow: var(--card-shadow);
  animation: modalSlideIn 0.2s ease;
}

@keyframes modalOverlayFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalPopIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.modal-large {
  max-width: 900px;
}

/* Base: Estructura interna del modal */
.modal-header {
  padding: 1.2rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1.25rem;
  margin: 0;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex-grow: 1;
  background: var(--surface);
}

.modal-footer {
  padding: 1.2rem 1.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-dark);
}

/* =========================================
   GESTIÓN DE MOVIMIENTOS (AUDITORÍA)
   ========================================= */
.tipo-movimiento {
  font-weight: 700;
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: var(--border-radius-sm);
  text-transform: uppercase;
}

.tipo-venta {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}
.tipo-gasto {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}
.tipo-anulado {
  background: var(--surface);
  color: var(--text-muted);
}

/* --- Badges de estado para Presupuestos --- */
.tipo-presup-pendiente {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
}
.tipo-presup-aprobado {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}
.tipo-presup-rechazado {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}
.tipo-presup-vencido {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-muted);
}

.monto-positivo {
  color: var(--success);
  font-weight: bold;
}
.monto-negativo {
  color: var(--danger);
  font-weight: bold;
}

.texto-recortado {
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}

.detalle-lista-modal {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text);
}

/* =========================================
   WIDGET DE DIVISAS
   ========================================= */
#usd-widget {
  /* Estilos reset para usar dentro de card */
  width: 100%;
}

.dolar-row {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.dolar-row:last-child {
  border-bottom: none;
}

.dolar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.dolar-name {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
}

.dolar-trend {
  font-size: 0.8rem;
  font-weight: bold;
}
.trend-up {
  color: var(--success);
}
.trend-down {
  color: var(--danger);
}
.trend-equal {
  color: var(--text-muted);
}

.dolar-values {
  display: flex;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--border-radius-md);
  padding: 8px 12px;
}

.dolar-val-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.dolar-val-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.dolar-val-num {
  font-size: 1rem;
  font-weight: bold;
  color: white;
  font-family: "Courier New", monospace;
}

body.light-mode .dolar-val-num {
  color: var(--text);
}

/* =========================================
   THEME SWITCH
   ========================================= */
.theme-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}
.theme-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}
.theme-switch input {
  display: none;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--border);
  transition: 0.4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: var(--text-muted);
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}
input:checked + .slider:before {
  transform: translateX(26px);
  background-color: white;
}

/* =========================================
   UTILIDADES Y ESTADOS
   ========================================= */
.fila-anulada {
  opacity: 0.4;
  text-decoration: line-through;
  filter: grayscale(1);
}

.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}
.form-row > div {
  flex: 1;
}
.form-row label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.text-right {
  text-align: right;
}

.w-full {
  width: 100%;
}
.mt-auto {
  margin-top: auto;
}

/* --- PERFIL STAFF: edición de inventario solo con permiso inventarioEditar (inventory.js) --- */
body.rol-staff:not(.inventario-puede-editar) .btn-icon.edit,
body.rol-staff:not(.inventario-puede-editar) .btn-icon.delete,
body.rol-staff:not(.inventario-puede-editar) .btn-icon.wa {
  display: none !important;
}

body.rol-staff:not(.inventario-puede-editar)
  button[onclick="exportarInventario()"],
body.rol-staff:not(.inventario-puede-editar)
  button[onclick="triggerImportar()"] {
  display: none !important;
}

/* --- ESTILOS PARA MODAL DE CIERRE DE CAJA --- */
.cierre-line-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 1rem;
}
.cierre-line-item span {
  color: var(--text-muted);
}
.cierre-line-item strong {
  font-weight: 700;
}
.cierre-line-item.total-sistema strong {
  color: var(--primary);
  font-size: 1.2rem;
}

.cierre-diferencia {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--border-radius-md);
  text-align: center;
  font-size: 1.1rem;
  font-weight: bold;
  min-height: 54px;
}
.cierre-diferencia.sobrante {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid var(--success);
}
.cierre-diferencia.faltante {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid var(--danger);
}
.cierre-diferencia.exacto {
  background: rgba(59, 130, 246, 0.1);
  color: var(--blue);
  border: 1px solid var(--blue);
}

/* --- LISTA DE USUARIOS --- */
.user-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.user-list-item:last-child {
  border-bottom: none;
}
.user-list-item .user-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* --- POS: SELECTOR DE CLIENTE / TIPO DE VENTA --- */
.pos-client-box {
  width: 100%;
  text-align: left;
}
.pos-client-box small {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 4px;
  display: block;
}
.btn-client-select {
  width: 100%;
  background: var(--overlay-medium);
  border: 1px solid var(--border);
  color: white;
  padding: 10px;
  border-radius: var(--border-radius-md);
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
}
.btn-client-select:hover {
  background: var(--overlay-strong);
}

/* Tabs del modal de cliente/tipo de venta */
.cliente-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.cliente-tab {
  flex: 1;
  padding: 15px;
  background: var(--bg-dark);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  border-bottom: 3px solid transparent;
}

.cliente-tab:hover {
  background: var(--surface);
  color: var(--text);
}

.cliente-tab.active {
  background: var(--surface);
  color: var(--text);
  border-bottom-color: var(--primary);
}

/* Panels */
#panel-consumidor-final,
#panel-facturacion {
  animation: fadeIn 0.2s ease;
}

/* --- MODAL HISTORIAL DE CLIENTE --- */
.modal-historial-cliente {
  max-width: 800px;
  width: 90vw;
  max-height: 80vh;
}

.modal-historial-cliente .modal-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.historial-cliente-table-container {
  flex: 1;
  overflow-y: auto;
  max-height: 60vh;
  border: 1px solid var(--border);
  border-radius: var(--border-radius-md);
  margin: 15px;
}

.historial-cliente-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.historial-cliente-table thead {
  position: sticky;
  top: 0;
  background: var(--bg-dark);
  z-index: 10;
}

.historial-cliente-table th {
  padding: 12px 10px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.historial-cliente-table td {
  padding: 15px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.historial-cliente-table tbody tr {
  transition: background 0.15s;
}

.historial-cliente-table tbody tr:hover {
  background: var(--row-hover);
}

.historial-cliente-table tbody tr:last-child td {
  border-bottom: none;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Botones de acción en tabla */
.historial-cliente-table .btn-sm {
  padding: 6px 10px;
  font-size: 0.85rem;
  min-width: 32px;
}

@media (max-width: 768px) {
  .modal-historial-cliente {
    width: 95vw;
    max-height: 90vh;
  }

  .historial-cliente-table th,
  .historial-cliente-table td {
    padding: 10px 8px;
    font-size: 0.85rem;
  }

  .historial-cliente-table th {
    font-size: 0.75rem;
  }
}

.lista-seleccionable {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--border-radius-md);
}

/* Altura por defecto (Contraído) */
.historial-scroll-container {
  height: 380px;
  max-height: 380px;
  overflow-y: hidden;
  transition: max-height 0.4s ease;
  border: 1px solid var(--border);
}

#card-historial.expanded .historial-scroll-container {
  max-height: 380px;
  overflow-y: auto;
}

/* =========================================
   AVISO DE DESCONEXIÓN (OFFLINE)
   ========================================= */
.offline-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem;
  animation: fadeIn 0.3s ease;
}

.offline-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.offline-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--danger);
}

.offline-text {
  color: var(--text-muted);
  max-width: 400px;
  line-height: 1.6;
}

/* Aviso sutil para usuarios Pro */
.offline-toast-pro {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: white;
  padding: 10px 20px;
  border-radius: var(--border-radius-md);
  z-index: 9999;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translate(-50%, 100%);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Botones de tipo de venta en wizard */
.btn-tipo-venta {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
  background: var(--bg-dark);
  border: 2px solid var(--border);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
}

.btn-tipo-venta:hover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
}

.btn-tipo-venta .icon {
  font-size: 1.5rem;
}

.btn-tipo-venta .info {
  flex: 1;
}

.btn-tipo-venta .info strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text);
}

.btn-tipo-venta .info small {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-tipo-venta.factura {
  border-color: rgba(59, 130, 246, 0.3);
}

.badge-recommended {
  background: var(--success);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Wizard steps indicators */
.wizard-step-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
}

.wizard-step-indicator.active {
  color: var(--primary);
}

.wizard-step-indicator.completed {
  color: var(--success);
}

.wizard-step-indicator .step-circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-dark);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.wizard-step-indicator.active .step-circle {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.wizard-step-indicator.completed .step-circle {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.wizard-step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  max-width: 40px;
}

/* Botones de tipo de factura en wizard */
.btn-tipo-factura {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px;
  background: var(--bg-dark);
  border: 2px solid var(--border);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.btn-tipo-factura:hover {
  border-color: var(--primary);
}

.btn-tipo-factura strong {
  font-size: 0.95rem;
  color: var(--text);
}

.btn-tipo-factura small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-tipo-factura.selected {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
}

/* Modal de Tipo de Venta - Solo diferencias específicas */
#modal-pos-cliente .modal-content {
  max-width: 650px;
  width: 95vw;
  min-height: 450px;
  max-height: 90vh;
}

#modal-pos-cliente .wizard-step-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 280px;
}

#modal-pos-cliente .btn-tipo-venta {
  min-height: 70px;
  border-radius: 8px;
}

/* Lista de clientes con altura fija */
#wizard-lista-clientes {
  min-height: 60px;
}

/* Formulario de nuevo cliente compacto */
#wizard-form-nuevo-cliente .form-group {
  margin-bottom: 10px;
}

/* =========================================
   RESPONSIVE - MEDIA QUERIES
   ========================================= */

/* Móvil y Tablet (< 1024px) - Estilos compartidos y progresivos */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .content-wrapper {
    padding: 15px;
  }
}

/* Móvil (< 768px) - Overrides específicos */
@media (max-width: 767px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 12px;
    border-radius: var(--border-radius-md);
  }

  .card-title {
    font-size: 1rem;
  }

  .btn {
    padding: 8px 14px;
    font-size: 0.85rem;
  }

  .form-control {
    padding: 10px 12px;
    font-size: 16px; /* Previene zoom en iOS */
  }

  /* Sidebar colapsado por defecto en móvil */
  .sidebar {
    position: fixed;
    left: -100%;
    width: 80%;
    max-width: 280px;
    z-index: 1000;
    transition: left 0.3s ease;
  }

  .sidebar.active {
    left: 0;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
  }

  .sidebar-overlay.active {
    display: block;
  }

  /* Botón hamburguesa */
  .menu-toggle {
    display: flex;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .main-content {
    margin-left: 0;
    padding-top: 60px;
  }

  /* Header compacto */
  .page-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .page-header h1 {
    font-size: 1.25rem;
  }

  /* Botones en columna */
  .btn-group {
    flex-direction: column;
    width: 100%;
  }

  .btn-group .btn {
    width: 100%;
    justify-content: center;
  }

  /* Modales full-screen */
  .modal-content {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 15px;
  }

  .modal-footer {
    flex-direction: column;
  }

  .modal-footer .btn {
    width: 100%;
  }

  /* Tablas compactas */
  table {
    font-size: 0.8rem;
  }

  table th,
  table td {
    padding: 8px 6px;
  }

  /* Wizard pasos en columna */
  .wizard-steps {
    flex-direction: column;
    gap: 8px;
  }

  .wizard-step-line {
    display: none;
  }

  /* Botones de tipo factura */
  .btn-tipo-factura-container {
    grid-template-columns: 1fr;
  }

  /* POS ajustes */
  .pos-grid {
    grid-template-columns: 1fr;
  }

  .pos-sidebar {
    order: -1;
  }
}

/* Tablet específico (768px - 1024px) - Solo overrides necesarios */
@media (min-width: 768px) and (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Desktop (> 1024px) - Default, solo ocultar menú hamburguesa */
@media (min-width: 1025px) {
  .menu-toggle {
    display: none;
  }
}

/* =========================================
   🎨 TIPOGRAFÍA FLUIDA PREMIUM
   ========================================= */
h1,
.h1 {
  font-size: var(--h1-size);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 1rem;
}

h2,
.h2 {
  font-size: var(--h2-size);
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.875rem;
}

h3,
.h3 {
  font-size: var(--h3-size);
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.75rem;
}

h4,
.h4 {
  font-size: var(--h4-size);
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 0.5rem;
}

body {
  font-size: var(--body-size);
}

small,
.small {
  font-size: var(--small-size);
}

/* =========================================
   📱 BOTÓN WHATSAPP FLOTANTE - FASE 2
   Solo visible en pestaña Configuración
   ========================================= */
.whatsapp-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--whatsapp) 0%, #128c7e 100%);
  border-radius: 50%;
  display: none; /* Oculto por defecto */
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.75rem;
  text-decoration: none;
  box-shadow:
    0 4px 15px rgba(37, 211, 102, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.1) inset;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 9998;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  animation: whatsappPulse 10s ease-in-out infinite;
}

/* Mostrar solo cuando estamos en la pestaña Configuración */
body.tab-configuracion-active .whatsapp-float,
body:has(#tab-configuracion[style*="display: block"]) .whatsapp-float,
body:has(#tab-configuracion.tab-active) .whatsapp-float {
  display: flex;
}

/* Fallback para navegadores que no soportan :has() */
@media (hover: none) {
  .whatsapp-float.visible {
    display: flex !important;
  }
}

.whatsapp-float:hover {
  transform: scale(1.1) translateY(-4px);
  box-shadow:
    0 8px 25px rgba(37, 211, 102, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.2) inset;
  animation: none;
}

.whatsapp-float::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--whatsapp) 0%, #128c7e 100%);
  opacity: 0.3;
  z-index: -1;
  animation: whatsappRipple 2s ease-out infinite;
}

.whatsapp-float-tooltip {
  position: absolute;
  right: 70px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--border-radius-md);
  font-size: 0.85rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
}

.whatsapp-float:hover .whatsapp-float-tooltip {
  opacity: 1;
  visibility: visible;
  right: 75px;
}

@keyframes whatsappPulse {
  0%,
  90%,
  100% {
    transform: scale(1);
  }
  95% {
    transform: scale(1.05);
  }
}

@keyframes whatsappRipple {
  0% {
    transform: scale(1);
    opacity: 0.3;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

/* WhatsApp flotante en móvil - ajuste de posición */
@media (max-width: 767px) {
  .whatsapp-float {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
  }

  .whatsapp-float-tooltip {
    display: none; /* Ocultar tooltip en móvil, ocupa mucho espacio */
  }
}

/* =========================================
   🔒 FIX MODAL SCROLL LOCK
   ========================================= */
body.modal-open {
  overflow: hidden;
  padding-right: var(--scrollbar-width, 0px);
}

/* Asegurar que el body recupera scroll al cerrar modal */
body:not(.modal-open) {
  overflow: auto;
}
/* Fix: Asegurar que modales permitan interacción cuando están ocultos */
.modal-overlay {
  pointer-events: auto;
}

.modal-overlay[style="display: none"],
.modal-overlay[style*="display: none"] {
  pointer-events: none;
}

/* Fix: Z-index correcto para stacking de modales */
.modal-overlay {
  z-index: 2000;
}

/* =========================================
   🔒 ACCESIBILIDAD - Screen Reader Only
   ========================================= */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.modal {
  z-index: 10000;
}

/* Fix: Overlay del sidebar mobile */
.sidebar-overlay {
  z-index: 999;
}

.sidebar {
  z-index: 1000;
}

.menu-toggle {
  z-index: 1001;
}

/* =========================================
   PRINT STYLES
   ========================================= */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }

  .sidebar,
  .gesi-bubble,
  .gesi-window,
  .btn,
  .filters-top-row,
  .action-buttons-row,
  .search-group,
  .filter-group,
  .modal-overlay,
  .modal-dialog,
  .modal,
  .toast-container,
  .tabs-header,
  #diagnostico-panel {
    display: none !important;
  }

  .main-content,
  .tab-content,
  .tab-pane.active {
    margin-left: 0 !important;
    width: 100% !important;
    display: block !important;
  }

  .stock-table,
  table {
    border: 1px solid #ccc;
  }

  .stock-table th,
  .stock-table td,
  table th,
  table td {
    color: #000 !important;
    border-color: #ccc !important;
  }
}
