/**
 * Enciclopedia de platos típicos del mundo y España
 * Hoja de estilos canónica, responsive y dark-first
 */

:root {
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Paleta cromática Dark-First Midnight Slate */
  --bg-body: #0b0f17;
  --bg-card: #111827;
  --bg-card-subtle: #1e293b;
  --bg-input: #151d2f;
  --border-color: #27354a;
  --border-subtle: #1e293b;
  
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-primary: #f59e0b;
  --accent-hover: #d97706;
  --accent-soft: rgba(245, 158, 11, 0.12);
  --accent-border: rgba(245, 158, 11, 0.35);

  --badge-bg: #1e293b;
  --badge-text: #cbd5e1;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 10px 35px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #e2e8f0;
  --border-subtle: #cbd5e1;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --accent-primary: #d97706;
  --accent-hover: #b45309;
  --accent-soft: rgba(217, 119, 6, 0.08);
  --accent-border: rgba(217, 119, 6, 0.25);

  --badge-bg: #e2e8f0;
  --badge-text: #334155;
  --shadow-card: 0 4px 18px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 35px rgba(0, 0, 0, 0.12);
}

/* Reseteo y contención canónica */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  margin-top: 0;
  color: var(--text-main);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.text-mono {
  font-family: var(--font-mono);
}

/* Layout principal */
.main-wrapper.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
  width: 100%;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* Tarjeta principal contenedora */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
  margin-bottom: 2.5rem;
}

/* Barra resumen KPI superior */
.kpi-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  padding: 1.25rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 1.75rem;
}

.kpi-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  border-right: 1px solid var(--border-color);
  padding-right: 0.5rem;
}

.kpi-cell:last-child {
  border-right: none;
}

.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: none;
}

.kpi-val {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-primary);
}

/* Pestañas de navegación España vs Mundo */
.tool-view-tabs {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  flex-wrap: wrap;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 42px;
}

.tab-btn:hover {
  background: var(--border-color);
  color: var(--text-main);
}

.tab-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.tab-btn.btn-random-pill {
  margin-left: auto;
  border-color: var(--accent-border);
  color: var(--accent-primary);
  background: var(--accent-soft);
}

.tab-btn.btn-random-pill:hover {
  background: var(--accent-primary);
  color: #ffffff;
}

/* Barra de búsqueda y filtros facetados */
.catalog-filters-bar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.75rem;
  background: var(--bg-card-subtle);
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.search-icon {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.75rem 2.75rem 0.75rem 2.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.95rem;
  min-height: 44px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-clear-search {
  position: absolute;
  right: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

.filter-dropdowns-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.filter-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-control-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  padding: 0.6rem 2.25rem 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.88rem;
  min-height: 42px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

.form-control-select:focus {
  border-color: var(--accent-primary);
}

.form-control-select option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

/* Barra de estado / conteo */
.catalog-status-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding: 0 0.25rem;
}

.status-counter {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.status-counter strong {
  color: var(--accent-primary);
}

/* Rejilla de tarjetas de platos */
.dishes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1.35rem;
}

/* Tarjeta de plato */
.dish-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.dish-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-border);
  box-shadow: var(--shadow-lg);
}

.dish-card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0f172a;
  overflow: hidden;
}

.dish-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.dish-card:hover .dish-card-img {
  transform: scale(1.04);
}

.dish-badge-region {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(4px);
  color: #ffffff;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.dish-badge-type {
  position: absolute;
  bottom: 0.6rem;
  right: 0.6rem;
  background: rgba(245, 158, 11, 0.9);
  color: #0b0f17;
  padding: 0.18rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 700;
}

.dish-card-body {
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}

.dish-card-title {
  font-size: 1.1rem;
  margin-bottom: 0.4rem;
  line-height: 1.35;
}

