/* ============================================================
   SOFTWARE DE CONTEO — HOJA DE ESTILOS PRINCIPAL
   Archivo: css/styles.css
   Incluir en todas las páginas HTML del sistema
   ============================================================ */

/* --- VARIABLES DE COLOR Y TIPOGRAFÍA --- */
:root {
  --azul:        #1E22AA;
  --azul-oscuro: #161A8A;
  --azul-claro:  #E8E9F8;
  --blanco:      #FFFFFF;
  --gris-fondo:  #F4F5F7;
  --gris-borde:  #D1D5DB;
  --gris-texto:  #6B7280;
  --gris-oscuro: #2D2D2D;
  --verde:       #16A34A;
  --verde-claro: #DCFCE7;
  --rojo:        #DC2626;
  --rojo-claro:  #FEE2E2;
  --amarillo:    #D97706;
  --amarillo-claro: #FEF3C7;
  --naranja:     #EA580C;
  --naranja-claro: #FFEDD5;

  --sombra-sm: 0 1px 3px rgba(0,0,0,0.12);
  --sombra-md: 0 4px 12px rgba(0,0,0,0.10);
  --sombra-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radio:     10px;
  --radio-lg:  16px;
}

/* --- RESET Y BASE --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Nunito Sans', sans-serif;
  background-color: var(--gris-fondo);
  color: var(--gris-oscuro);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  line-height: 1.3;
}

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

a:hover {
  text-decoration: underline;
}

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

/* --- LAYOUT PRINCIPAL --- */
.pagina-contenedor {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.contenido-principal {
  flex: 1;
  padding: 24px 16px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* --- ENCABEZADO (HEADER) --- */
.header {
  background-color: var(--azul);
  color: var(--blanco);
  padding: 0 16px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--sombra-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-marca {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  height: 36px;
  width: 36px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--blanco);
  padding: 2px;
}

.header-logo-placeholder {
  height: 36px;
  width: 60px;
  border: 2px dashed rgba(255,255,255,0.6);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  letter-spacing: 1px;
}

.header-nombre {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--blanco);
}

.header-acciones {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-usuario {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.85);
  display: block;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 480px) {
  .header-usuario {
    max-width: 200px;
    font-size: 0.85rem;
  }
}

/* --- NAVEGACIÓN LATERAL (SIDEBAR) --- */
.layout-con-sidebar {
  display: flex;
  min-height: calc(100vh - 64px);
}

.sidebar {
  width: 240px;
  background-color: var(--blanco);
  border-right: 1px solid var(--gris-borde);
  padding: 16px 0;
  flex-shrink: 0;
  display: none;
}

@media (min-width: 768px) {
  .sidebar { display: block; }
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: var(--gris-oscuro);
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
  background-color: var(--azul-claro);
  color: var(--azul);
  text-decoration: none;
  border-left-color: var(--azul);
}

.sidebar-nav li a.activo {
  background-color: var(--azul-claro);
  color: var(--azul);
  border-left-color: var(--azul);
}

.sidebar-nav .icono {
  font-size: 1.1rem;
  width: 22px;
  text-align: center;
}

.sidebar-contenido {
  flex: 1;
  padding: 24px 16px;
  overflow-x: hidden;
}

/* --- TARJETAS (CARDS) --- */
.card {
  background: var(--blanco);
  border-radius: var(--radio-lg);
  box-shadow: var(--sombra-sm);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--gris-borde);
}

.card-titulo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gris-oscuro);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--gris-fondo);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--blanco);
  border-radius: var(--radio);
  padding: 20px;
  box-shadow: var(--sombra-sm);
  border: 1px solid var(--gris-borde);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card .stat-valor {
  font-family: 'Nunito', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--azul);
  line-height: 1;
}

.stat-card .stat-etiqueta {
  font-size: 0.85rem;
  color: var(--gris-texto);
  font-weight: 600;
}

/* --- FORMULARIOS --- */
.form-grupo {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--gris-oscuro);
  margin-bottom: 6px;
}

.form-label .requerido {
  color: var(--rojo);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--gris-borde);
  border-radius: var(--radio);
  font-family: 'Nunito Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--gris-oscuro);
  background-color: var(--blanco);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(30, 34, 170, 0.12);
}

