:root {
  --brand-primary: #44c2c4;
  /* teal */
  --brand-secondary: #f3c02c;
  /* amarillo */
  --brand-light: #e8f7f7;
  /* teal muy claro para fondos */
  /* Unificar azules con Bootstrap */
  --bs-primary: var(--brand-primary);
  --bs-primary-rgb: 68, 194, 196;
  --bs-link-color: var(--brand-primary);
  --bs-link-hover-color: var(--brand-primary);
  /* Forzar variantes de botón primary al mismo color en todos los estados */
  --bs-btn-bg: var(--brand-primary);
  --bs-btn-border-color: var(--brand-primary);
  --bs-btn-hover-bg: var(--brand-primary);
  --bs-btn-hover-border-color: var(--brand-primary);
  --bs-btn-active-bg: var(--brand-primary);
  --bs-btn-active-border-color: var(--brand-primary);
  --bs-btn-focus-shadow-rgb: 68, 194, 196;
  /* Variables para transiciones y sombras */
  --transition-fast: 0.2s ease-in-out;
  --transition-base: 0.3s ease-in-out;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-hover: 0 6px 20px rgba(68, 194, 196, 0.25);
}

/* Estilos ligeros para complementar Bootstrap */

/* Transiciones globales para elementos interactivos */
* {
  transition: box-shadow var(--transition-fast), transform var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}

/* Excluir tablas de productos de las transiciones globales para evitar cambios de color en bordes */
.product-card,
.product-card *,
.product-card .table,
.product-card .table *,
.product-card .table th,
.product-card .table td,
.product-card .table tbody tr,
.product-card .table thead th,
.product-card .table tbody tr td,
.product-card .table tbody tr th {
  transition: none !important;
}

/* Excluir tablas de productos de las transiciones globales */
.product-card *,
.product-card .table *,
.product-card .table th,
.product-card .table td,
.product-card .table tbody tr,
.product-card .table thead th {
  transition: none !important;
}

/* Eliminar todos los efectos hover en tablas de productos */
.product-card .table tbody tr:hover,
.product-card .table tbody td:hover,
.product-card .table tbody th:hover {
  background-color: inherit !important;
  transform: none !important;
  border-color: #e9ecef !important;
  color: inherit !important;
}

/* EXCEPCIÓN: Los encabezados de las tablas deben mantener el color blanco en hover */
.product-card .table thead th:hover {
  color: #fff !important;
}

.product-card .table thead th:hover {
  background: linear-gradient(135deg, var(--brand-primary) 0%, rgba(68, 194, 196, 0.9) 100%) !important;
  color: #fff !important;
  transform: none !important;
}

/* Asegurar que el color del texto de los encabezados de productos no cambie en hover */
.product-card .table thead th,
.product-card .table thead th:hover {
  color: #fff !important;
}

.product-card .table thead th:hover * {
  color: #fff !important;
}

/* Mejoras generales de tarjetas */
.card {
  border: none;
  box-shadow: var(--shadow-sm);
  border-radius: 12px;
  transition: all var(--transition-base);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-bottom: 2px solid var(--brand-light);
  padding: 1.25rem 1.5rem;
  font-weight: 600;
}

.card-body {
  padding: 1.5rem;
}

/* Mejoras en tarjetas de productos */
.product-card {
  border: 1px solid #e9ecef;
  transition: none;
  margin-bottom: 1.5rem;
}

.product-card:hover {
  border-color: #e9ecef !important;
  box-shadow: var(--shadow-sm) !important;
  transform: none !important;
}

