/* ============================================
   COMPONENTES - BÚSQUEDA, TARJETAS, NAVEGACIÓN
   ============================================ */


/* ===== SEARCH CONTAINER ===== */
.search-container {
  max-width: 1400px;
  margin: 1rem auto 0;
  padding: 0 1rem;
  position: relative;
  z-index: 2;
  width: 100%;
}


.search {
  border-radius: 12px;
  padding: 1.5rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  width: 100%;
}


.search-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}


.search-field label {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}


.search input,
.search select {
  padding: 0.8rem 1rem;
  font-size: 1rem;
  border: 2px solid var(--input-border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-primary);
  transition: all 0.2s ease;
}


.search input:focus,
.search select:focus {
  outline: none;
  border-color: var(--badge-text);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.1);
}


/* ===== STATS BAR ===== */
.stats-bar {
  background: var(--bg-secondary);
  border-radius: 8px;
  margin-top: 1rem;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  border: 1px solid var(--border-color);
}


#resultsCount {
  font-size: 0.9rem;
  font-weight: 500;
}


.reset-btn {
  background: none;
  border: 1px solid var(--border-color);
  padding: 0.4rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-secondary);
}


.reset-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}


/* ===== MAIN NAVIGATION ===== */
.main-nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}


.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: center;
  gap: 2rem;
}


.nav-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.2s ease;
}


.nav-link .nav-icon {
  font-size: 1.1rem;
}


.nav-link:hover,
.nav-link.active {
  background: var(--badge-bg);
  color: var(--badge-text);
}


/* Menú hamburguesa */
.menu-toggle-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.2s ease;
  color:#2dd4bf
}


.menu-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}


.main-nav.collapsed {
  max-height: 0;
  overflow: hidden;
  padding: 0;
  border: none;
  transition: max-height 0.3s ease-out;
}


.main-nav.expanded {
  max-height: 300px;
  overflow: visible;
  transition: max-height 0.4s ease-in;
  border-bottom: 1px solid var(--border-color);
}


/* ===== RESULTS GRID ===== */
#results {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  align-items: stretch;
}


body.layout-detailed #results {
  grid-template-columns: repeat(2, 1fr);
}


@media (max-width: 1200px) {
  #results {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 900px) {
  #results {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  #results {
    grid-template-columns: 1fr;
  }

  body.layout-detailed #results {
    grid-template-columns: 1fr;
  }
}


/* ===== CARDS ===== */
.card {
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  height: 100%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}


.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--badge-text);
}


/* En modo oscuro, el borde hover debe ser naranja */
[data-theme="dark"] .card:hover {
  border-color: #f97316;
}


.card-header {
  padding: 1rem 1rem 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}


.card h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
  flex: 1;
  color: var(--text-primary);
}


[data-theme="dark"] .card h3 {
  color: var(--badge-text);
}


.island-tag {
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  background: var(--badge-bg);
  color: var(--badge-text);
  white-space: nowrap;
}


/* Tipo y alcance */
.card-type {
  padding: 0 1rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}


.type-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.type-text {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}


.scope-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-weight: 500;
}


/* Meta badges */
.card-meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 1rem 0.6rem;
  align-items: center;
}


/* Pill base de meta-badges */
.meta-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  white-space: nowrap;
  font-weight: 625;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

/* Pill base de licencias */
.license-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}

/* OK: Machine-readable, API disponible, ✅ Abierta → MISMO LOOK */
.meta-badge.meta-ok,
.license-badge.license-open {
  background: rgba(13, 148, 136, 0.12);      /* teal claro */
  color: #0f766e;
  border: 1px solid rgba(13, 148, 136, 0.25);
}

[data-theme="dark"] .meta-badge.meta-ok,
[data-theme="dark"] .license-badge.license-open {
  color: #64c086;                            /* teal brillante */
  background: rgba(45, 212, 191, 0.15);
  border-color: rgba(45, 212, 191, 0.4);
}


/* Badge de API: usa el pill de .badge, ajustamos solo texto y hover */
.badge.api-badge {
  text-decoration: none;
  color: #2dd4bf; /* teal claro en modo oscuro, combina con el fondo */
}

/* Hover: texto naranja, sin subrayado */
.badge.api-badge:hover {
  color: #f97316;
  text-decoration: underline;
}

