/**
 * Estilos canónicos para la Guía interactiva de banderas e identidades LGTBIQ+
 * Fijate Tools
 */

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

  /* Colores base - 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-pride: linear-gradient(135deg, #e40303 0%, #ff8c00 20%, #ffed00 40%, #008026 60%, #004dff 80%, #750787 100%);
  --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 28px 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: 2rem;
  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: var(--accent-pride);
}

.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: 780px;
}

/* Barra de control: Buscador y filtros */
.controls-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-box-wrapper {
  position: relative;
  margin-bottom: 1.25rem;
}

.search-box-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);
}

.filters-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.filter-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;
}

.filter-btn:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  border-color: var(--text-subtle);
}

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

.results-status-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);
}

/* Grid de banderas */
.flags-grid-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.flag-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}

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

.flag-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.flag-card-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: #000000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border-subtle);
}

.flag-card-preview svg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.flag-card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

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

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

.flag-card-year {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-subtle);
}

.flag-card-title {
  font-size: 1.125rem;
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.flag-card-author {
  font-size: 0.825rem;
  color: var(--text-subtle);
  margin-bottom: 0.85rem;
  flex: 1;
}

.flag-card-stripes-dots {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.stripe-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

/* Estado vacío */
.flags-empty-state {
  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;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 42px;
  text-decoration: none;
  border: none;
}

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

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

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

.btn-secondary:hover {
  background: var(--bg-surface-subtle);
  border-color: var(--text-subtle);
}

/* Taller de banderas personalizadas */
.builder-section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 3rem;
  box-shadow: var(--shadow-card);
}

.builder-header {
  margin-bottom: 1.5rem;
}

.builder-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

.builder-layout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

.builder-preview-wrapper {
  background: #000000;
  border-radius: var(--radius-md);
  overflow: hidden;
  aspect-ratio: 3 / 2;
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-card);
}

.builder-controls-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.builder-control-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.builder-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
}

.builder-select {
  width: 100%;
  height: 42px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0 0.85rem;
  font-family: var(--font-main);
  cursor: pointer;
}

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

.builder-checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.9rem;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
}

.builder-checkbox-label input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.builder-stripes-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.builder-stripe-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
}

.stripe-index-badge {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 65px;
}

.builder-color-input {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 4px;
}

.builder-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.builder-color-input::-webkit-color-swatch {
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}

.builder-hex-text {
  flex: 1;
  height: 32px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-main);
  text-transform: uppercase;
}

.builder-hex-text:focus {
  outline: none;
  border-color: var(--border-focus);
}

.builder-presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.preset-palette-btn {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 0.785rem;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.preset-palette-btn:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--primary);
}

.builder-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Glosario y recursos */
.info-section-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin-bottom: 3rem;
  box-shadow: var(--shadow-card);
}

.info-section-title {
  font-size: 1.45rem;
  margin-bottom: 0.5rem;
}

.info-section-desc {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.glossary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.glossary-card {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.15rem;
}

.glossary-term {
  font-size: 1.025rem;
  color: var(--primary);
  margin-bottom: 0.45rem;
}

.glossary-def {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

.resource-card {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

.resource-card-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.65rem;
}

.resource-icon {
  font-size: 1.35rem;
}

.resource-name {
  font-size: 1.05rem;
  line-height: 1.3;
}

.resource-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.15rem;
  flex: 1;
}

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

.btn-resource-phone,
.btn-resource-web {
  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);
  text-decoration: none;
  min-height: 38px;
}

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

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

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

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

/* Acordeón FAQ semántico */
.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;
}

/* Modal accesible */
.app-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.app-modal.open {
  display: flex;
}

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

.modal-dialog {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  z-index: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 2;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.modal-close-btn:hover {
  background: #e11d48;
  color: #ffffff;
  border-color: #e11d48;
}

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

.modal-flag-hero-preview {
  width: 100%;
  aspect-ratio: 3 / 2;
  background: #000000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-card);
}

.modal-info-block {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.modal-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.meta-field-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-subtle);
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.meta-field-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.modal-history-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.65;
}

.modal-subheading {
  font-size: 1.15rem;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Desglose franja por franja */
.stripes-detail-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stripe-detail-row {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
}

.stripe-color-pill {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

.stripe-text-info {
  flex: 1;
}

.stripe-header-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.2rem;
}

.stripe-name {
  font-size: 0.925rem;
  color: var(--text-main);
}

.stripe-hex-code {
  font-size: 0.8rem;
  background: var(--bg-surface-elevated);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  color: var(--primary);
}

.stripe-meaning {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Paleta interactiva del modal */
.modal-palette-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.palette-swatch-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 38px;
}

.palette-swatch-btn:hover {
  border-color: var(--primary);
  background: var(--bg-surface-elevated);
}

.swatch-color {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.swatch-label {
  font-family: var(--font-mono);
  font-size: 0.825rem;
  color: var(--text-main);
  text-transform: uppercase;
}

.modal-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

/* Toast de feedback */
.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) {
  .builder-layout-grid {
    grid-template-columns: 1fr;
  }
}

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

  .controls-section {
    padding: 1.25rem 1rem;
  }

  .filters-wrapper {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
  }

  .filter-btn {
    flex-shrink: 0;
  }

  .flags-grid-container {
    grid-template-columns: 1fr;
  }

  .modal-dialog {
    padding: 0;
  }

  .modal-header,
  .modal-body {
    padding: 1.25rem;
  }

  .modal-actions-bar,
  .builder-actions-row {
    flex-direction: column;
  }

  .modal-actions-bar .btn,
  .builder-actions-row .btn {
    width: 100%;
  }
}