.product-card .card-header {
  background: linear-gradient(135deg, rgba(68, 194, 196, 0.05) 0%, #ffffff 100%);
  border-bottom: 2px solid rgba(68, 194, 196, 0.2);
}

.alphabet-btn {
  min-width: 2.1rem;
  transition: all var(--transition-fast);
  border-radius: 8px;
  font-weight: 500;
}

.alphabet-btn:hover:not(.active) {
  background-color: rgba(68, 194, 196, 0.1);
  transform: scale(1.05);
}

.alphabet-scroll {
  overflow-x: auto;
  overflow-y: hidden !important;
  white-space: nowrap;
  scrollbar-width: thin;
  max-height: fit-content;
}

/* Tabs y contenedores navegables en móvil - solo horizontal */
.nav-tabs {
  overflow-x: auto !important;
  overflow-y: hidden !important;
  white-space: nowrap;
  flex-wrap: nowrap;
}

/* Colores de marca */
.btn-primary {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  /* Alinear variables Bootstrap para todos los estados, incluido disabled */
  --bs-btn-bg: var(--brand-primary);
  --bs-btn-border-color: var(--brand-primary);
  --bs-btn-disabled-bg: var(--brand-primary);
  --bs-btn-disabled-border-color: var(--brand-primary);
  transition: all var(--transition-fast);
  border-radius: 8px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  filter: brightness(0.95);
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

/* Estado deshabilitado: mismo color que activo */
.btn-primary:disabled,
.btn-primary.disabled {
  background-color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
}

/* Scroll-to-top forzado al color de marca */
.scroll-top.btn-primary {
  background-color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
}

/* Formularios: focus del mismo color de marca */
.form-control,
.form-select {
  border-radius: 8px;
  border: 1.5px solid #dee2e6;
  transition: all var(--transition-fast);
  padding: 0.625rem 0.875rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.25rem rgba(68, 194, 196, 0.25);
  transform: translateY(-1px);
  background-color: #fff;
}

.form-control:hover:not(:disabled):not([readonly]),
.form-select:hover:not(:disabled) {
  border-color: rgba(68, 194, 196, 0.5);
}

/* Checkbox: color de marca en checked y focus */
.form-check-input:checked {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.form-check-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 .25rem rgba(68, 194, 196, .25);
}

/* Botón primario: anillo de enfoque con color de marca cuando es visible */
.btn-primary:focus-visible {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 .25rem rgba(68, 194, 196, .25);
}

.btn-outline-primary {
  color: var(--brand-primary);
  border-color: var(--brand-primary);
  transition: all var(--transition-fast);
  border-radius: 8px;
  font-weight: 500;
}

.btn-outline-primary:hover {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline-primary:active {
  transform: translateY(0);
}

/* Hover azul para botones outline usados: Aplicar filtros, Limpiar, Todos, Cancelar, Cerrar */
.btn-outline-secondary:hover,
.btn-outline-secondary:active,
.btn-outline-dark:hover,
.btn-outline-dark:active {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
  box-shadow: none;
}

/* Quitar el estado de focus después de hacer clic */
.btn-outline-secondary:focus:not(:focus-visible),
.btn-outline-dark:focus:not(:focus-visible) {
  background-color: transparent;
  border-color: inherit;
  color: inherit;
  box-shadow: none;
  outline: none;
}

/* Mantener el focus visible solo para accesibilidad con teclado */
.btn-outline-secondary:focus-visible,
.btn-outline-dark:focus-visible {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
  box-shadow: 0 0 0 0.25rem rgba(68, 194, 196, 0.25);
}

/* Estilo mejorado para el botón Limpiar en historial */
#btnClearFilters {
  border-width: 2px;
  font-weight: 500;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#btnClearFilters:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

#btnClearFilters:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#btnClearFilters i {
  margin-right: 0.25rem;
}

/* Botón acento (amarillo) */
.btn-accent {
  color: #0f2a2a;
  background-color: var(--brand-secondary);
  border-color: var(--brand-secondary);
  transition: all var(--transition-fast);
  border-radius: 8px;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.btn-accent:hover {
  filter: brightness(0.95);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(243, 192, 44, 0.3);
}

.btn-accent:active {
  transform: translateY(0);
}

.bg-accent {
  background-color: var(--brand-secondary) !important;
}

.nav-tabs {
  border-bottom: 2px solid #e9ecef;
  gap: 0.5rem;
}

.nav-tabs .nav-link {
  border: none;
  border-bottom: 3px solid transparent;
  color: #6c757d;
  font-weight: 500;
  padding: 0.75rem 1.25rem;
  transition: all var(--transition-fast);
  border-radius: 8px 8px 0 0;
  margin-bottom: -2px;
}

.nav-tabs .nav-link:hover {
  border-bottom-color: rgba(68, 194, 196, 0.5);
  color: var(--brand-primary);
  background-color: rgba(68, 194, 196, 0.05);
}

.nav-tabs .nav-link.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  background-color: rgba(68, 194, 196, 0.1);
  font-weight: 600;
}

.alphabet-btn {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  transition: all var(--transition-fast);
  border-radius: 8px;
  font-weight: 500;
}

.alphabet-btn.active {
  background-color: var(--brand-primary);
  color: #fff;
  box-shadow: var(--shadow-md);
  transform: scale(1.05);
}

.product-card .table thead th {
  background-color: var(--brand-primary);
  color: #fff;
}

.product-card .table thead th {
  white-space: nowrap;
}

.product-card .table tfoot td {
  font-weight: 600;
}

.product-title {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.badge-unit {
  font-weight: 500;
}

.card-header small {
  display: block;
}

.brand-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

/* Textos cortos solo en móvil para botones del historial */
#historyFilters .label-short {
  display: none;
}

#historyFilters .label-full {
  display: inline;
}

@media (max-width: 576px) {
  .brand-logo {
    height: 32px;
  }

  /* Navbar responsive mejorado - Solo para navbars antiguos, no top-navbar */
  .navbar:not(.top-navbar) {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    min-height: auto;
    box-shadow: var(--shadow-sm);
  }

  .navbar .container-fluid {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
    position: relative;
    padding-left: 1rem;
    padding-right: 1rem;
    display: flex;
  }

  /* Primera fila: botones a la derecha (encima del título) */
  .navbar .d-flex.ms-auto {
    order: 1;
    width: 100%;
    justify-content: flex-end;
    margin: 0 !important;
    padding: 0;
    flex-wrap: nowrap;
    gap: 0.5rem;
    align-self: flex-end;
    position: static;
    z-index: 1;
    margin-bottom: 1.25rem !important;
  }

  /* Segunda fila: logo y título centrados (debajo de los botones) */
  .navbar .navbar-brand.centered-brand {
    order: 2;
    position: static;
    left: auto;
    transform: translateX(-3.5rem);
    width: 100%;
    max-width: 100%;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    row-gap: 0.4rem;
    margin: 0 auto;
    padding: 0 6rem 0 1rem;
    clear: both;
    margin-top: 0 !important;
    padding-top: 0;
    z-index: 0;
  }

  .navbar .navbar-brand span {
    font-size: 0.85rem;
    text-align: center;
    white-space: normal;
    line-height: 1.3;
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Tercera fila: info de usuario */
  .navbar #userInfo {
    order: 3;
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    padding: 0.4rem 0.5rem;
    margin: 0;
    margin-top: 0.75rem;
    background-color: rgba(68, 194, 196, 0.1);
    border-radius: 0.375rem;
    display: block;
  }

  .navbar button {
    flex: 0 0 auto;
    min-width: 44px !important;
    min-height: 44px !important;
    font-size: 0.8rem;
    padding: 0.75rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.4rem;
    position: relative !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    z-index: 1 !important;
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
  }

  .navbar button i {
    font-size: 1.1rem;
    pointer-events: none;
    flex-shrink: 0;
  }

  .navbar button span:not(.badge) {
    display: none !important;
  }

  .scroll-top {
    width: 40px;
    height: 40px;
  }

  /* Organizar botones de productos y procesos en móvil */
  /* El contenedor principal de búsqueda y botones */
  #viewProducts .card-header>.d-flex.flex-wrap {
    flex-direction: column;
    gap: 1rem !important;
    align-items: stretch !important;
  }

  /* Campo de búsqueda - ancho completo y arriba */
  #productSearch {
    max-width: 100% !important;
    width: 100% !important;
    margin-bottom: 0.5rem;
    order: 1;
  }

  /* Contenedor de botones - organizar en grid 2x3 */
  #productButtonsContainer {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: auto auto auto !important;
    gap: 0.75rem !important;
    width: 100%;
    align-items: stretch;
    order: 2;
  }

  /* Asegurar que el input oculto no afecte el grid */
  #productButtonsContainer input[type="file"] {
    display: none !important;
    grid-column: none !important;
    grid-row: none !important;
  }

  /* Botones en móvil - ancho completo de su celda */
  #productButtonsContainer .btn {
    width: 100%;
    padding: 0.75rem 0.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
    white-space: normal;
    line-height: 1.3;
    min-height: 48px;
    word-break: break-word;
    overflow-wrap: break-word;
    flex-direction: row;
    box-sizing: border-box;
    margin: 0;
  }

  /* Iconos en botones */
  #productButtonsContainer .btn i {
    flex-shrink: 0;
    font-size: 1.1rem;
  }

  /* Grid 2x2: Crear | Editar en primera fila, Importar | Eliminar en segunda fila */
  /* Usar IDs específicos para evitar problemas con el input oculto */

  /* Crear Producto - primera fila, primera columna */
  #btnAddProduct {
    grid-column: 1;
    grid-row: 1;
  }

  /* Editar Producto - primera fila, segunda columna */
  #btnEditProduct {
    grid-column: 2;
    grid-row: 1;
  }

  /* Importar Excel - segunda fila, primera columna */
  #btnLoadExcel {
    grid-column: 1;
    grid-row: 2;
  }

  /* Eliminar Productos - segunda fila, segunda columna */
  #btnDeleteProducts {
    grid-column: 2;
    grid-row: 2;
  }

  /* Exportar Excel - tercera fila, centrado con mismo tamaño que otros botones */
  #btnExportProducts {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-self: center;
    width: calc(50% - 0.375rem) !important;
    max-width: calc(50% - 0.375rem);
    min-width: 0;
  }

  /* Si el botón Eliminar no está visible (admin-only), Importar ocupa toda la fila */
  #btnLoadExcel:only-of-type,
  #productButtonsContainer .btn:last-child#btnLoadExcel {
    grid-column: 1 / -1;
  }

  /* Para usuarios vendedor: centrar el botón Importar Excel cuando es el único visible */
  body:not(.admin) #productButtonsContainer {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    grid-template-columns: unset !important;
    grid-template-rows: unset !important;
  }

  body:not(.admin) #productButtonsContainer #btnLoadExcel {
    grid-column: unset !important;
    grid-row: unset !important;
    max-width: 300px;
    width: auto;
    min-width: 200px;
  }

  /* Tablas de productos - scroll horizontal para ver todas las columnas */
  .product-card .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    display: block;
  }

  .product-card .table {
    min-width: 1000px;
    width: 100%;
    margin: 0;
  }

  .product-card .table th,
  .product-card .table td {
    padding: .5rem .4rem;
    font-size: .8125rem;
    white-space: nowrap;
    vertical-align: middle;
  }

  /* Columna de Análisis - permitir texto largo con ajuste */
  .product-card .table th:nth-child(3),
  .product-card .table td:nth-child(3) {
    white-space: normal;
    min-width: 180px;
    max-width: 250px;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Columna de Código - ancho fijo */
  .product-card .table th:nth-child(2),
  .product-card .table td:nth-child(2) {
    min-width: 80px;
    max-width: 120px;
  }

  /* Columna de Método - ancho moderado */
  .product-card .table th:nth-child(4),
  .product-card .table td:nth-child(4) {
    min-width: 100px;
    max-width: 150px;
    white-space: normal;
    word-wrap: break-word;
  }

  /* Columnas numéricas - ancho fijo */
  .product-card .table th:nth-child(5),
  .product-card .table td:nth-child(5),
  .product-card .table th:nth-child(6),
  .product-card .table td:nth-child(6) {
    min-width: 80px;
    text-align: center;
  }

  /* Columnas de valores unitarios - ancho fijo */
  .product-card .table th:nth-child(7),
  .product-card .table td:nth-child(7),
  .product-card .table th:nth-child(8),
  .product-card .table td:nth-child(8),
  .product-card .table th:nth-child(9),
  .product-card .table td:nth-child(9),
  .product-card .table th:nth-child(10),
  .product-card .table td:nth-child(10),
  .product-card .table th:nth-child(11),
  .product-card .table td:nth-child(11) {
    min-width: 120px;
    text-align: center;
  }

  /* Mostrar todas las columnas - no ocultar ninguna */
  /* Ocultar solo el pie para evitar desalineaciones en móvil */
  .product-card .table tfoot {
    display: none;
  }

  /* Tabs: scroll horizontal en móvil - solo horizontal, sin vertical */
  .nav-tabs {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    flex-wrap: nowrap;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
    max-height: 100%;
  }

  .nav-tabs .nav-item {
    flex: 0 0 auto;
    min-width: 0;
  }

  .nav-tabs .nav-link {
    width: auto;
    padding: .45rem .6rem;
    white-space: nowrap;
    font-size: .9rem;
    text-align: center;
  }

  /* Alfabeto A-Z compacto */
  .alphabet-btn {
    min-width: 2rem !important;
    width: 2rem !important;
    height: 2rem !important;
    min-height: 2rem !important;
    padding: 0 !important;
    font-size: 0.85rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    line-height: 1 !important;
    font-weight: 500 !important;
  }

  #alphabetNav {
    gap: .25rem !important;
    justify-content: flex-start !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-height: fit-content !important;
  }

  /* Asegurar que el botón "Todos" no se corte - aumentar ancho */
  #alphabetNav>button:first-child {
    min-width: 3.5rem !important;
    width: auto !important;
    padding: .25rem .75rem !important;
  }

  /* Asegurar que alphabet-scroll no tenga scroll vertical */
  .alphabet-scroll {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-height: fit-content !important;
  }

  /* Historial: agrupar filtros 2 por fila */
  #historyFilters {
    row-gap: .5rem;
  }

  #historyFilters .label-full {
    display: none;
  }

  #historyFilters .label-short {
    display: inline;
  }

  #historyFilters>.col-auto {
    flex: 0 0 100%;
    min-width: 0;
  }

  #historyFilters>.col-auto:nth-child(1),
  #historyFilters>.col-auto:nth-child(2),
  #historyFilters>.col-auto:nth-child(3),
  #historyFilters>.col-auto:nth-child(4) {
    flex: 0 0 calc(50% - .25rem);
    min-width: 0;
  }

  #historyFilters>.col-auto:nth-child(5),
  #historyFilters>.col-auto:nth-child(6) {
    flex: 0 0 calc(50% - .25rem);
    min-width: 0;
  }

  #historyFilters input,
  #historyFilters select {
    width: 100%;
  }

  #historyFilters>.col-auto:nth-child(7) {
    flex: 0 0 100%;
    display: flex;
    justify-content: center;
  }

  /* Campos de fecha en móvil: mostrar labels y asegurar visibilidad */
  #historyFilters input[type="date"] {
    min-height: 38px;
    color-scheme: light;
  }

  /* Mostrar labels visibles para campos de fecha en móvil */
  #historyFilters>.col-auto:nth-child(5) label,
  #historyFilters>.col-auto:nth-child(6) label {
    display: block !important;
    visibility: visible !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 0 0.25rem 0 !important;
    overflow: visible !important;
    clip: auto !important;
    clip-path: none !important;
    white-space: normal !important;
    font-size: 0.875rem;
    font-weight: 500;
    color: #495057;
  }

  /* Modales en móvil vertical: asegurar que el botón de cerrar funcione */
  .modal {
    z-index: 1055 !important;
    padding: 0 !important;
  }

  .modal-dialog,
  .modal-dialog-centered {
    max-height: 100vh !important;
    height: 100vh !important;
    margin: 0 auto !important;
    padding: 1rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: auto !important;
    transform: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .modal-dialog-centered {
    justify-content: center !important;
    align-items: center !important;
  }

  .modal-content {
    max-height: 85vh !important;
    max-width: 95% !important;
    width: 100% !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    margin: 0 auto !important;
    border-radius: 0.75rem !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2) !important;
  }

  .modal-header {
    flex-shrink: 0 !important;
    position: relative !important;
    z-index: 1000 !important;
    background-color: #fff !important;
    padding: 1rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    border-bottom: 1px solid #dee2e6 !important;
    order: 1 !important;
  }

  /* Botón de cerrar siempre accesible y clickeable - PRIORIDAD MÁXIMA */
  .modal-header .btn-close,
  button.btn-close[data-bs-dismiss="modal"] {
    position: relative !important;
    z-index: 9999 !important;
    flex-shrink: 0 !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0.75rem !important;
    margin: 0 !important;
    margin-left: auto !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.2) !important;
    cursor: pointer !important;
    background-color: transparent !important;
    border: none !important;
    display: block !important;
    visibility: visible !important;
    order: 999 !important;
  }

  .modal-header .btn-close::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: -1 !important;
  }

  .modal-body {
    overflow-y: auto !important;
    flex: 1 1 auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 1rem !important;
    order: 2 !important;
    position: relative !important;
    z-index: 1 !important;
  }

  .modal-footer {
    flex-shrink: 0 !important;
    background-color: #fff !important;
    padding: 0.75rem 1rem !important;
    border-top: 1px solid #dee2e6 !important;
    order: 3 !important;
    position: relative !important;
    z-index: 1 !important;
  }

  /* Modales grandes en móvil - tamaño más compacto */
  .modal-lg .modal-content {
    max-width: 95% !important;
    width: 100% !important;
  }

  /* Modales extra grandes en móvil - tamaño más compacto */
  .modal-xl .modal-content {
    max-width: 95% !important;
    width: 100% !important;
  }

  /* Modales normales en móvil - tamaño más compacto */
  .modal-dialog:not(.modal-lg):not(.modal-xl) .modal-content {
    max-width: 90% !important;
    width: 100% !important;
  }

  /* Asegurar que el backdrop no bloquee */
  .modal-backdrop {
    z-index: 1040 !important;
    pointer-events: auto !important;
  }

  /* Asegurar que ningún elemento del modal-body bloquee el header */
  .modal-body * {
    position: relative;
    z-index: 1;
  }

  /* El título del modal no debe bloquear el botón */
  .modal-title {
    flex: 1 1 auto;
    margin: 0;
    padding-right: 0.5rem;
  }
}