/* WARN: avisos, restricciones, etc. (naranja) */
.meta-badge.meta-warn,
.license-restricted {
  background: rgba(251, 146, 60, 0.12);
  color: #c2410c;
  border: 1px solid rgba(251, 146, 60, 0.25);
}


[data-theme="dark"] .meta-badge.meta-warn,
[data-theme="dark"] .license-restricted {
  color: #fb923c;
}


/* Badges neutros (sin cambio) */
.meta-badge.meta-neutral {
  background: rgba(148, 163, 184, 0.12);
  color: #64748b;
  border: 1px solid rgba(148, 163, 184, 0.25);
}


[data-theme="dark"] .meta-badge.meta-neutral {
  color: #94a3b8;
}


/* LICENSE BLOCK */
.license-primary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}


.license-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}


.license-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}


.license-summary-text,
.license-unavailable {
  font-size: 0.78rem;
  line-height: 1.4;
  margin: 0;
  color: var(--text-secondary);
}


/* Descripción */
.card-description {
  padding: 0 1rem;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 1rem;
  color: var(--text-secondary);
}


/* Estadísticas de la tarjeta */
.card-stats {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
}


.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}


.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--badge-text);
}


.stat-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
}


/* Secciones internas */
.card-section {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}


.card-section strong {
  font-size: 0.75rem;
  display: block;
  margin-bottom: 0.5rem;
}


/* Badges */
.badge-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  width: 100%;
}


.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.7rem;
  border-radius: 20px;
  font-weight: 500;
  background: var(--badge-bg);
  color: var(--badge-text);
}


.format-badge {
  background: #e2f4f0;
  color: #006652;
}


[data-theme="dark"] .format-badge {
  background: #0b1220;
  color: #38d5c4;
}


/* Footer de tarjeta */
.card-footer {
  padding: 0.75rem 1rem;
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}


.portal-link,
.map-button {
  font-weight: 600;
  text-decoration: none;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: gap 0.2s ease;
  color: var(--badge-text);
  background: none;
  border: none;
  cursor: pointer;
}


.portal-link:hover,
.map-button:hover {
  text-decoration: underline;
  gap: 0.5rem;
  color: var(--text-primary);
}


/* El texto del map-button se subraya, pero el icono NO */
.map-button:hover {
  text-decoration: none;
}


.map-button:hover span:last-child {
  text-decoration: underline;
}


[data-theme="dark"] .portal-link:hover,
[data-theme="dark"] .map-button:hover {
  color: #f97316;
}


.map-button .pin-icon {
  display: inline-block;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}


.map-button:hover .pin-icon {
  transform: translateY(-3px);
}


.coordinates {
  font-size: 0.7rem;
  font-family: monospace;
  color: var(--text-secondary);
}


/* LICENSE BLOCK */
.license-primary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}


.license-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}


.license-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}


.license-open {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
  border: 1px solid rgba(34, 197, 94, 0.25);
}


.license-restricted {
  background: rgba(251, 146, 60, 0.12);
  color: #c2410c;
  border: 1px solid rgba(251, 146, 60, 0.25);
}


.license-summary-text,
.license-unavailable {
  font-size: 0.78rem;
  line-height: 1.4;
  margin: 0;
  color: var(--text-secondary);
}


[data-theme="dark"] .license-open {
  color: #4ade80;
}

[data-theme="dark"] .license-restricted {
  color: #fb923c;
}


/* DESCRIPTION COLLAPSIBLE */
.description-container {
  position: relative;
  margin-bottom: 1rem;
  padding: 0 1rem;
}


.description-text {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-secondary);
  word-wrap: break-word;
}


.description-text.collapsed {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}


body.layout-detailed .description-text.collapsed {
  -webkit-line-clamp: 6;
  line-clamp: 6;
}


.toggle-desc-btn {
  background: none;
  border: none;
  color: var(--badge-text);
  cursor: pointer;
  font-size: 0.75rem;
  margin-top: 0.25rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 500;
  transition: all 0.2s ease;
}


.toggle-desc-btn .arrow-icon {
  font-size: 0.8rem;
  transition: transform 0.2s ease;
}


.toggle-desc-btn.expanded .arrow-icon {
  transform: rotate(180deg);
}


body.layout-detailed .toggle-cat-btn,
body.layout-detailed .toggle-desc-btn {
  display: none;
}


body.layout-detailed [id$="-hidden"],
body.layout-detailed [id$="-formats-hidden"] {
  display: flex !important;
}


/* CATEGORIES COLLAPSIBLE */
.categories-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}