.form-input.error,
.form-select.error {
  border-color: var(--rojo);
}

.form-input:disabled,
.form-select:disabled {
  background-color: var(--gris-fondo);
  color: var(--gris-texto);
  cursor: not-allowed;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-hint {
  font-size: 0.82rem;
  color: var(--gris-texto);
  margin-top: 4px;
}

.form-error {
  font-size: 0.82rem;
  color: var(--rojo);
  margin-top: 4px;
  font-weight: 600;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 480px) {
  .form-grid-2 { grid-template-columns: 1fr; }
}

/* --- BOTONES --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  min-height: 48px;
  border: none;
  border-radius: var(--radio);
  font-family: 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primario {
  background-color: var(--azul);
  color: var(--blanco);
}

.btn-primario:hover:not(:disabled) {
  background-color: var(--azul-oscuro);
  box-shadow: 0 4px 12px rgba(30,34,170,0.3);
  text-decoration: none;
  color: var(--blanco);
}

.btn-secundario {
  background-color: var(--blanco);
  color: var(--azul);
  border: 2px solid var(--azul);
}

.btn-secundario:hover:not(:disabled) {
  background-color: var(--azul-claro);
  text-decoration: none;
}

.btn-peligro {
  background-color: var(--rojo);
  color: var(--blanco);
}

.btn-peligro:hover:not(:disabled) {
  background-color: #B91C1C;
  text-decoration: none;
  color: var(--blanco);
}

.btn-exito {
  background-color: var(--verde);
  color: var(--blanco);
}

.btn-exito:hover:not(:disabled) {
  background-color: #15803D;
  text-decoration: none;
  color: var(--blanco);
}

.btn-amarillo {
  background-color: var(--amarillo);
  color: var(--blanco);
}

.btn-amarillo:hover:not(:disabled) {
  background-color: #B45309;
  text-decoration: none;
  color: var(--blanco);
}

.btn-gris {
  background-color: var(--gris-fondo);
  color: var(--gris-oscuro);
  border: 1px solid var(--gris-borde);
}

.btn-gris:hover:not(:disabled) {
  background-color: #E5E7EB;
  text-decoration: none;
}

.btn-bloque {
  width: 100%;
  display: flex;
}

.btn-sm {
  padding: 8px 14px;
  min-height: 36px;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 16px 28px;
  min-height: 56px;
  font-size: 1.05rem;
}

/* --- TABLAS --- */
.tabla-contenedor {
  overflow-x: auto;
  border-radius: var(--radio);
  border: 1px solid var(--gris-borde);
  background: var(--blanco);
}

.tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.tabla th {
  background-color: var(--gris-fondo);
  padding: 12px 16px;
  text-align: left;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  color: var(--gris-oscuro);
  font-size: 0.85rem;
  border-bottom: 2px solid var(--gris-borde);
  white-space: nowrap;
}

.tabla td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gris-borde);
  vertical-align: middle;
}

.tabla tbody tr:last-child td {
  border-bottom: none;
}

.tabla tbody tr:hover {
  background-color: var(--gris-fondo);
}

.tabla-acciones {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* --- BADGES / ETIQUETAS DE ESTADO --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  white-space: nowrap;
}

.badge-verde   { background: var(--verde-claro);    color: var(--verde); }
.badge-rojo    { background: var(--rojo-claro);     color: var(--rojo); }
.badge-amarillo{ background: var(--amarillo-claro); color: var(--amarillo); }
.badge-naranja { background: var(--naranja-claro);  color: var(--naranja); }
.badge-azul    { background: var(--azul-claro);     color: var(--azul); }
.badge-gris    { background: var(--gris-fondo);     color: var(--gris-texto); }