/* Desktop: dar más respiro al header */
@media (min-width: 992px) {
  .navbar {
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
    box-shadow: var(--shadow-sm);
    background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
  }
}

/* Centrar marca en navbar manteniendo acciones a la derecha */
.navbar .navbar-brand.centered-brand {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* En desktop y tablet, mostrar userInfo junto a los botones */
@media (min-width: 577px) {
  .navbar .container-fluid {
    flex-direction: row;
    gap: 0;
  }

  .navbar #userInfo {
    order: 0;
    display: inline;
    margin: 0 0.5rem 0 1.5rem;
    padding: 0;
    background-color: transparent;
    border-radius: 0;
    width: auto;
    align-self: center;
  }

  .navbar .d-flex.ms-auto {
    order: 1;
    width: auto;
    align-self: center;
    margin-left: auto;
  }

  .navbar .navbar-brand.centered-brand {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    order: 0;
    margin-top: 0;
    width: auto;
  }
}

/* Mejoras responsive para tablet */
@media (min-width: 577px) and (max-width: 991px) {
  .navbar .navbar-brand span {
    font-size: 0.95rem;
  }

  .navbar button {
    font-size: 0.875rem;
    padding: 0.5rem 0.8rem;
  }

  .navbar #userInfo {
    font-size: 0.85rem;
  }
}

/* Encabezados de todas las tablas con color de botones A-Z */
.table thead th {
  background: linear-gradient(135deg, var(--brand-primary) 0%, rgba(68, 194, 196, 0.9) 100%);
  color: #fff !important;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.5px;
  padding: 1rem 0.75rem;
  border: none;
}

/* Asegurar que todos los elementos dentro de los encabezados mantengan el color blanco */
.table thead th,
.table thead th *,
.table thead th span,
.table thead th i,
.table thead th a {
  color: #fff !important;
}

/* Cuadrícula (bordes) para todas las tablas */
.table {
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 8px;
  overflow: hidden;
}

.table th,
.table td {
  border: 1px solid #e9ecef;
  padding: 0.875rem 0.75rem;
  transition: none;
}

.table th:hover,
.table td:hover {
  border-color: #e9ecef !important;
}

