/**
 * Estilos canónicos para el Buscador de recursos y apoyo LGTBI en España
 * Fijate Tools
 */

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

  /* Modo oscuro por defecto */
  --bg-app: #0b0f17;
  --bg-surface: #141b26;
  --bg-surface-elevated: #1d2636;
  --bg-surface-subtle: #182232;
  --border-subtle: #243247;
  --border-focus: #3b82f6;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.2);

  --accent-emergency: #ef4444;
  --accent-success: #10b981;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-subtle: #f8fafc;
  --border-subtle: #e2e8f0;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-glow: rgba(37, 99, 235, 0.15);

  --shadow-card: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 8px 24px rgba(15, 23, 42, 0.14);
}

/* Base y contención */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  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;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-main);
}

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

/* Layout canónico */
.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%;
}

/* Hero de la herramienta */
.tool-hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem 2.25rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.tool-hero-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #ec4899 0%, #8b5cf6 50%, #3b82f6 100%);
}

.hero-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--primary);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  margin-bottom: 1rem;
}

.hero-main-title {
  font-size: clamp(1.75rem, 3.5vw, 2.35rem);
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
}

.hero-description {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 800px;
}

/* Banner de emergencia 028 */
.emergency-banner-card {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, var(--bg-surface) 100%);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  box-shadow: var(--shadow-card);
}

.emergency-info-side {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.emergency-icon-pill {
  background: var(--accent-emergency);
  color: #ffffff;
  font-size: 1.25rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  line-height: 1;
}

.emergency-title {
  font-size: 1.25rem;
  color: #ef4444;
  margin-bottom: 0.25rem;
}

.emergency-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.emergency-btn-call {
  background: var(--accent-emergency);
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0.85rem 1.75rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  white-space: nowrap;
  transition: transform 0.2s ease, background 0.2s ease;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

.emergency-btn-call:hover {
  background: #dc2626;
  transform: translateY(-2px);
}

/* Filtros y buscador */
.search-filter-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-card);
}

.search-filter-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.search-input-wrapper {
  position: relative;
}

.search-input-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  pointer-events: none;
}

.search-input-field {
  width: 100%;
  height: 48px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 1rem 0 2.85rem;
  color: var(--text-main);
  font-size: 0.975rem;
  font-family: var(--font-main);
  transition: all 0.2s ease;
}

.search-input-field:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-input-field::placeholder {
  color: var(--text-subtle);
}

.select-ccaa-field {
  width: 100%;
  height: 48px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 1rem;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.925rem;
  cursor: pointer;
}

.select-ccaa-field:focus {
  outline: none;
  border-color: var(--border-focus);
}

.categories-pill-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.category-pill-btn {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
}

.category-pill-btn:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
}

.category-pill-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}

.results-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Mapa interactivo Leaflet */
.map-card-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow-card);
}

.map-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.map-card-title {
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.map-container-box {
  width: 100%;
  height: 440px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  z-index: 1;
}

/* Popups de Leaflet */
.leaflet-popup-content-wrapper {
  background: var(--bg-surface) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
  padding: 0 !important;
}

.leaflet-popup-content {
  margin: 1rem !important;
  line-height: 1.5;
}

.leaflet-popup-tip {
  background: var(--bg-surface) !important;
}

.map-popup-card {
  max-width: 280px;
}

.popup-category {
  font-size: 0.725rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  margin-bottom: 0.25rem;
  display: block;
}

.popup-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.popup-city {
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.popup-address {
  font-size: 0.8rem;
  color: var(--text-subtle);
  margin-bottom: 0.75rem;
}

.popup-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.popup-btn-phone,
.popup-btn-web {
  display: inline-flex;
  align-items: center;
  font-size: 0.775rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 4px;
  text-decoration: none;
}

.popup-btn-phone {
  background: var(--primary);
  color: #ffffff;
}

.popup-btn-web {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

/* Grid de resultados de recursos */
.resources-results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.resource-item-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-card);
}

.resource-item-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: var(--shadow-hover);
}

.resource-item-card.emergency-card {
  border-left: 4px solid var(--accent-emergency);
}

.resource-top-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.category-badge {
  font-size: 0.725rem;
  font-weight: 700;
  background: var(--bg-surface-elevated);
  color: var(--primary);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
}

.ccaa-badge {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.resource-item-title {
  font-size: 1.15rem;
  margin-bottom: 0.5rem;
  line-height: 1.35;
}

.resource-location-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.825rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}

.resource-item-desc {
  font-size: 0.885rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.25rem;
  flex: 1;
}

.resource-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.btn-res-phone,
.btn-res-web,
.btn-res-map {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.825rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  min-height: 38px;
  border: none;
  font-family: var(--font-main);
}

.btn-res-phone {
  background: var(--primary);
  color: #ffffff;
}

.btn-res-phone:hover {
  background: var(--primary-hover);
}

.btn-res-web {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.btn-res-web:hover {
  border-color: var(--primary);
}

.btn-res-map {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.btn-res-map:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
}

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

.empty-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

/* Acordeón FAQ */
.faq-accordion-section {
  margin-bottom: 3rem;
}

.faq-title {
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.faq-item[open] {
  border-color: var(--primary);
}

.faq-summary {
  padding: 1.15rem 1.25rem;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-main);
}

.faq-summary::-webkit-details-marker {
  display: none;
}

.faq-summary::after {
  content: "+";
  font-size: 1.25rem;
  color: var(--primary);
  font-family: var(--font-mono);
  font-weight: bold;
}

.faq-item[open] .faq-summary::after {
  content: "−";
}

.faq-content {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.925rem;
  line-height: 1.65;
  border-top: 1px solid var(--border-subtle);
  margin-top: 0.25rem;
  padding-top: 1rem;
}

/* Toast flotante */
.app-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #334155;
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  z-index: 2000;
}

.app-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-width: 900px) {
  .search-filter-grid {
    grid-template-columns: 1fr;
  }

  .emergency-banner-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .emergency-btn-call {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  .tool-hero-card {
    padding: 1.5rem;
  }

  .map-container-box {
    height: 320px;
  }

  .categories-pill-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
  }

  .category-pill-btn {
    flex-shrink: 0;
  }

  .resources-results-grid {
    grid-template-columns: 1fr;
  }

  .resource-footer-actions {
    flex-direction: column;
  }

  .btn-res-phone,
  .btn-res-web,
  .btn-res-map {
    width: 100%;
    justify-content: center;
  }
}
