/* ===================================
   CATALOG SECTION - LAYOUT PRINCIPAL
   =================================== */
.catalog-section {
  width: 100%;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-primary);
  background: var(--bg-elevated);
  padding: var(--space-4);
  box-shadow: var(--shadow-md);
}

/* ===================================
   CONTROLS AREA
   =================================== */
.catalog-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: var(--space-4);
}

.catalog-search {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-secondary);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  outline: none;
  font-family: var(--font-family-base);
  font-size: var(--font-size-sm);
  transition: var(--theme-transition);
}

.catalog-search::placeholder {
  color: var(--text-primary);
  transition: var(--theme-transition);
}

.catalog-search:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-transparent, rgba(0,0,0,0.1));
}

/* Contenedor de filtros en fila */
.catalog-filters {
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: center;
  width: 100%;
  position: relative; 
}

/* Ocultamos los select nativos */
.catalog-select-native {
  display: none !important;
}

/* ===================================
   NUEVO MENÚ PERSONALIZADO (CUSTOM DROPDOWN)
   =================================== */

.custom-select-wrapper {
  flex: 1;
  position: relative;
  min-width: 140px;
  font-family: var(--font-family-base);
  font-size: var(--font-size-sm);
}

/* --- CABEZA DEL MENÚ (TRIGGER) --- */
.custom-select-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-tertiary);      /* Fondo adaptable */
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-lg);
  color: var(--text-primary);          /* Texto adaptable */
  cursor: pointer;
  user-select: none;
  transition: var(--theme-transition);
}

/* Hover en el menú principal (Restaurado) */
.custom-select-trigger:hover {
  border-color: var(--text-secondary); /* Un poco más oscuro */
  background: var(--bg-subtle);        /* Cambio sutil de fondo */
}

/* Flecha */
.custom-select-trigger:after {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-secondary);
  border-bottom: 2px solid var(--text-secondary);
  transform: rotate(45deg) translateY(-2px);
  transition: var(--theme-transition);
  margin-left: 8px;
}

/* Estado abierto (Cabeza) */
.custom-select-wrapper.open .custom-select-trigger {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-transparent, rgba(0,0,0,0.1));
}
.custom-select-wrapper.open .custom-select-trigger:after {
  transform: rotate(-135deg) translateY(-2px);
  border-color: var(--color-primary);
}

/* --- LISTA DESPLEGABLE (OPCIONES) --- */
.custom-options {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  z-index: 999;
  
  /* AQUÍ ESTÁ EL CAMBIO CLAVE: */
  /* Usamos variables. En Dark Mode esto será #16213e (Navy) y en Light Mode será blanco/gris */
  background-color: var(--bg-solid) !important; 
  border: 1px solid var(--border-primary) !important;
  
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  
  max-height: 300px;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-10px);
  transition: var(--theme-transition);
}

/* Mostrar lista */
.custom-select-wrapper.open .custom-options {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
  transform: translateY(0);
}

/* --- OPCIONES INDIVIDUALES --- */
.custom-option {
  padding: 15px 16px !important; 
  font-size: 16px !important;      
  
  /* CAMBIO: Usamos var(--text-primary) */
  /* En Light Mode será oscuro, en Dark Mode será blanco automáticamente */
  color: var(--text-primary) !important;          
  
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  
  border-bottom: 1px solid var(--border-subtle);
}

.custom-option:last-child {
  border-bottom: none;
}

/* --- HOVER --- */
/* Mantengo las variables para que funcione en los dos modos */
.custom-option:hover {
  background-color: var(--bg-tertiary) !important; 
  color: var(--text-primary) !important;
}

/* --- OPCIÓN SELECCIONADA --- */
.custom-option.selected {
  background-color: var(--bg-tertiary) !important;
  font-weight: 700;
}

/* Scrollbar adaptable */
.custom-options::-webkit-scrollbar {
  width: 8px;
}
.custom-options::-webkit-scrollbar-track {
  background: var(--bg-solid);
}
.custom-options::-webkit-scrollbar-thumb {
  background: var(--border-secondary);
  border-radius: 4px;
}

/* ===================================
   RESET BUTTON
   =================================== */
.catalog-reset {
  padding: 10px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: var(--font-size-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--theme-transition);
  height: 42px;
}
.catalog-reset:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-primary);
}

/* ===================================
   TABLA
   =================================== */
.catalog-table-wrap {
  width: 100%;
  max-height: 520px;
  overflow-y: auto;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-primary);
  background: var(--bg-solid);
  scrollbar-width: thin;
  scrollbar-color: var(--border-secondary) var(--bg-tertiary);
}

/* Scrollbar Tabla */
.catalog-table-wrap::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
.catalog-table-wrap::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}
.catalog-table-wrap::-webkit-scrollbar-thumb {
  background-color: var(--border-secondary);
  border-radius: 4px;
}

.catalog-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px;
}
.catalog-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 12px;
  border-bottom: 1px solid var(--border-secondary);
  position: sticky;
  top: 0;
  background: var(--bg-tertiary);
  z-index: 10;
}

.catalog-table tbody tr:last-child td {
  border-bottom: none;
}

.catalog-table td {
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.catalog-table tbody tr:hover {
  background-color: var(--bg-tertiary); /* Hover en filas de tabla */
}

.catalog-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  font-size: 12px;
  text-decoration: none;
  font-weight: 500;
  transition: var(--theme-transition);
}
.catalog-download:hover {
  border-color: var(--color-primary);
  background-color: var(--bg-subtle);
}

.catalog-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Mobile */
@media (max-width: 600px) {
  .catalog-filters {
    flex-direction: column;
    align-items: stretch;
  }
}