.dish-card-desc {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dish-kpis-mini {
  display: flex;
  gap: 0.85rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 0.85rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
}

.dish-kpis-mini span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.dish-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.dish-tag {
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 0.72rem;
  padding: 0.18rem 0.5rem;
  border-radius: var(--radius-sm);
}

.dish-card-footer {
  margin-top: auto;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.dish-license-meta {
  display: flex;
  flex-direction: column;
  font-size: 0.68rem;
  color: var(--text-dim);
}

.badge-cc {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent-primary);
}

.btn-dish-detail {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  background: var(--accent-soft);
  color: var(--accent-primary);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 36px;
}

.btn-dish-detail:hover {
  background: var(--accent-primary);
  color: #ffffff;
}

/* Estado vacío */
.empty-state-card {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--bg-card-subtle);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
}

.empty-state-card svg {
  color: var(--text-dim);
  margin-bottom: 1rem;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 1rem;
  min-height: 42px;
}

/* ==========================================
   MODAL DE FICHA TÉCNICA
   ========================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.modal-container {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 820px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  z-index: 2;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 3;
}

.modal-header-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.modal-header-info h2 {
  font-size: 1.4rem;
  margin: 0;
}

.modal-header-info p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn-close-modal {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-close-modal:hover {
  background: var(--border-color);
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.modal-hero-img-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #0f172a;
}

.modal-hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-legal-attribution {
  font-size: 0.74rem;
  color: var(--text-dim);
  background: var(--bg-card-subtle);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.modal-legal-attribution a {
  color: var(--accent-primary);
  text-decoration: underline;
}

.modal-kpis-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  background: var(--bg-card-subtle);
  padding: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.modal-kpi-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.modal-kpi-item span:first-child {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.modal-kpi-item span:last-child {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.modal-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-section h4 {
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--accent-primary);
  margin: 0;
}

.modal-section p {
  font-size: 0.88rem;
  color: var(--text-main);
  margin: 0;
  line-height: 1.55;
}

.ing-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.ing-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.86rem;
  color: var(--text-main);
}

.ing-check-icon {
  color: var(--accent-primary);
  flex-shrink: 0;
}

.diet-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.badge-diet {
  font-size: 0.74rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-primary);
  font-weight: 600;
  border: 1px solid var(--accent-border);
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--bg-card);
  position: sticky;
  bottom: 0;
}

.btn-modal-action {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  transition: all 0.2s;
}

.btn-modal-action:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* ==========================================
   SECCIÓN EDUCATIVA Y GUÍA DIDÁCTICA SEO
   ========================================== */
.edu-section {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.edu-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
}

.edu-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.edu-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.edu-card p {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.seo-guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 2rem;
  margin-bottom: 2.5rem;
}

.seo-guide-section h2 {
  font-size: 1.35rem;
  margin-bottom: 1rem;
}

.seo-guide-section p {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.65;
  margin-bottom: 1.25rem;
}

/* Acordeón de preguntas frecuentes */
.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card-subtle);
  overflow: hidden;
}

.faq-question {
  width: 100%;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: none;
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.faq-icon-arrow {
  transition: transform 0.25s ease;
  color: var(--accent-primary);
}

.faq-item.active .faq-icon-arrow {
  transform: rotate(180deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
  padding: 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.faq-item.active .faq-answer {
  max-height: 350px;
  padding: 0 1.25rem 1.25rem 1.25rem;
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */
@media (max-width: 992px) {
  .filter-dropdowns-group {
    grid-template-columns: 1fr 1fr;
  }
  .kpi-summary-strip {
    grid-template-columns: 1fr 1fr;
  }
  .edu-section {
    grid-template-columns: 1fr;
  }
  .modal-details-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .filter-dropdowns-group {
    grid-template-columns: 1fr;
  }
  .kpi-summary-strip {
    grid-template-columns: 1fr;
  }
  .kpi-cell {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
  }
  .kpi-cell:last-child {
    border-bottom: none;
  }
  .modal-kpis-grid {
    grid-template-columns: 1fr 1fr;
  }
  .tool-view-tabs {
    flex-direction: column;
  }
  .tab-btn {
    width: 100%;
    justify-content: center;
  }
  .tab-btn.btn-random-pill {
    margin-left: 0;
  }
}

