/* ===== Catálogo de datasets ===== */

.catalog-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: start;
  padding: 24px;
}

/* Botón "Filtros" (mobile): oculto por defecto en escritorio.
   IMPORTANTE: esta regla base debe ir ANTES del @media que la muestra en
   mobile — si va después (como estaba antes), gana siempre por orden de
   archivo y el botón queda oculto también en mobile, sin importar que el
   media query aplique bien. */
.filtros-toggle-btn {
  display: none;
}

@media (max-width: 800px) {
  .catalog-layout {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }

  /* En una sola columna, que el sidebar "flote" con sticky se ve raro
     (se queda pegado arriba tapando resultados) — mejor que se desplace normal.
     !important porque la regla base ".catalog-sidebar { position: sticky }"
     está más abajo en este mismo archivo, y en CSS gana la que aparece
     después cuando la especificidad es igual — sin el !important, esta
     regla de mobile perdía silenciosamente contra esa. */
  .catalog-sidebar {
    position: static !important;
  }

  /* Botón para mostrar/ocultar los filtros, solo visible en mobile */
  .filtros-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: #fff;
    border: 1px solid #e2e2e2;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #333;
    cursor: pointer;
  }

  .filtros-toggle-btn .chevron {
    transition: transform 0.2s ease;
  }

  .filtros-toggle-btn.abierto .chevron {
    transform: rotate(180deg);
  }

  /* Colapsado por defecto en mobile: el JS solo agrega/quita la clase "abierto" */
  #filtros-body {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease;
  }

  #filtros-body.abierto {
    max-height: 1000px;
    margin-top: 12px;
  }
}

@media (max-width: 480px) {
  .catalog-layout {
    padding: 12px;
  }

  /* Tarjetas a ancho completo en pantallas muy angostas, para evitar
     que el mínimo de 280px no quepa y genere scroll horizontal. */
  #catalog-results {
    grid-template-columns: 1fr;
  }
}

/* Sidebar de filtros */
.catalog-sidebar {
  position: sticky;
  top: 16px;
  background: #fff;
  border: 1px solid #e2e2e2;
  border-radius: 10px;
  padding: 16px;
}

.catalog-sidebar h4 {
  margin: 16px 0 8px;
  font-size: 0.95rem;
  color: #333;
}

.catalog-sidebar h4:first-child {
  margin-top: 0;
}

#catalog-search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9rem;
  box-sizing: border-box;
}

#catalog-sort {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.85rem;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  margin-bottom: 6px;
  cursor: pointer;
  color: #444;
}

/* Checkbox con estilo propio (cuadrado, esquinas redondeadas) — no depende
   de cómo cada navegador/sistema operativo dibuje el checkbox por defecto,
   así se ve igual siempre. */
.filter-checkbox input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  min-width: 16px;
  border: 1.5px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  position: relative;
  margin: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.filter-checkbox input[type="checkbox"]:hover {
  border-color: #0b5fff;
}

.filter-checkbox input[type="checkbox"]:checked {
  background: #0b5fff;
  border-color: #0b5fff;
}

.filter-checkbox input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Resultados */
.catalog-results-header {
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: #666;
}

#catalog-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.dataset-card {
  background: #fff;
  border: 1px solid #e2e2e2;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow 0.2s ease;
}

.dataset-card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.dataset-card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
  color: #1a1a1a;
}

.dataset-desc {
  font-size: 0.85rem;
  color: #555;
  margin: 0;
  line-height: 1.4;
}

.dataset-card-header {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-category {
  background: #eef1f8;
  color: #3a4a7a;
}

.badge-source {
  color: #fff;
}
.badge-gbif { background: #509e2f; }
.badge-zenodo { background: #1259a5; }
.badge-figshare { background: #d55e00; }
.badge-dryad { background: #7b3f9e; }
.badge-otro { background: #777; }

.dataset-card-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: #888;
}

.dataset-card-footer a {
  color: #0b5fff;
  text-decoration: none;
  font-weight: 600;
}

.dataset-card-footer a:hover {
  text-decoration: underline;
}

.catalog-empty {
  color: #777;
  font-style: italic;
  padding: 24px 0;
}

/* Paginación */
#catalog-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
}

.pg-btn {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  width: 34px;
  height: 34px;
  font-size: 1.1rem;
  cursor: pointer;
  color: #333;
}

.pg-btn:hover:not(:disabled) {
  background: #f0f4ff;
  border-color: #0b5fff;
}

.pg-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.pg-info {
  font-size: 0.85rem;
  color: #555;
}

/* ===== Sección "Últimos datasets publicados" (index.html) ===== */
.recent-datasets {
  max-width: 1100px;
  margin: 40px auto;
  padding: 0 24px;
}

.recent-datasets h2 {
  margin-bottom: 16px;
  text-align: center;
}

.recent-datasets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.recent-datasets-link {
  text-align: center;
  margin-top: 20px;
}

.recent-datasets-link a {
  color: #0b5fff;
  text-decoration: none;
  font-weight: 600;
}

.recent-datasets-link a:hover {
  text-decoration: underline;
}

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