/* Estilos específicos para la interfaz del POS */
.card {
  width: 100%;
  max-width: 900px;
  margin: auto;
  background: var(--ui-surface, white);
  color: var(--ui-text, #1e293b);
  border: 1px solid var(--ui-border, #e2e8f0);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  min-height: calc(100vh - 5rem);
}
#login {
  min-height: auto !important; /* Tarjeta de login compacta y pequeña */
}
.tab {
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100vh - 12rem);
  scrollbar-width: thin;
  scrollbar-color: var(--ui-primary, #2563eb) var(--ui-border, #e5e7eb);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
}
/* Asegurar que los tabs ocultos estén realmente ocultos */
.tab.hidden {
  display: none !important;
}
/* Contenedor de productos con scroll independiente dentro del tab */
#productos {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding-right: 0.25rem;
}
.tab::-webkit-scrollbar {
  width: 8px;
}
.tab::-webkit-scrollbar-track {
  background: #e5e7eb;
  border-radius: 4px;
}
body.dark .tab::-webkit-scrollbar-track {
  background: #334155;
}
.tab::-webkit-scrollbar-thumb {
  background-color: #2563eb;
  border-radius: 4px;
  border: 2px solid #e5e7eb;
}
body.dark .tab::-webkit-scrollbar-thumb {
  background-color: #3b82f6;
  border: 2px solid #334155;
}
/* Scrollbar para contenedor de productos */
#productos::-webkit-scrollbar {
  width: 8px;
}
#productos::-webkit-scrollbar-track {
  background: transparent;
}
#productos::-webkit-scrollbar-thumb {
  background-color: #3b82f6;
  border-radius: 4px;
}
.tab-btn {
  flex: 0 0 auto;
  width: auto;
  background-color: var(--ui-surface-raised, #f3f4f6);
  color: var(--ui-muted, #4b5563);
  font-weight: 600;
  min-width: 110px;
  white-space: normal;
  text-align: center;
  padding: 0.75rem 1rem;
  transition: all 0.2s;
}
.tab-btn.active {
  background-color: var(--ui-primary, #2563eb);
  color: white;
}
.app-actions button,
.button-row button,
.app-actions #btnAdmin {
  min-width: auto;
  width: auto;
  flex: 0 0 auto;
}
.producto-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  background-color: var(--ui-surface-raised, #f9fafb);
  border: 1px solid var(--ui-border, #f3f4f6);
  transition: all 0.2s;
}
.producto-row:hover {
  background-color: #f3f4f6;
}
.producto-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
  flex-wrap: nowrap;
}
.producto-controls button {
  min-width: 0;
  min-height: 46px;
  font-size: 1rem;
  transition: all 0.15s;
}
.producto-controls button:nth-child(1),
.producto-controls button:nth-child(2) {
  flex: 0 0 42%;
}
.producto-controls button:nth-child(3) {
  flex: 0 0 16%;
}
.producto-controls button i {
  display: inline-block;
  width: 1em;
  height: 1em;
  text-align: center;
  line-height: 1em;
  pointer-events: none;
}
.producto-info {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto auto;
  gap: 0.75rem;
  align-items: center;
}
.producto-info span:first-child {
  font-weight: 700;
  color: #1f2937;
  min-width: 0;
}
.producto-info span:nth-child(2) {
  text-align: right;
  white-space: nowrap;
  font-size: 0.95rem;
  color: #4b5563;
}
.producto-info .producto-cantidad {
  font-size: 1.1rem;
  font-weight: 800;
  color: #2563eb;
  text-align: right;
  white-space: nowrap;
}
.app-actions,
.button-row {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-start;
  align-items: center;
}
.app-actions {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
}
.app-actions::-webkit-scrollbar {
  display: none;
}
.app-actions button,
.button-row button,
.app-actions #btnAdmin {
  min-width: auto;
  width: auto;
  min-height: 34px;
  flex: 0 0 auto;
  white-space: nowrap;
  align-self: center;
}

.app-actions button {
  height: 40px;
}

.app-actions #btnAdmin.hidden { display: none !important; }
.app-actions #btnAdmin:not(.hidden) { display: inline-flex; }

.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 1rem;
  line-height: 1.2;
  border: 1px solid var(--ui-border, #e2e8f0);
  border-radius: 6px;
}

#app .tab-btn:not(.active) { background-color: var(--ui-surface-raised); color: var(--ui-text); }
#app .tab-btn:not(.active):hover { border-color: var(--ui-primary); }
#app .producto-row { border-radius: 6px; }
#app input,
#app select,
#app textarea {
  border-color: var(--ui-border, #e2e8f0);
  border-radius: 6px;
  background-color: var(--ui-surface, #fff);
  color: var(--ui-text, #1e293b);
}
#app #totalSeleccionado { color: var(--ui-danger, #dc2626); }
#app .text-blue-600 { color: var(--ui-primary, #2563eb); }
#app .bg-blue-600 { background-color: var(--ui-primary, #2563eb); }
#app .bg-blue-600:hover { background-color: var(--ui-primary-hover, #1d4ed8); }
#app .bg-green-600 { background-color: var(--ui-success, #047857); }
#app .bg-green-600:hover { filter: brightness(0.92); }
#app .bg-red-500 { background-color: var(--ui-danger, #dc2626); }
#app .bg-red-500:hover { filter: brightness(0.92); }

.btn-cierre-caja {
  background-color: #ea580c !important;
  color: #ffffff !important;
}

.btn-cierre-caja:hover {
  background-color: #c2410c !important;
}

/* Dark Mode */
body.dark {
  background: var(--ui-bg, #0f172a);
  color: var(--ui-text, #f8fafc);
}
body.dark .card {
  background: var(--ui-surface, #1e293b);
  border-color: var(--ui-border, #475569);
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.45);
}
body.dark .tab-btn {
  background-color: var(--ui-surface-raised, #334155);
  color: var(--ui-muted, #cbd5e1);
}
body.dark .tab-btn.active {
  background-color: var(--ui-primary, #2563eb);
  color: white;
}
body.dark .producto-row {
  background: var(--ui-surface-raised, #334155);
  border-color: var(--ui-border, #475569);
}
body.dark .producto-row:hover {
  background: var(--ui-border, #475569);
}
body.dark .producto-info span:first-child {
  color: #f8fafc;
}
body.dark .producto-info span:nth-child(2) {
  color: #94a3b8;
}
body.dark .producto-info .producto-cantidad {
  color: #3b82f6;
}
/* Ajuste de color para los textos de los labels y p dentro de config en modo oscuro */
body.dark .text-gray-600,
body.dark .text-gray-700,
body.dark .text-gray-800,
body.dark .text-gray-500,
body.dark #config label,
body.dark #config p,
body.dark #dashboard h3,
body.dark #dashboard h4,
body.dark #dashboard p,
body.dark #dashboard .text-gray-600,
body.dark #dashboard .text-gray-700,
body.dark #dashboard .text-gray-800,
body.dark #dashboard .text-gray-500 {
  color: #f8fafc !important;
}
body.dark #dashboard .bg-blue-50,
body.dark #dashboard .bg-green-50,
body.dark #dashboard .bg-purple-50,
body.dark #dashboard .bg-orange-50,
body.dark #dashboard .bg-gray-50 {
  background-color: #334155 !important;
}
body.dark #dashboard .border-gray-200,
body.dark #dashboard .border-gray-700 {
  border-color: #475569 !important;
}

.dashboard-card {
  border: 1px solid #d1d5db;
  border-left-width: 4px;
  border-radius: 0.5rem;
  padding: 0.5rem;
  background-color: #f9fafb;
  color: #111827;
  box-shadow: none;
}

.dashboard-card .dashboard-card-title {
  color: #111827;
  font-weight: 600;
}

.dashboard-card .dashboard-card-subtitle {
  color: #6b7280;
  font-size: 0.75rem;
}

.dashboard-card .dashboard-card-value {
  color: #2563eb;
  font-weight: 700;
  font-size: 1.125rem;
  margin-left: 0.5rem;
}

.dashboard-card--green {
  border-left-color: #16a34a;
}

.dashboard-card--green .dashboard-card-value {
  color: #16a34a;
}

.dashboard-chart-wrapper {
  width: 100%;
  height: 16rem;
  min-height: 16rem;
  max-height: 16rem;
  overflow: hidden;
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
  background-color: rgba(255,255,255,0.7);
  padding: 0.5rem;
}

.dashboard-chart-canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 100%;
}

body.dark .dashboard-card {
  background-color: #1e293b;
  border-color: #475569;
  color: #f8fafc;
}

body.dark .dashboard-card .dashboard-card-title,
body.dark .dashboard-card .dashboard-card-subtitle,
body.dark .dashboard-card .dashboard-card-value,
body.dark #dashboard h3,
body.dark #dashboard h4,
body.dark #dashboard p,
body.dark #dashboard .text-gray-600,
body.dark #dashboard .text-gray-700,
body.dark #dashboard .text-gray-800,
body.dark #dashboard .text-gray-500 {
  color: #f8fafc !important;
}

body.dark .dashboard-card .dashboard-card-subtitle {
  color: #cbd5e1;
}

body.dark .dashboard-card .dashboard-card-value {
  color: #93c5fd;
}

body.dark .dashboard-card--green .dashboard-card-value {
  color: #4ade80;
}

body.dark .dashboard-chart-wrapper {
  border-color: #475569;
  background-color: rgba(15,23,42,0.6);
}
body.dark .border {
  border-color: #475569 !important;
}
body.dark input,
body.dark textarea,
body.dark select {
  background: var(--ui-surface, #1e293b) !important;
  color: var(--ui-text, #f8fafc) !important;
  border-color: var(--ui-border, #475569) !important;
}
body.dark #app #totalSeleccionado { color: var(--ui-danger, #f87171); }
body.dark #app .text-blue-600 { color: var(--ui-primary, #60a5fa); }
body.dark #logVentas li {
  background: #334155 !important;
  color: #f8fafc !important;
  border: 1px solid #475569;
}
body.dark #payment-section {
  background-color: #334155 !important;
  border-color: #475569 !important;
}
body.dark label {
  color: #f8fafc !important; /* Reafirmar que los labels siempre sean claros */
}

body.dark .text-gray-500,
body.dark #config p,
body.dark #config p.text-sm.text-gray-500 {
  color: #cbd5e1 !important;
}
body.dark #config label,
body.dark #config label.flex.items-center,
body.dark #config label.flex.items-center.font-medium.text-gray-800 {
  color: #f8fafc !important;
}

/* Color amarillo brillante para el sol en modo claro */
#icon-sun,
#icon-sun i {
  color: #fbbf24 !important;
}

/* Estilos personalizados para las cajas de configuración (Preferencias) */
.config-box {
  background-color: #f9fafb;
  border-color: #e5e7eb;
}
.config-label {
  color: #1f2937;
}
.config-desc {
  color: #4b5563;
}

/* Override para Modo Oscuro en Preferencias con máxima especificidad */
body.dark .config-box {
  background-color: #334155 !important;
  border-color: #475569 !important;
}
body.dark .config-label {
  color: #f8fafc !important;
}
body.dark .config-desc {
  color: #cbd5e1 !important;
}

/* .app-actions #theme-toggle, #theme-toggle removidos */
.selector-obsoleto-removido {
  /* removido */
  /* removido */
  /* removido */
  /* removido */
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
#nombreImpresora {
  word-break: break-word;
  white-space: normal;
}
.header-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
}
.header-scroll::-webkit-scrollbar {
  display: none;
}
#app .header-scroll { overflow: visible; }

@media (max-width: 768px) {
  .card {
    max-width: 95%;
    padding: 16px;
  }
  #app.card {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    margin: 0;
    padding: 0.75rem;
    border: 0;
    border-radius: 0;
  }
  .producto-row {
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    align-items: center;
  }
  .producto-info {
    grid-template-columns: minmax(120px, 1fr) auto auto;
  }
  .producto-controls {
    width: 100%;
    justify-content: flex-start;
    gap: 0.35rem;
    flex-wrap: nowrap;
  }
  .producto-controls button:nth-child(1),
  .producto-controls button:nth-child(2) {
    flex: 1 1 0;
  }
  .producto-controls button:nth-child(3) {
    flex: 0 0 48px;
  }
  .tab-btn {
    min-width: 0;
    flex: 1 1 0;
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
  }
  .button-row {
    flex-direction: column;
  }
  .app-actions {
    justify-content: flex-start;
  }
  .app-actions button {
    width: auto;
    min-width: 90px;
    min-height: 44px;
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
  }
  .button-row button {
    width: 100%;
    min-width: 0;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }
  .header-scroll { font-size: 0.9rem; }
  .producto-controls button { min-height: 48px; }
  #app .session-trigger { min-height: 44px; }
  #productos .delete-product-btn {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }
  #totalSeleccionado {
    text-align: left;
  }
}

/* Tarea F.5: Estilos de Transición e Interacciones para Gestos Swipe Táctiles (Sumar / Restar) */
.producto-row {
  touch-action: pan-y; /* Permite el scroll vertical normal pero indica interacción táctil */
  position: relative;
  will-change: transform, background-color, border-color;
  transition: transform 0.15s ease-out, background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.15s ease;
}

/* Estado deslizar a la derecha (Sumar - Verde) */
.producto-row.swipe-sumar {
  background-color: #ecfdf5 !important; /* bg-green-50 */
  border-color: #10b981 !important; /* border-green-500 */
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15) !important;
}
body.dark .producto-row.swipe-sumar {
  background-color: rgba(16, 185, 129, 0.15) !important; /* Verde traslúcido en modo oscuro */
  border-color: #10b981 !important;
}

/* Estado deslizar a la izquierda (Restar - Amarillo/Naranja) */
.producto-row.swipe-restar {
  background-color: #fffbeb !important; /* bg-yellow-50 */
  border-color: #f59e0b !important; /* border-yellow-500 */
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15) !important;
}
body.dark .producto-row.swipe-restar {
  background-color: rgba(245, 158, 11, 0.15) !important; /* Amarillo traslúcido en modo oscuro */
  border-color: #f59e0b !important;
}

/* Tarea G.3 / H.3: Forzar el contraste perfecto en la pantalla de actualización */
#updating-screen {
  background-color: #ffffff !important;
}
#updating-screen p,
#updating-screen span {
  color: #111827 !important; /* Texto gris muy oscuro/negro en fondo blanco */
}
#updating-screen .bg-gray-100 {
  background-color: #f3f4f6 !important; /* Fondo del loader claro */
  border-color: #e5e7eb !important;
}

/* Ajustes específicos para Modo Oscuro en la pantalla de actualización */
body.dark #updating-screen {
  background-color: #0f172a !important; /* Fondo oscuro idéntico al body */
}
body.dark #updating-screen p,
body.dark #updating-screen span {
  color: #f8fafc !important; /* Texto blanco puro en modo oscuro */
}
body.dark #updating-screen .bg-gray-100 {
  background-color: #1e293b !important; /* Fondo del loader en modo oscuro */
  border-color: #334155 !important;
}

/* Quitar scroll de pantalla completa en login o actualización de forma hermética */
body:has(#login:not(.hidden)),
body:has(#updating-screen:not(.hidden)) {
  overflow: hidden !important;
  height: 100vh !important;
}