.table thead th {
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.table thead th:last-child {
  border-right: none;
}

.table tbody tr {
  transition: none;
}

.table tbody tr:hover {
  background-color: transparent;
  transform: none;
}

.table tbody tr:not(:last-child) td {
  border-bottom: 1px solid #e9ecef;
}

/* Estilos para página de login */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: url('../images/Hero.webp');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  padding: 2rem;
  position: relative;
}

.login-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(68, 194, 196, 0.1) 0%, rgba(243, 192, 44, 0.05) 100%);
  z-index: 0;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 3rem;
  width: 100%;
  max-width: 520px;
  position: relative;
  z-index: 1;
  transition: all var(--transition-base);
  border: 1px solid rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
}

.login-card:hover {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
  transform: translateY(-4px);
}

.login-card .brand-logo {
  max-width: 200px;
  height: auto;
}

/* Ocultar elementos según rol - Por defecto ocultos */
.admin-only {
  display: none !important;
}

/* Mostrar pestañas admin solo cuando body tiene clase admin */
body.admin .nav-item.admin-only {
  display: list-item !important;
}

/* Mostrar botones y otros elementos admin-only cuando body tiene clase admin */
body.admin .admin-only {
  display: inline-block !important;
}

body.admin button.admin-only,
body.admin .btn.admin-only {
  display: inline-block !important;
}

/* Asegurar que los botones admin-only se muestren correctamente */
body.admin #btnDeleteProducts.admin-only,
body.admin #btnAddProduct.admin-only,
body.admin #btnEditProduct.admin-only {
  display: inline-block !important;
  visibility: visible !important;
  pointer-events: auto !important;
  position: relative !important;
  z-index: 1 !important;
}

/* Asegurar que las secciones admin-only SIEMPRE estén ocultas para no-admin */
/* Estas reglas tienen mayor especificidad y se aplican sin importar d-none */
body:not(.admin) #viewStats,
body:not(.admin) #viewUsers,
body:not(.admin) section#viewStats,
body:not(.admin) section#viewUsers {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* Asegurar que las secciones con d-none SIEMPRE estén ocultas, incluso para admin */
/* Esto tiene prioridad sobre cualquier otra regla para mantener el sistema de pestañas funcionando */
section.d-none,
#viewStats.d-none,
#viewUsers.d-none,
#viewHistory.d-none,
#viewClients.d-none,
#viewContactos.d-none,
#viewProducts.d-none {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* Asegurar que las secciones admin ocupen todo el ancho disponible */
#viewStats,
#viewUsers {
  width: 100%;
}

#viewStats .card,
#viewUsers .card {
  width: 100%;
  max-width: 100%;
}

/* Permitir mostrar secciones admin solo si es admin Y no tiene d-none */
/* Pero el sistema de pestañas (JavaScript) controla qué sección mostrar */
body.admin #viewStats:not(.d-none),
body.admin #viewUsers:not(.d-none),
body.admin section#viewStats:not(.d-none),
body.admin section#viewUsers:not(.d-none) {
  /* No forzar display aquí - dejar que JavaScript lo controle */
  /* Solo asegurar que si no tiene d-none y es admin, pueda mostrarse */
}

/* Ancho mínimo para tablas de productos y scroll horizontal limpio en móviles */
.product-card .table {
  min-width: 900px;
}

/* Botón scroll-to-top */
.scroll-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1030;
  display: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  padding: 0;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-base);
}

.scroll-top.show {
  display: inline-flex;
  animation: fadeInUp 0.3s ease-out;
}

.scroll-top:hover {
  transform: translateY(-4px) scale(1.1);
  box-shadow: var(--shadow-hover);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Sin efectos hover en encabezados de tablas - mantener color del texto constante */
.table thead th:hover {
  background: linear-gradient(135deg, var(--brand-primary) 0%, rgba(68, 194, 196, 0.9) 100%) !important;
  color: #fff !important;
  transform: none;
}

/* Asegurar que el color del texto de los encabezados no cambie en hover */
.table thead th:hover,
.table thead th:hover *,
.table thead th:hover span,
.table thead th:hover i,
.table thead th:hover a {
  color: #fff !important;
}

.product-card .table thead th:hover {
  background: linear-gradient(135deg, var(--brand-primary) 0%, rgba(68, 194, 196, 0.9) 100%) !important;
  color: #fff !important;
  transform: none !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}

/* Asegurar que el color del texto de los encabezados de productos no cambie en hover */
.product-card .table thead th,
.product-card .table thead th:hover {
  color: #fff !important;
}

.product-card .table thead th:hover * {
  color: #fff !important;
}

/* Eliminar TODOS los efectos de cambio de color de borde en tablas de productos */
.product-card .table,
.product-card .table *,
.product-card .table th,
.product-card .table td,
.product-card .table tbody tr,
.product-card .table tbody tr td,
.product-card .table tbody tr th {
  border-color: #e9ecef !important;
}

.product-card .table:hover,
.product-card .table *:hover,
.product-card .table th:hover,
.product-card .table td:hover,
.product-card .table tbody tr:hover,
.product-card .table tbody tr:hover td,
.product-card .table tbody tr:hover th {
  border-color: #e9ecef !important;
}

/* Eliminar TODOS los efectos hover en tablas de productos */
.product-card .table tbody tr {
  transition: none !important;
}

.product-card .table tbody tr:hover {
  background-color: transparent !important;
  transform: none !important;
}

.product-card .table th,
.product-card .table td {
  transition: none !important;
  border-color: #e9ecef !important;
}

.product-card .table th:hover,
.product-card .table td:hover {
  border-color: #e9ecef !important;
  background-color: transparent !important;
  transform: none !important;
  color: inherit !important;
}

/* EXCEPCIÓN: Los encabezados de las tablas (thead th) siempre deben ser blancos */
.product-card .table thead th,
.product-card .table thead th:hover,
.product-card .table thead th:hover * {
  color: #fff !important;
}

/* Forzar que los bordes de las tablas de productos NO cambien de color al hacer hover */
.product-card .table tbody tr:hover th,
.product-card .table tbody tr:hover td {
  border-color: #e9ecef !important;
  background-color: transparent !important;
  color: inherit !important;
}

/* EXCEPCIÓN CRÍTICA: Los encabezados de las tablas siempre deben mantener el color blanco, incluso en hover */
.product-card .table thead tr:hover th,
.product-card .table thead tr:hover th *,
.product-card .table thead th:hover,
.product-card .table thead th:hover * {
  border-color: rgba(255, 255, 255, 0.2) !important;
  background: linear-gradient(135deg, var(--brand-primary) 0%, rgba(68, 194, 196, 0.9) 100%) !important;
  color: #fff !important;
}

/* Footer delgado y discreto */
.site-footer {
  padding: .35rem 0;
  font-size: .85rem;
  color: #6c757d;
  background-color: #fff;
  border-top: 1px solid #dee2e6;
  margin-top: auto;
}

/* Sticky footer: el contenido ocupa el alto y el footer cae al final */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================
   SIDEBAR LATERAL IZQUIERDO
   ============================================ */

#mainContent {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

/* Navbar superior */
.top-navbar {
  position: sticky;
  top: 0;
  z-index: 1050;
  background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
  box-shadow: var(--shadow-sm);
  padding: 0.75rem 1rem;
  padding-right: 1.5rem;
  transition: opacity var(--transition-base), visibility var(--transition-base), transform var(--transition-base);
  overflow: visible !important;
}

/* En móvil, permitir que el botón esté completamente a la izquierda */
@media (max-width: 575px) {
  .top-navbar {
    padding-left: 0 !important;
  }
}

/* Ocultar el navbar superior cuando el sidebar está abierto */
body.sidebar-open .top-navbar {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-100%);
  pointer-events: none;
  height: 0;
  overflow: hidden;
  padding: 0;
  margin: 0;
}

.top-navbar .container-fluid {
  display: flex;
  align-items: center;
  gap: 1rem;
  overflow: visible !important;
}

.top-navbar .navbar-brand {
  flex-grow: 1;
  margin: 0;
  display: flex !important;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #212529;
  flex-shrink: 1;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.top-navbar .container-fluid {
  flex-wrap: nowrap;
  overflow: visible !important;
  position: relative;
  display: flex;
  align-items: center;
}

/* Asegurar que el botón sidebarToggle esté siempre accesible */
.top-navbar #sidebarToggle {
  order: -1 !important;
  z-index: 1052 !important;
  pointer-events: auto !important;
  position: relative !important;
  flex-shrink: 0 !important;
  touch-action: manipulation !important;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
}