/* --- ALERTAS / AVISOS --- */
.alerta {
  padding: 14px 16px;
  border-radius: var(--radio);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alerta-info    { background: var(--azul-claro);     color: var(--azul);     border-left: 4px solid var(--azul); }
.alerta-exito   { background: var(--verde-claro);    color: var(--verde);    border-left: 4px solid var(--verde); }
.alerta-error   { background: var(--rojo-claro);     color: var(--rojo);     border-left: 4px solid var(--rojo); }
.alerta-aviso   { background: var(--amarillo-claro); color: var(--amarillo); border-left: 4px solid var(--amarillo); }

/* --- TOAST NOTIFICATIONS (mensajes flotantes) --- */
#toast-contenedor {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: calc(100vw - 32px);
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radio);
  box-shadow: var(--sombra-lg);
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 260px;
  max-width: 380px;
  animation: toast-entrar 0.3s ease forwards;
  cursor: pointer;
}

.toast.saliendo {
  animation: toast-salir 0.3s ease forwards;
}

.toast-exito  { background: var(--verde);   color: var(--blanco); }
.toast-error  { background: var(--rojo);    color: var(--blanco); }
.toast-aviso  { background: var(--amarillo);color: var(--blanco); }
.toast-info   { background: var(--azul);    color: var(--blanco); }

@keyframes toast-entrar {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toast-salir {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}

/* --- INDICADORES DE ESTADO FLOTANTES (conteo) --- */
.indicador-flotante {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  z-index: 8000;
  padding: 28px 48px;
  border-radius: var(--radio-lg);
  font-family: 'Nunito', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--blanco);
  text-align: center;
  box-shadow: var(--sombra-lg);
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
  pointer-events: none;
}

.indicador-flotante.visible {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

.indicador-verde   { background: var(--verde); }
.indicador-amarillo{ background: var(--amarillo); font-size: 1.1rem; max-width: 320px; }
.indicador-rojo    { background: var(--rojo); animation: parpadeo 0.5s ease infinite; }

@keyframes parpadeo {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* --- MODALES --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-overlay.visible {
  opacity: 1;
}

.modal {
  background: var(--blanco);
  border-radius: var(--radio-lg);
  box-shadow: var(--sombra-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.visible .modal {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gris-borde);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-titulo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gris-oscuro);
}

.modal-cerrar {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--gris-texto);
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s;
}

.modal-cerrar:hover { background: var(--gris-fondo); }

.modal-body {
  padding: 20px 24px;
}

.modal-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--gris-borde);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* --- BARRA DE PROGRESO --- */
.progreso-barra-contenedor {
  background: var(--gris-fondo);
  border-radius: 99px;
  height: 10px;
  overflow: hidden;
}

.progreso-barra {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--azul), #4F54D1);
  transition: width 0.4s ease;
}

.progreso-texto {
  font-size: 0.85rem;
  color: var(--gris-texto);
  font-weight: 600;
  margin-top: 6px;
}

/* --- PÁGINA DE LOGIN --- */
.login-pagina {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--azul) 0%, #3B3FC9 50%, #5A5EDB 100%);
  padding: 16px;
}

.login-card {
  background: var(--blanco);
  border-radius: var(--radio-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
}

.login-logo-contenedor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-logo-placeholder {
  width: 80px;
  height: 80px;
  border: 3px dashed var(--azul);
  border-radius: var(--radio);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--azul);
  letter-spacing: 2px;
}

.login-logo-img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: var(--radio);
}

.login-nombre-sistema {
  font-family: 'Nunito', sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--gris-oscuro);
  text-align: center;
}

/* --- SECCIÓN DE CONTEO (pantalla del escáner) --- */
.conteo-pagina {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--gris-fondo);
}

.conteo-header {
  background: var(--azul);
  color: var(--blanco);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}

.conteo-nombre {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conteo-cuerpo {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 700px;
  margin: 0 auto;
  width: 100%;
}

.campo-scanner {
  background: var(--blanco);
  border-radius: var(--radio-lg);
  padding: 16px;
  box-shadow: var(--sombra-sm);
  border: 2px solid var(--azul-claro);
}

.campo-scanner:focus-within {
  border-color: var(--azul);
}

.campo-scanner label {
  display: block;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--azul);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.campo-scanner input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--gris-borde);
  border-radius: var(--radio);
  font-size: 1.1rem;
  font-family: 'Nunito Sans', sans-serif;
  font-weight: 700;
  letter-spacing: 1px;
}

.campo-scanner input:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(30,34,170,0.12);
}