.toggle-cat-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--badge-text);
  padding: 0;
  transition: transform 0.2s ease;
}


.toggle-cat-btn.rotated {
  transform: rotate(90deg);
}


[id$="-hidden"],
[id$="-formats-hidden"] {
  display: none;
  flex-wrap: wrap;
  gap: 0.3rem;
  width: 100%;
  margin-top: 0.25rem;
}


[id$="-hidden"].show,
[id$="-formats-hidden"].visible {
  display: flex;
}


/* LOADING / ERROR / EMPTY */
.loading-spinner {
  grid-column: 1/-1;
  text-align: center;
  padding: 4rem 2rem;
}


.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--spinner-border);
  border-top-color: var(--spinner-top);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}


@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}


.error-message,
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 3rem 2rem;
  border-radius: 12px;
}


.error-message {
  background: var(--error-bg);
  border-left: 4px solid var(--error-border);
  color: #b91c1c;
}


.empty-state {
  background: var(--empty-bg);
}


.error-icon,
.empty-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}


.retry-btn,
.reset-btn-empty {
  border: none;
  padding: 0.6rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s ease;
}


.retry-btn {
  background: var(--badge-text);
  color: white;
}


code {
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85rem;
  background: var(--badge-bg);
  color: var(--badge-text);
}


/* ABOUT SECTION */
.about-section {
  max-width: 860px;
  margin: 1.5rem auto 0;
  padding: 0 1.5rem;
}


.about-inner {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}


.about-text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-secondary);
}


.about-text strong {
  color: var(--text-primary);
  font-weight: 600;
}


[data-theme="dark"] .about-inner {
  border-color: #14b8a6;
}


[data-theme="dark"] .about-text strong {
  color: var(--text-header);
}


/* BOTONES UTILITY */
.stats-button-container {
  display: flex;
  justify-content: center;
  margin: 30px 0;
}


.stats-button {
  display: inline-block;
  padding: 14px 28px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  text-decoration: none;
  font-weight: 600;
  border-radius: 14px;
  transition: all 0.3s ease;
}


#updateBtn {
  background-color: #14b8a6;
  color: white;
  border: none;
  border-radius: 5px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}


#updateBtn:hover {
  background-color: #1565c0;
}


#updateOutput {
  display: none;
  position: relative;
  margin: 12px auto;
  max-width: 420px;
  width: 100%;
  padding: 8px 10px;
  background-color: #f5f9ff;
  border: 1px solid #bbdefb;
  border-radius: 5px;
  color: #0d47a1;
  font-family: monospace;
  font-size: 0.8rem;
}


/* Utilidades de layout */
.compact-only {
  display: block;
}

.detail-only {
  display: none;
}

body.layout-detailed .compact-only {
  display: none;
}

body.layout-detailed .detail-only {
  display: block;
}


/* Tablas schema */
.schema-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}


.schema-table th,
.schema-table td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}


.schema-table th {
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-secondary);
}


.schema-table td {
  color: var(--text-secondary);
}


.schema-table td:first-child {
  font-family: monospace;
  font-size: 0.82rem;
  color: var(--badge-text);
  white-space: nowrap;
}


/* Badge de licencia */
.license-badge-about {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--badge-bg);
  color: var(--badge-text);
  margin-top: 0.25rem;
}


/* Botón de modo oscuro */
#darkModeToggle {
  position: static;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
}


#darkModeToggle:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}


[data-theme="dark"] #darkModeToggle {
  color: var(--text-secondary);
}


[data-theme="dark"] #darkModeToggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}


/* RESPONSIVE */
@media (max-width: 1024px) {
  .search {
    grid-template-columns: 1fr 1fr;
  }
}


@media (max-width: 768px) {
  .search {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }


  .card-stats {
    flex-direction: column;
    gap: 0.5rem;
  }


  .stats-bar {
    flex-direction: column;
    text-align: center;
  }


  .nav-container {
    gap: 0.5rem;
    padding: 0.5rem 1rem;
  }


  .nav-link span:last-child {
    display: none;
  }


  .nav-link {
    padding: 0.5rem;
  }


  .nav-link .nav-icon {
    font-size: 1.3rem;
  }


  .about-inner {
    padding: 1rem 1.25rem;
  }


  .about-text {
    font-size: 0.875rem;
  }
}


@media (max-width: 480px) {
  .card-footer {
    flex-direction: column;
    text-align: center;
  }
}