/* Asegurar que el navbar-brand no bloquee el botón */
.top-navbar .navbar-brand {
  margin-left: 0 !important;
  padding-left: 0 !important;
  pointer-events: auto;
}

/* Asegurar que el contenedor no bloquee el botón */
.top-navbar .container-fluid>#sidebarToggle {
  position: relative !important;
  z-index: 1052 !important;
  pointer-events: auto !important;
}

/* Asegurar que ningún elemento bloquee el botón */
.top-navbar .container-fluid>* {
  position: relative;
}

.top-navbar .container-fluid>#sidebarToggle {
  z-index: 1053 !important;
}

/* Asegurar que el contenedor de botones permita ver el badge */
.top-navbar .d-flex.ms-auto {
  overflow: visible !important;
  position: relative;
  flex-shrink: 0;
}

.top-navbar .navbar-brand img.brand-logo {
  height: 40px !important;
  width: auto;
  object-fit: contain;
  display: block !important;
  flex-shrink: 0;
}

.top-navbar .navbar-brand span {
  font-size: 0.95rem;
  font-weight: 600;
  color: #212529;
  white-space: normal;
  display: inline-block !important;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

/* Mejorar visualización del texto en pantallas medianas y grandes */
@media (min-width: 768px) {
  .top-navbar .navbar-brand span {
    font-size: 1rem;
    white-space: normal;
    max-width: 400px;
  }

  /* Asegurar que los botones se vean bien en tablet */
  .top-navbar .d-flex.ms-auto {
    gap: 0.75rem !important;
  }

  .top-navbar .d-flex.ms-auto .btn {
    padding: 0.5rem 1rem !important;
    white-space: nowrap !important;
  }
}

@media (min-width: 992px) {
  .top-navbar .navbar-brand span {
    max-width: 500px;
  }

  /* Botones completos en desktop */
  .top-navbar .d-flex.ms-auto .btn span:not(.badge) {
    display: inline !important;
  }
}

/* En pantallas pequeñas, ocultar el logo y mostrar solo el botón hamburguesa */
@media (max-width: 575px) {
  .top-navbar {
    padding: 0.5rem 0.5rem !important;
    padding-left: 0 !important;
    min-height: 56px !important;
    overflow: visible !important;
  }

  .top-navbar .container-fluid {
    gap: 0.25rem !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding-left: 0 !important;
    padding-right: 0.25rem !important;
    overflow: visible !important;
    width: 100% !important;
  }

  /* Ocultar el logo en móvil - el botón hamburguesa ocupará su lugar */
  .top-navbar .navbar-brand {
    display: none !important;
  }

  /* Botón sidebar toggle - en la posición del logo, completamente a la izquierda */
  .top-navbar #sidebarToggle {
    padding: 0.5rem !important;
    min-width: 44px !important;
    max-width: 44px !important;
    width: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    height: 44px !important;
    font-size: 1.25rem !important;
    margin: 0 !important;
    margin-right: 0.75rem !important;
    flex-shrink: 0 !important;
    order: 1 !important;
    align-self: center !important;
    margin-left: 0 !important;
  }

  /* Contenedor de botones derecho - prioridad máxima, tamaño fijo */
  .top-navbar .d-flex.ms-auto {
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    gap: 0.3rem !important;
    min-width: 90px !important;
    width: 90px !important;
    max-width: 90px !important;
    overflow: visible !important;
    order: 3 !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    justify-content: flex-end !important;
    align-items: center !important;
    position: relative !important;
    z-index: 10 !important;
  }

  /* Botones del navbar - solo iconos en móvil, tamaño fijo */
  .top-navbar .d-flex.ms-auto .btn {
    padding: 0.35rem !important;
    min-width: 40px !important;
    max-width: 40px !important;
    width: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    height: 40px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    overflow: visible !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    border-radius: 6px !important;
    position: relative !important;
    white-space: nowrap !important;
  }

  /* Asegurar que el botón de cotización tenga espacio para el badge */
  .top-navbar .d-flex.ms-auto #openCartBtn {
    padding-right: 0.45rem !important;
    overflow: visible !important;
    position: relative !important;
  }

  .top-navbar .d-flex.ms-auto .btn span:not(.badge) {
    display: none !important;
  }

  .top-navbar .d-flex.ms-auto .btn i {
    margin: 0 !important;
    font-size: 1rem !important;
    line-height: 1 !important;
  }

  /* Ajustar badge del contador en móvil */
  #openCartBtn {
    padding: 0.35rem !important;
    padding-right: 0.4rem !important;
    padding-left: 0.4rem !important;
  }

  #cartCount {
    right: -2px !important;
    top: -6px !important;
  }
}

/* Asegurar que los estilos antiguos del navbar no afecten al top-navbar */
.top-navbar.navbar .container-fluid {
  flex-direction: row !important;
  align-items: center !important;
  gap: 1rem !important;
}

.top-navbar.navbar .navbar-brand {
  order: 0 !important;
  transform: none !important;
  position: static !important;
  width: auto !important;
  max-width: none !important;
  justify-content: flex-start !important;
  flex-direction: row !important;
  padding: 0 !important;
  margin: 0 !important;
}

.top-navbar #sidebarToggle {
  border: none;
  background: transparent;
  color: #212529;
  font-size: 1.5rem;
  padding: 0.5rem;
  border-radius: 8px;
  transition: all var(--transition-fast);
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1051;
  cursor: pointer;
  pointer-events: auto !important;
  flex-shrink: 0;
  order: -1;
}

.top-navbar #sidebarToggle:hover {
  background-color: rgba(68, 194, 196, 0.1);
  color: var(--brand-primary);
  transform: scale(1.1);
}

.top-navbar #sidebarToggle:active {
  transform: scale(0.95);
}

/* Sidebar */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: 280px;
  background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
  box-shadow: var(--shadow-lg);
  z-index: 1040;
  transform: translateX(-100%);
  transition: transform var(--transition-base);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

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

.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 2px solid var(--brand-light);
  background: linear-gradient(135deg, rgba(68, 194, 196, 0.05) 0%, #ffffff 100%);
  min-height: auto;
}

.sidebar-header-top {
  width: 100%;
  position: relative;
}

.sidebar-header-top>div {
  margin-bottom: 0;
}

.sidebar-header-top .sidebar-title {
  color: #212529;
  font-size: 0.875rem;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  font-weight: 600;
  margin-top: 0.5rem;
  margin-bottom: 0;
  text-align: left;
  padding: 0;
  display: block;
  width: 100%;
}

.sidebar-header .brand-logo {
  height: 45px;
}

.sidebar-header-top #sidebarToggleInSidebar {
  border: none;
  background: transparent;
  color: #6c757d;
  font-size: 1.1rem;
  padding: 0.25rem;
  border-radius: 8px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  align-self: flex-start;
  line-height: 1;
  width: 32px;
  height: 32px;
}

.sidebar-header-top #sidebarToggleInSidebar:hover {
  background-color: rgba(220, 53, 69, 0.1);
  color: #dc3545;
  transform: scale(1.1);
}

.sidebar-header-top #sidebarToggleInSidebar:active {
  transform: scale(0.95);
}

.sidebar-header-top .brand-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
  margin: 0;
}

.sidebar-header-top .flex-grow-1 {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}


/* Navegación del sidebar */
.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.sidebar-nav .nav {
  padding: 0 0.75rem;
}

.sidebar-nav .nav-item {
  margin-bottom: 0.5rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  padding: 0.875rem 1rem;
  color: #495057;
  font-weight: 500;
  border-radius: 10px;
  transition: all var(--transition-fast);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  gap: 0.75rem;
}

.sidebar-nav .nav-link i {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
  color: #6c757d;
  transition: all var(--transition-fast);
}

.sidebar-nav .nav-link:hover {
  background-color: rgba(68, 194, 196, 0.1);
  color: var(--brand-primary);
  transform: translateX(4px);
}

.sidebar-nav .nav-link:hover i {
  color: var(--brand-primary);
  transform: scale(1.1);
}