.producto-card {
  background: var(--blanco);
  border-radius: var(--radio-lg);
  padding: 16px;
  box-shadow: var(--sombra-sm);
  display: none;
}

.producto-card.visible { display: block; }

.producto-info {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.producto-imagen {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radio);
  border: 1px solid var(--gris-borde);
  flex-shrink: 0;
}

.producto-imagen-placeholder {
  width: 72px;
  height: 72px;
  background: var(--gris-fondo);
  border-radius: var(--radio);
  border: 1px solid var(--gris-borde);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
}

.producto-nombre {
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--gris-oscuro);
  margin-bottom: 4px;
}

.producto-sku {
  font-size: 0.85rem;
  color: var(--gris-texto);
  font-weight: 600;
}

.subalmacen-fila {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gris-fondo);
}

.subalmacen-fila:last-child { border-bottom: none; }

.subalmacen-nombre {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gris-oscuro);
  display: flex;
  align-items: center;
  gap: 6px;
}

.subalmacen-input {
  width: 100px;
  padding: 10px 12px;
  border: 1.5px solid var(--gris-borde);
  border-radius: var(--radio);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  font-family: 'Nunito', sans-serif;
}

.subalmacen-input:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(30,34,170,0.12);
}

.conteo-footer {
  background: var(--blanco);
  border-top: 1px solid var(--gris-borde);
  padding: 12px 16px;
  position: sticky;
  bottom: 0;
}

.conteo-progreso-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

/* --- SPINNER DE CARGA --- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: var(--blanco);
  border-radius: 50%;
  animation: girar 0.7s linear infinite;
  display: inline-block;
}

.spinner-azul {
  border-color: rgba(30,34,170,0.2);
  border-top-color: var(--azul);
}

@keyframes girar {
  to { transform: rotate(360deg); }
}

.cargando-pagina {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  gap: 16px;
  color: var(--gris-texto);
  font-weight: 600;
}

/* --- ESTADO VACÍO --- */
.estado-vacio {
  text-align: center;
  padding: 48px 16px;
  color: var(--gris-texto);
}

.estado-vacio .icono-grande {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.estado-vacio p {
  font-size: 0.95rem;
  font-weight: 600;
}

/* --- PIE DE PÁGINA --- */
.footer {
  background: var(--blanco);
  border-top: 1px solid var(--gris-borde);
  padding: 16px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--gris-texto);
}

/* --- UTILIDADES --- */
.texto-centro    { text-align: center; }
.texto-derecha   { text-align: right; }
.texto-azul      { color: var(--azul); }
.texto-verde     { color: var(--verde); }
.texto-rojo      { color: var(--rojo); }
.texto-amarillo  { color: var(--amarillo); }
.texto-gris      { color: var(--gris-texto); }
.negrita         { font-weight: 700; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.oculto { display: none !important; }
.flex { display: flex; }
.flex-centro { display: flex; align-items: center; justify-content: center; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.separador {
  border: none;
  border-top: 1px solid var(--gris-borde);
  margin: 20px 0;
}

/* --- TOGGLE ACTIVOS/CERRADOS --- */
.toggle-grupo {
  display: inline-flex;
  background: var(--gris-fondo);
  border-radius: var(--radio);
  padding: 4px;
  gap: 4px;
  border: 1px solid var(--gris-borde);
}

.toggle-btn {
  padding: 8px 16px;
  border-radius: 7px;
  border: none;
  background: transparent;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--gris-texto);
  transition: background 0.15s, color 0.15s;
}

.toggle-btn.activo {
  background: var(--blanco);
  color: var(--azul);
  box-shadow: var(--sombra-sm);
}

/* --- RESPONSIVE GENERAL --- */
@media (max-width: 768px) {
  .contenido-principal { padding: 16px; }
  .card { padding: 16px; }
  .modal { max-width: 100%; }
  .tabla th, .tabla td { padding: 10px 12px; }
  .btn-lg { padding: 14px 20px; }
}

@media (max-width: 480px) {
  /* Header 2 líneas en mobile: nombre programa + usuario apilados */
  .header {
    min-height: auto;
    padding: 6px 12px;
    gap: 6px;
  }
  .header-marca {
    flex: 1;
    min-width: 0;
  }
  .header-nombre {
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
    line-height: 1.3;
  }
  /* Usuario debajo del nombre del programa */
  .header-acciones {
    flex-direction: row;
    align-items: center;
    gap: 6px;
  }
  .header-usuario {
    font-size: 0.68rem;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: rgba(255,255,255,0.8);
    display: block !important;
    order: -1;
  }
  .header-acciones .btn-sm {
    font-size: 0.65rem;
    padding: 3px 7px;
    min-height: unset;
    line-height: 1.4;
  }
  .login-card { padding: 28px 20px; }
}

/* ============================================================
   MENÚ HAMBURGUESA — NAVEGACIÓN MÓVIL
   ============================================================ */

/* Botón hamburguesa — solo visible en móvil */
.btn-hamburguesa {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  color: var(--blanco);
  font-size: 1.4rem;
  line-height: 1;
  transition: background 0.15s;
}

.btn-hamburguesa:hover {
  background: rgba(255,255,255,0.15);
}

@media (max-width: 767px) {
  .btn-hamburguesa {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

/* Overlay oscuro detrás del sidebar en móvil */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.visible {
  opacity: 1;
}

/* Sidebar en móvil: se desliza desde la izquierda */
@media (max-width: 767px) {
  .sidebar {
    display: block !important;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--sombra-lg);
    overflow-y: auto;
    padding-top: 72px; /* espacio para el header */
  }

  .sidebar.abierto {
    transform: translateX(0);
  }

  .sidebar-overlay.visible {
    display: block;
  }

  /* El contenido no se desplaza cuando el sidebar está abierto */
  body.sidebar-abierto {
    overflow: hidden;
  }

  /* Ajustar el contenido principal en móvil */
  .sidebar-contenido {
    padding: 16px;
  }

  .layout-con-sidebar {
    display: block;
  }
}

/* ============================================================
   MEJORAS RESPONSIVE MÓVIL
   Correcciones para pantallas pequeñas (< 480px y < 768px)
   ============================================================ */

/* ── Card grid: en móvil una sola columna ── */
@media (max-width: 600px) {
  .card-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
}

@media (max-width: 380px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Stat cards: reducir tamaño de fuente en móvil ── */
@media (max-width: 600px) {
  .stat-card .stat-valor {
    font-size: 1.5rem;
  }
  .stat-card {
    padding: 14px;
  }
}

/* ── Tablas: scroll horizontal + columnas más compactas ── */
@media (max-width: 768px) {
  .tabla-contenedor {
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tabla {
    min-width: 700px;
  }

  .tabla th,
  .tabla td {
    padding: 6px 8px;
    font-size: 0.75rem;
    white-space: nowrap;
  }

  /* Mostrar todas las columnas en móvil — scroll horizontal */
  .tabla .col-ocultar-movil {
    display: table-cell;
  }
}

/* ── Botones de acciones en tablas: apilados en móvil ── */
@media (max-width: 600px) {
  .tabla-acciones {
    flex-direction: column;
    gap: 4px;
  }

  .tabla-acciones .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ── Modales: ancho completo con margen en móvil ── */
@media (max-width: 600px) {
  .modal {
    max-width: 100% !important;
    margin: 0 8px;
    border-radius: 12px;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-header,
  .modal-footer {
    padding: 14px 16px;
  }

  .modal-footer {
    flex-wrap: wrap;
  }

  .modal-footer .btn {
    flex: 1;
    min-width: 120px;
  }
}

/* ── Login card: más compacto en móvil ── */
@media (max-width: 480px) {
  .login-card {
    padding: 24px 16px;
    border-radius: 12px;
  }

  .login-logo-placeholder,
  .login-logo-img {
    width: 60px;
    height: 60px;
  }

  .login-nombre-sistema {
    font-size: 1.1rem;
  }
}

/* ── Header: botones más compactos en móvil ── */
@media (max-width: 480px) {
  .header {
    padding: 0 10px;
    height: 56px;
  }

  .header-logo-placeholder {
    display: none;
  }
  .header-nombre {
    font-size: 0.88rem;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .header-acciones {
    gap: 6px;
  }

  .header-acciones .btn-sm {
    padding: 6px 10px;
    font-size: 0.8rem;
    min-height: 36px;
  }
}

/* ── Conteo header: apilar botones en pantallas muy pequeñas ── */
@media (max-width: 400px) {
  .conteo-header {
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
  }

  .conteo-header .btn-sm {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
}

/* ── Scanner card en móvil ── */
@media (max-width: 480px) {
  .scanner-input {
    font-size: 1rem;
    padding: 12px 14px;
  }

  .qty-input {
    width: 80px;
    padding: 8px;
  }
}

/* ── Producto imagen más pequeña en móvil ── */
@media (max-width: 480px) {
  .producto-img,
  .producto-img-placeholder {
    width: 56px;
    height: 56px;
  }

  .producto-nombre {
    font-size: 0.9rem;
  }
}

/* ── Cards con padding reducido en móvil ── */
@media (max-width: 480px) {
  .card {
    padding: 14px;
    border-radius: 10px;
  }

  .sidebar-contenido {
    padding: 12px;
  }
}

/* ── Toggle grupo: scroll horizontal si no caben ── */
@media (max-width: 480px) {
  .toggle-grupo {
    overflow-x: auto;
    max-width: 100%;
  }

  .toggle-btn {
    padding: 7px 12px;
    font-size: 0.82rem;
    white-space: nowrap;
  }
}

/* ── Periodo selector en dashboard ── */
@media (max-width: 480px) {
  .card-titulo-flex {
    flex-direction: column;
    align-items: flex-start;
  }

  .periodo-selector {
    width: 100%;
    justify-content: space-between;
  }

  .periodo-btn {
    flex: 1;
    text-align: center;
  }
}

/* ── Tabla inactividad: columnas reducidas en móvil ── */
@media (max-width: 600px) {
  .tabla td:nth-child(4),
  .tabla th:nth-child(4) {
    display: none; /* Ocultar "Último conteo" en móvil muy pequeño */
  }
}

/* ── Alertas y badges más pequeños en móvil ── */
@media (max-width: 480px) {
  .alerta {
    font-size: 0.85rem;
    padding: 12px 14px;
  }

  .badge {
    font-size: 0.72rem;
    padding: 3px 8px;
  }
}

/* ── Formulario de configuracion: secciones más compactas ── */
@media (max-width: 480px) {
  .config-seccion {
    margin-bottom: 20px;
  }

  .progreso-barra-contenedor {
    height: 8px;
  }
}

/* ── Buttons en móvil: tamaño mínimo para toque fácil ── */
@media (max-width: 768px) {
  .btn {
    min-height: 44px; /* Apple HIG: 44pt mínimo para touch targets */
  }

  .btn-sm {
    min-height: 38px;
    padding: 8px 14px;
  }
}

/* ── Scroll suave para toda la app ── */
html {
  scroll-behavior: smooth;
}

/* ── Evitar zoom en inputs en iOS ── */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="tel"],
  select,
  textarea {
    font-size: 16px !important; /* iOS no hace zoom si font-size >= 16px */
  }
}

/* ── Drawer lateral — botones ── */
.drawer-btn-hamburguesa {
  background: none;
  border: none;
  color: var(--blanco);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 10px 0 0;
  flex-shrink: 0;
  line-height: 1;
}
.drawer-btn-cerrar {
  width: 100%;
  background: rgba(255,255,255,.12);
  color: var(--blanco);
  border: none;
  padding: 10px 0;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: background 0.15s;
}
.drawer-btn-cerrar:hover {
  background: rgba(255,255,255,.22);
}

/* Forzar visibilidad del btn-hamburguesa en páginas sin sidebar (conteo, reconteos) */
.btn-hamburguesa-visible {
  display: flex !important;
  align-items: center;
  justify-content: center;
}

/* Botón de acción destructiva suave (ej: cerrar lista) */
.btn-peligro-suave {
  background: rgba(220,38,38,.1);
  color: var(--rojo);
  border: 1px solid rgba(220,38,38,.3);
  font-family: 'Nunito', sans-serif;
}
.btn-peligro-suave:hover {
  background: rgba(220,38,38,.18);
}