.sidebar-nav .nav-link.active {
  background: linear-gradient(135deg, var(--brand-primary) 0%, rgba(68, 194, 196, 0.9) 100%);
  color: #fff;
  box-shadow: var(--shadow-md);
  font-weight: 600;
}

.sidebar-nav .nav-link.active i {
  color: #fff;
}

/* Contenido principal */
.main-content {
  flex: 1;
  margin-left: 0;
  transition: margin-left var(--transition-base);
  padding: 1rem 1.5rem 1.5rem 1.5rem;
  min-height: calc(100vh - 60px);
}

/* Cuando el sidebar está activo en desktop */
@media (min-width: 992px) {
  .sidebar.active~.main-content {
    margin-left: 280px;
  }
}

/* Overlay para móvil */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1039;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
  backdrop-filter: blur(2px);
  pointer-events: none;
}

.sidebar-overlay.active {
  pointer-events: auto;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Asegurar que el navbar siempre esté por encima del overlay */
.top-navbar,
.top-navbar * {
  pointer-events: auto !important;
  position: relative;
  z-index: 1051 !important;
}

/* En móvil, el sidebar siempre está oculto por defecto */
@media (max-width: 991px) {
  .sidebar {
    width: 280px;
  }

  .sidebar.active~.sidebar-overlay {
    opacity: 1;
    visibility: visible;
  }

  /* En móvil, cuando el sidebar está abierto, el contenido no se mueve */
  .sidebar.active~.main-content {
    margin-left: 0;
  }
}

/* En desktop, el sidebar puede estar visible por defecto */
@media (min-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .main-content {
    margin-left: 0;
    transition: margin-left var(--transition-base);
  }

  .sidebar.active~.main-content {
    margin-left: 280px;
  }

  .sidebar-overlay {
    display: none;
  }
}

/* Mejorar el scroll del sidebar */
.sidebar-nav {
  scrollbar-width: thin;
  scrollbar-color: rgba(68, 194, 196, 0.3) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background-color: rgba(68, 194, 196, 0.3);
  border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background-color: rgba(68, 194, 196, 0.5);
}

/* Ajustar el padding del main content */
.main-content {
  padding: 1.5rem;
  min-height: calc(100vh - 60px);
}

/* Optimizar espacio horizontal en móvil */
@media (max-width: 575px) {
  .main-content {
    padding: 0.75rem !important;
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }

  .main-content .container-fluid {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Reducir padding de cards en móvil */
  .card {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .card-header {
    padding: 1rem 0.75rem !important;
  }

  .card-body {
    padding: 1rem 0.75rem !important;
  }

  /* Reducir padding de contenedores internos */
  .card .container-fluid,
  .card .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  .card .col,
  .card [class*="col-"] {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }

  /* Optimizar gaps y márgenes */
  .card .row {
    margin-left: -0.5rem !important;
    margin-right: -0.5rem !important;
  }

  /* Reducir márgenes de elementos */
  .product-card {
    margin-bottom: 1rem !important;
  }

  /* Optimizar tabs */
  .nav-tabs {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }

  .nav-tabs .nav-link {
    padding: 0.5rem 0.75rem !important;
  }

  /* Optimizar botones de alfabeto - centrar letras */
  #alphabetNav {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    gap: 0.25rem !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-height: fit-content !important;
  }

  /* Asegurar que alphabet-scroll no tenga scroll vertical */
  .alphabet-scroll {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    max-height: fit-content !important;
  }

  .alphabet-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    min-width: 2rem !important;
    width: 2rem !important;
    height: 2rem !important;
    min-height: 2rem !important;
    padding: 0 !important;
    line-height: 1 !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
  }

  /* Asegurar que el botón "Todos" también esté centrado y con ancho adecuado */
  #alphabetNav>button:first-child {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center !important;
    line-height: 1 !important;
    min-width: 3.5rem !important;
    width: auto !important;
    padding: 0.25rem 0.75rem !important;
    white-space: nowrap !important;
  }

  /* Optimizar formularios */
  .form-control,
  .form-select {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  /* Reducir padding de modales en móvil */
  .modal-body {
    padding: 1rem 0.75rem !important;
  }

  .modal-header {
    padding: 0.75rem !important;
  }

  .modal-footer {
    padding: 0.75rem !important;
  }

  /* Optimizar tablas - reducir padding */
  .table th,
  .table td {
    padding: 0.5rem 0.4rem !important;
  }

  /* Asegurar que las tablas se vean completamente en móvil */
  .table-responsive {
    overflow-x: auto !important;
    overflow-y: visible !important;
    -webkit-overflow-scrolling: touch !important;
    max-width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Asegurar que las tablas tengan el espacio necesario */
  #viewHistory .table-responsive,
  #viewClients .table-responsive,
  #viewContactos .table-responsive,
  #viewUsers .table-responsive {
    width: 100%;
    display: block;
  }

  /* Asegurar que las tablas no se corten */
  #viewHistory .card-body,
  #viewClients .card-body,
  #viewContactos .card-body,
  #viewUsers .card-body {
    overflow: visible !important;
    padding-bottom: 1rem !important;
  }

  /* Asegurar que las tablas tengan ancho mínimo para scroll horizontal */
  #historyTable,
  #clientsTable,
  #contactosTable,
  #usersTable {
    min-width: 600px;
    width: 100%;
  }

  /* Optimizar contenedores de búsqueda */
  #productSearch {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  /* Reducir márgenes de secciones */
  .mb-3,
  .mb-4,
  .mb-5 {
    margin-bottom: 1rem !important;
  }

  /* Optimizar espacios entre elementos */
  .gap-2 {
    gap: 0.5rem !important;
  }

  .gap-3 {
    gap: 0.75rem !important;
  }

  /* Asegurar que los elementos usen el 100% del ancho disponible */
  .w-100 {
    width: 100% !important;
  }

  /* Reducir padding de listas y elementos de navegación */
  .list-group-item {
    padding: 0.75rem 0.5rem !important;
  }

  /* Optimizar espacios de botones en grupos */
  .btn-group,
  .input-group {
    width: 100% !important;
  }

  /* Reducir padding de alertas */
  .alert {
    padding: 0.75rem 0.5rem !important;
  }
}

.main-content .container-fluid {
  max-width: 100%;
  padding: 0;
}

/* Ajustar el footer para que esté pegado al final */
.site-footer {
  margin-top: auto;
}

/* Estilos para el dropdown de autocompletado de clientes */
#clientDropdown {
  padding: 0.25rem 0;
  margin-top: 0.25rem;
}

#clientDropdown .dropdown-item {
  padding: 0.5rem 1rem;
  white-space: normal;
  cursor: pointer;
}

#clientDropdown .dropdown-item:hover {
  background-color: var(--brand-light);
  color: inherit;
}

#clientDropdown .dropdown-item:active {
  background-color: var(--brand-primary);
  color: #fff;
}

#clientDropdown .dropdown-item small {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.875rem;
}

/* Estilos para campos readonly */
.form-control[readonly] {
  background-color: #f8f9fa;
  cursor: not-allowed;
}

/* Estilos para diferenciar roles de usuario en el navbar */
.user-role-admin {
  color: #856404 !important;
  font-weight: 600;
  padding: 0.375rem 0.75rem;
  background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%) !important;
  border-radius: 8px;
  border: 1px solid #ffc107;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.user-role-admin:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

.user-role-vendedor {
  color: #0d4a4c !important;
  font-weight: 500;
  padding: 0.375rem 0.75rem;
  background: linear-gradient(135deg, rgba(68, 194, 196, 0.15) 0%, rgba(68, 194, 196, 0.25) 100%) !important;
  border-radius: 8px;
  border: 1px solid rgba(68, 194, 196, 0.3);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.user-role-vendedor:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-md);
}

/* Asegurar que el modal de confirmación aparezca por encima de otros modales */
/* Bootstrap 5 usa z-index 1055 para modales y 1050 para backdrops */
/* Cuando hay múltiples modales, necesitamos z-index mayores */
/* Solo aplicar cuando el modal de confirmación está visible */
#confirmModal.modal.show {
  z-index: 1065 !important;
}

/* Cuando el modal de confirmación está visible, aumentar su z-index */
body.modal-open #confirmModal.show {
  z-index: 1065 !important;
}

/* Asegurar que el modal de confirmación aparezca por encima cuando hay múltiples modales */
/* Esto se maneja dinámicamente en JavaScript cuando se muestra el modal de confirmación */

/* ============================================
   MEJORAS ADICIONALES DE UX Y ESTÉTICA
   ============================================ */

/* Mejoras en modales */
.modal-content {
  border: none;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* Prevenir foco en elementos dentro de modales ocultos (accesibilidad) */
.modal:not(.show)[aria-hidden="true"] button,
.modal:not(.show)[aria-hidden="true"] a,
.modal:not(.show)[aria-hidden="true"] input,
.modal:not(.show)[aria-hidden="true"] select,
.modal:not(.show)[aria-hidden="true"] textarea {
  pointer-events: none !important;
  tabindex: -1 !important;
}

.modal:not(.show)[aria-hidden="true"] *:focus {
  outline: none !important;
}

/* Asegurar que los modales visibles permitan interacción */
.modal.show button,
.modal.show a,
.modal.show input,
.modal.show select,
.modal.show textarea {
  pointer-events: auto;
}

.modal-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border-bottom: 2px solid var(--brand-light);
  padding: 1.5rem;
}

.modal-title {
  font-weight: 600;
  color: #212529;
  font-size: 1.25rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
  padding: 1rem 1.5rem;
  gap: 0.75rem;
}

/* Mejoras en dropdowns */
.dropdown-menu {
  border: none;
  box-shadow: var(--shadow-lg);
  border-radius: 12px;
  padding: 0.5rem;
  margin-top: 0.5rem;
  animation: fadeInDown 0.2s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-item {
  border-radius: 8px;
  padding: 0.625rem 1rem;
  transition: all var(--transition-fast);
  margin-bottom: 0.25rem;
}

.dropdown-item:hover {
  background-color: var(--brand-light);
  transform: translateX(4px);
}

.dropdown-item:active {
  background-color: var(--brand-primary);
  color: #fff;
}

/* Mejoras en paginación */
.pagination {
  gap: 0.5rem;
}

.page-link {
  border: none;
  border-radius: 8px;
  padding: 0.625rem 1rem;
  color: var(--brand-primary);
  font-weight: 500;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.page-link:hover {
  background-color: var(--brand-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: var(--brand-primary);
}

.page-item.active .page-link {
  background: linear-gradient(135deg, var(--brand-primary) 0%, rgba(68, 194, 196, 0.9) 100%);
  border-color: var(--brand-primary);
  box-shadow: var(--shadow-md);
}

.page-item.disabled .page-link {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mejoras en badges */
.badge {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.875rem;
}

/* Mejoras en alertas */
.alert {
  border: none;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid;
}

.alert-success {
  background: linear-gradient(90deg, rgba(25, 135, 84, 0.1) 0%, rgba(25, 135, 84, 0.05) 100%);
  border-left-color: #198754;
}

.alert-danger {
  background: linear-gradient(90deg, rgba(220, 53, 69, 0.1) 0%, rgba(220, 53, 69, 0.05) 100%);
  border-left-color: #dc3545;
}

.alert-warning {
  background: linear-gradient(90deg, rgba(255, 193, 7, 0.1) 0%, rgba(255, 193, 7, 0.05) 100%);
  border-left-color: #ffc107;
}

.alert-info {
  background: linear-gradient(90deg, rgba(68, 194, 196, 0.1) 0%, rgba(68, 194, 196, 0.05) 100%);
  border-left-color: var(--brand-primary);
}

/* Mejoras en inputs de búsqueda */
#productSearch,
input[type="search"],
input[type="text"].form-control:not([readonly]) {
  position: relative;
}

#productSearch::placeholder,
input::placeholder {
  color: #adb5bd;
  font-style: italic;
}

/* Mejoras en botones de acción en tablas */
.btn-sm {
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.btn-sm:hover {
  transform: scale(1.05);
}

/* Mejoras en el campo de búsqueda de productos */
#productSearch {
  border-radius: 12px;
  padding: 0.75rem 1rem;
  border: 2px solid #e9ecef;
  transition: all var(--transition-fast);
}

#productSearch:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.25rem rgba(68, 194, 196, 0.25);
}

/* Mejoras en el contenedor de productos */
#productsContainer {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Mejoras en el botón de cotización del navbar */
#openCartBtn {
  position: relative;
  overflow: visible;
  padding-right: 1.5rem !important;
  min-width: auto;
}

#cartCount {
  animation: pulse 2s infinite;
  position: absolute !important;
  top: -10px !important;
  right: 4px !important;
  transform: none !important;
  min-width: 26px;
  max-width: 60px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  z-index: 10;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  border: 2px solid #ffffff;
  letter-spacing: 0.02em;
}

/* Si el número es muy grande, mostrar "+" después del límite */
#cartCount::after {
  content: '';
}

/* Asegurar que el badge no se salga de la pantalla en móvil */
@media (max-width: 767px) {
  #cartCount {
    max-width: 52px;
    font-size: 0.85rem;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    right: 2px !important;
    top: -9px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  }

  #openCartBtn {
    padding-right: 0.75rem !important;
  }

  /* Ajustar botones en tablet pequeña - ocultar texto pero mantener iconos */
  .top-navbar .d-flex.ms-auto {
    gap: 0.5rem !important;
    flex-shrink: 0 !important;
    min-width: auto !important;
  }

  .top-navbar .d-flex.ms-auto .btn {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.85rem !important;
    min-width: 44px !important;
    min-height: 44px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
  }

  .top-navbar .d-flex.ms-auto .btn span:not(.badge) {
    display: none !important;
  }

  .top-navbar .d-flex.ms-auto .btn i {
    font-size: 1.1rem !important;
    margin: 0 !important;
  }

  /* Ajustar navbar-brand para dar más espacio a los botones */
  .top-navbar .navbar-brand {
    max-width: calc(100% - 150px) !important;
    flex-shrink: 1 !important;
    min-width: 0 !important;
  }

  .top-navbar .navbar-brand span {
    font-size: 0.9rem !important;
    max-width: 200px !important;
  }

  /* Ajustar sidebar toggle */
  .top-navbar #sidebarToggle {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0.5rem !important;
    flex-shrink: 0 !important;
  }
}

/* En pantallas muy pequeñas, ajustar aún más */
@media (max-width: 575px) {
  #cartCount {
    max-width: 42px;
    font-size: 0.75rem;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    right: 0px !important;
    top: -7px !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  }

  #openCartBtn {
    padding-right: 0.5rem !important;
    padding-left: 0.5rem !important;
  }
}

/* Asegurar que el navbar tenga espacio para el badge */
.top-navbar {
  overflow: visible !important;
}

@keyframes pulse {

  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }

  50% {
    transform: translate(-50%, -50%) scale(1.1);
  }
}

/* Mejoras en el footer */
.site-footer {
  padding: 1rem 0;
  font-size: 0.875rem;
  color: #6c757d;
  background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
  border-top: 1px solid #e9ecef;
  margin-top: auto;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

/* Mejoras en mensajes de "no hay resultados" */
#noResults,
#noHistory,
#noClients,
#noContactos,
#noUsers,
#noStats {
  padding: 3rem 1rem;
  color: #6c757d;
  font-size: 1.1rem;
}

#noResults::before,
#noHistory::before,
#noClients::before,
#noContactos::before,
#noUsers::before {
  content: "📋";
  display: block;
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Mejoras en checkboxes */
.form-check-input {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 6px;
  border: 2px solid #dee2e6;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--brand-primary);
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.25rem rgba(68, 194, 196, 0.25);
}

.form-check-input:hover {
  border-color: var(--brand-primary);
}

/* Mejoras en el selector de unidad de productos */
.unit-selector {
  border-radius: 8px;
  border: 2px solid #e9ecef;
  font-weight: 500;
  transition: all var(--transition-fast);
  padding-right: 2.5rem !important;
  /* Espacio suficiente para la flecha del select */
}

.unit-selector:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.25rem rgba(68, 194, 196, 0.25);
}

/* Mejoras en el título de productos */
.product-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.product-title .fw-semibold {
  font-size: 1.125rem;
  color: #212529;
  font-weight: 600;
}

/* Mejoras en el navbar brand */
.navbar-brand {
  transition: all var(--transition-fast);
}

.navbar-brand:hover {
  transform: scale(1.05);
}

.navbar-brand img {
  transition: all var(--transition-fast);
}

.navbar-brand:hover img {
  filter: brightness(1.1);
}

/* Smooth scroll */
html {
  scroll-behavior: smooth;
}

/* Mejoras en el contenedor principal */
main.container {
  animation: fadeIn 0.4s ease-out;
}

/* Mejoras en los mensajes de estado vacío */
.text-center.text-muted {
  opacity: 0.8;
  font-style: italic;
}

/* Mejoras adicionales en espaciado y organización */
.card-header h5 {
  color: #212529;
  font-weight: 600;
  font-size: 1.25rem;
}

.card-header small {
  color: #6c757d;
  font-size: 0.875rem;
}

/* Reducir espacio superior en secciones de navegación */
#viewHistory,
#viewClients,
#viewContactos,
#viewStats,
#viewUsers {
  margin-top: 0.5rem !important;
}

/* Reducir padding superior del main-content para aprovechar mejor el espacio vertical */
.main-content {
  padding-top: 1rem;
}

/* Reducir padding superior de los card-header en estas secciones */
#viewHistory .card-header,
#viewClients .card-header,
#viewContactos .card-header,
#viewStats .card-header,
#viewUsers .card-header {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

/* Mejoras en el espaciado de las secciones */
section {
  animation: fadeIn 0.4s ease-out;
}

/* Mejoras en los botones de la navbar */
.navbar button {
  transition: all var(--transition-fast);
  border-radius: 8px;
}

.navbar button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Mejor contraste en texto */
.text-muted {
  color: #6c757d !important;
}

/* Mejoras en las tarjetas del contenedor de productos */
#productsContainer .product-card {
  animation: slideUp 0.3s ease-out;
  animation-fill-mode: both;
}

#productsContainer .product-card:nth-child(1) {
  animation-delay: 0.05s;
}

#productsContainer .product-card:nth-child(2) {
  animation-delay: 0.1s;
}

#productsContainer .product-card:nth-child(3) {
  animation-delay: 0.15s;
}

#productsContainer .product-card:nth-child(4) {
  animation-delay: 0.2s;
}

#productsContainer .product-card:nth-child(5) {
  animation-delay: 0.25s;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mejoras en el contenedor de filtros del historial */
#historyFilters .form-control,
#historyFilters .form-select {
  border-radius: 8px;
  transition: all var(--transition-fast);
}

#historyFilters .form-control:focus,
#historyFilters .form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.25rem rgba(68, 194, 196, 0.25);
  transform: translateY(-1px);
}

/* Mejoras en los botones del header de productos */
#productButtonsContainer .btn {
  transition: all var(--transition-fast);
  border-radius: 8px;
  font-weight: 500;
}

#productButtonsContainer .btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Mejoras en los iconos */
i.bi {
  transition: transform var(--transition-fast);
}

.btn:hover i.bi {
  transform: scale(1.1);
}

/* Mejoras en las tablas responsivas */
.table-responsive {
  border-radius: 12px;
  overflow-x: auto;
  overflow-y: visible;
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}

/* Mejoras en el contenedor principal */
main.container {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

/* Mejoras en el navbar cuando está fijo */
.navbar {
  backdrop-filter: blur(10px);
  background-color: rgba(255, 255, 255, 0.95);
}

/* Mejoras en el footer */
.site-footer {
  backdrop-filter: blur(10px);
  background-color: rgba(255, 255, 255, 0.95);
}

/* Mejoras en botones de eliminar/seleccionar */
.btn-outline-danger {
  transition: all var(--transition-fast);
  border-radius: 8px;
  font-weight: 500;
}

.btn-outline-danger:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Mejoras en el contenedor de filtros */
#historyFilters {
  background: rgba(68, 194, 196, 0.02);
  padding: 1.5rem;
  border-radius: 12px;
  margin-bottom: 1rem;
}

/* Mejoras en el selector de productos */
.product-select {
  cursor: pointer;
  width: 1.25rem;
  height: 1.25rem;
}

/* Efecto de carga suave */
.loading {
  opacity: 0.6;
  pointer-events: none;
  position: relative;
}

/* REGLA FINAL: Forzar que los encabezados de las tablas SIEMPRE tengan texto blanco, incluso en hover */
.table thead th,
.table thead th:hover,
.table thead th:focus,
.table thead th:active,
.table thead th *,
.table thead th:hover *,
.table thead th:focus *,
.table thead th:active *,
.table thead th span,
.table thead th:hover span,
.table thead th i,
.table thead th:hover i,
.table thead th a,
.table thead th:hover a,
.product-card .table thead th,
.product-card .table thead th:hover,
.product-card .table thead th:focus,
.product-card .table thead th:active,
.product-card .table thead th *,
.product-card .table thead th:hover *,
.product-card .table thead th:focus *,
.product-card .table thead th:active *,
.product-card .table thead th span,
.product-card .table thead th:hover span,
.product-card .table thead th i,
.product-card .table thead th:hover i,
.product-card .table thead th a,
.product-card .table thead th:hover a {
  color: #ffffff !important;
}

/* REGLA FINAL RESPONSIVE: Asegurar que los botones del top-navbar se vean completamente en móvil */
@media (max-width: 575px) {

  /* Asegurar que el container-fluid tenga espacio suficiente */
  .top-navbar .container-fluid {
    overflow: visible !important;
    max-width: 100vw !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0.5rem !important;
    box-sizing: border-box !important;
  }

  /* Sidebar toggle - completamente a la izquierda */
  .top-navbar #sidebarToggle {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    max-height: 44px !important;
    padding: 0.5rem !important;
    margin: 0 !important;
    margin-right: 0.5rem !important;
    margin-left: 0 !important;
    flex-shrink: 0 !important;
    font-size: 1.25rem !important;
  }

  /* Ocultar el logo en móvil - el botón hamburguesa ocupará su posición */
  .top-navbar .navbar-brand {
    display: none !important;
  }

  /* Contenedor de botones - prioridad máxima */
  .top-navbar .d-flex.ms-auto {
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    width: 92px !important;
    min-width: 92px !important;
    max-width: 92px !important;
    overflow: visible !important;
    position: relative !important;
    z-index: 10 !important;
    gap: 0.3rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
  }

  /* Botones - tamaño fijo y visible */
  .top-navbar .d-flex.ms-auto .btn {
    flex-shrink: 0 !important;
    overflow: visible !important;
    position: relative !important;
    z-index: 11 !important;
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    padding: 0.35rem !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
  }

  /* Asegurar que el botón de cotización tenga espacio para el badge */
  .top-navbar .d-flex.ms-auto #openCartBtn {
    padding-right: 0.45rem !important;
    overflow: visible !important;
  }

  /* Badge ajustado */
  #cartCount {
    right: -2px !important;
    top: -6px !important;
    max-width: 40px !important;
    font-size: 0.75rem !important;
    height: 20px !important;
    min-width: 20px !important;
  }
}

/* REGLA FINAL: Forzar que los botones del top-navbar SIEMPRE se vean completamente en móvil */
@media (max-width: 575px) {

  /* Priorizar completamente los botones */
  .top-navbar .container-fluid {
    justify-content: space-between !important;
    align-items: center !important;
  }

  /* Reducir logo al mínimo para dar espacio a los botones */
  .top-navbar .navbar-brand {
    max-width: calc(100vw - 130px) !important;
    min-width: 0 !important;
    flex: 0 1 auto !important;
  }

  .top-navbar .navbar-brand img.brand-logo {
    height: 22px !important;
    max-width: 40px !important;
  }

  /* Asegurar espacio fijo para botones - NO pueden reducirse */
  .top-navbar .d-flex.ms-auto {
    flex: 0 0 92px !important;
    width: 92px !important;
    min-width: 92px !important;
    max-width: 92px !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
  }

  /* Botones tamaño fijo - completamente visibles */
  .top-navbar .d-flex.ms-auto .btn {
    flex: 0 0 40px !important;
    width: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
    display: inline-flex !important;
  }
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 3px solid var(--brand-primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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