/**
 * Estilos principales — Generador de pósters minimalistas de mapas y rutas GPX
 * Fijate Tools
 */

:root,
[data-theme="dark"] {
  color-scheme: dark;
  --font-main: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-app: #070b14;
  --bg-card: #111827;
  --bg-surface: #111827;
  --bg-surface-elevated: #1e293b;
  --bg-surface-hover: #293548;
  --bg-input: #0b1220;

  --border-color: rgba(148, 163, 184, 0.18);
  --border-subtle: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.32);

  --text-main: #f8fafc;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --primary: #38bdf8;
  --primary-color: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-light: rgba(56, 189, 248, 0.14);

  --accent: #f59e0b;
  --accent-light: rgba(245, 158, 11, 0.14);
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.14);
  --danger: #f43f5e;
  --danger-light: rgba(244, 63, 94, 0.14);

  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow-card: 0 10px 28px -6px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  color-scheme: light;
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --bg-surface-hover: #e2e8f0;
  --bg-input: #f8fafc;

  --border-color: #cbd5e1;
  --border-subtle: #e2e8f0;
  --border-strong: #94a3b8;

  --text-main: #0f172a;
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;

  --primary: #0284c7;
  --primary-color: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: rgba(2, 132, 199, 0.12);

  --accent: #d97706;
  --accent-light: rgba(217, 119, 6, 0.12);
  --success: #059669;
  --success-light: rgba(5, 150, 105, 0.12);
  --danger: #e11d48;
  --danger-light: rgba(225, 29, 72, 0.12);

  --shadow-card: 0 6px 22px -4px rgba(15, 23, 42, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.hero-title,
.faq-section-title {
  font-family: var(--font-heading);
}

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

.tool-layout {
  flex: 1 0 auto;
  margin-top: 1.25rem;
  margin-bottom: 2.5rem;
}

/* Badges en .tool-quick-bar */
.privacy-pill,
.engine-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.38rem 0.75rem;
  border-radius: 999px;
  white-space: nowrap;
}

.privacy-pill {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.28);
}

.engine-pill {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(56, 189, 248, 0.28);
}

/* Botones estandarizados */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.5rem 0.95rem;
  font-family: var(--font-main);
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

[data-theme="dark"] .btn-primary {
  color: #06121e;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

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

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
}

.btn-sm {
  min-height: 40px;
  padding: 0.42rem 0.8rem;
  font-size: 0.82rem;
}

/* Formularios y selects estilizados en ambos temas */
.form-control,
.studio-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 40px;
  height: 40px;
  padding: 0.45rem 0.8rem;
  font-family: var(--font-main);
  font-size: 0.88rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-main);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.form-control:focus,
.studio-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.studio-select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  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%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 15px 15px;
}

[data-theme="light"] .studio-select {
  background-color: #f8fafc;
  color: #0f172a;
  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='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.studio-select option {
  background-color: #0f172a;
  color: #f8fafc;
}

[data-theme="light"] .studio-select option {
  background-color: #ffffff;
  color: #0f172a;
}

/* Estudio principal: 2 columnas responsivas */
.studio-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: clamp(1rem, 2vw, 1.5rem);
  width: 100%;
  max-width: 100%;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.controls-column {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  min-width: 0;
}

.preview-column {
  position: sticky;
  top: 84px;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-width: 0;
}

/* Pestañas de modo Ciudad / Ruta GPX */
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.35rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.mode-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 42px;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

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

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

[data-theme="dark"] .mode-tab-btn.active {
  color: #06121e;
}

.control-section {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.section-heading-sm {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.mode-panel {
  display: none;
  flex-direction: column;
  gap: 0.85rem;
}

.mode-panel.active {
  display: flex;
}

/* Buscador ciudad + input flex seguro */
.search-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
}

.search-row .form-control {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
}

.search-results-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.search-result-btn {
  width: 100%;
  min-height: 40px;
  padding: 0.5rem 0.75rem;
  text-align: left;
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
}

.search-result-btn:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

/* Chips de ciudades */
.chips-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.city-chip-btn {
  min-height: 40px;
  padding: 0.4rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.16s ease;
}

.city-chip-btn:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.city-chip-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* Dropzone de rutas GPX */
.route-dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  padding: 0.95rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.55rem;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.route-dropzone:hover,
.route-dropzone.is-dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.route-dropzone-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
}

.route-dropzone-sub {
  font-size: 0.77rem;
  color: var(--text-muted);
}

.demo-routes-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.demo-route-btn {
  min-height: 42px;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.79rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.16s ease;
}

.demo-route-btn:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.demo-route-btn.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.route-stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.route-stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.route-stat-lbl {
  font-size: 0.69rem;
  color: var(--text-muted);
}

.route-stat-val {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Sliders y toggles */
.range-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.range-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.range-header strong {
  font-family: var(--font-mono);
  color: var(--primary);
}

.range-input {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
}

.toggles-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.toggle-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.35rem 0.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.toggle-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* Paletas de color */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.palette-swatch-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 42px;
  padding: 0.4rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-main);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.16s ease;
}

.palette-swatch-btn:hover {
  border-color: var(--primary);
  color: var(--text-main);
}

.palette-swatch-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--text-main);
}

.swatch-preview {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-shrink: 0;
}

.swatch-bar {
  width: 16px;
  height: 3px;
  border-radius: 2px;
}

.swatch-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
}

.swatch-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-colors-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.color-pick-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.color-pick-item input[type="color"] {
  width: 100%;
  height: 36px;
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  cursor: pointer;
}

/* Estilos de lámina */
.style-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.style-option-btn {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-height: 54px;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  transition: all 0.16s ease;
}

.style-option-btn:hover {
  border-color: var(--primary);
}

.style-option-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--text-main);
}

.style-opt-title {
  font-size: 0.81rem;
  font-weight: 700;
  color: var(--text-main);
}

.style-opt-desc {
  font-size: 0.71rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Campos de texto y formato */
.two-col-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}

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

/* Lienzo de previsualización */
.preview-stage-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.preview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.preview-dims-badge {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
}

.zoom-controls-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.zoom-controls-group .btn-sm {
  min-width: 40px;
  padding: 0.35rem 0.55rem;
}

.poster-preview-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 360px;
  padding: 0.5rem;
  background: radial-gradient(circle at center, rgba(148, 163, 184, 0.08) 0%, transparent 70%);
  border-radius: var(--radius-md);
  overflow: hidden;
}

#poster-preview-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 22px 45px -12px rgba(0, 0, 0, 0.6);
  cursor: grab;
  touch-action: none;
}

#poster-preview-canvas.is-grabbing {
  cursor: grabbing;
}

.preview-hint {
  margin: 0;
  text-align: center;
  font-size: 0.77rem;
  color: var(--text-muted);
}

.export-actions-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

/* Modales accesibles y toast */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-dialog {
  width: 100%;
  max-width: 540px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 1.15rem 1.25rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-body ul {
  margin: 0.5rem 0 0 1.1rem;
  padding: 0;
}

.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.toast-container {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(360px, calc(100vw - 2rem));
}

.toast-item {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.84rem;
  font-weight: 500;
  box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.45);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast-item.toast-success {
  border-left-color: var(--success);
}

.toast-item.is-leaving {
  opacity: 0;
  transform: translateY(6px);
}

/* Responsivo tablet y móvil */
@media (max-width: 1024px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }

  .preview-column {
    position: static;
    order: -1;
  }
}

@media (max-width: 640px) {
  .chips-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .route-stats-strip,
  .two-col-fields,
  .toggles-list,
  .style-grid,
  .palette-grid,
  .export-actions-bar,
  .demo-routes-grid {
    grid-template-columns: 1fr;
  }

  .search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .search-row .form-control {
    width: 100%;
    flex: none;
  }

  .btn,
  .studio-select,
  .form-control {
    width: 100%;
    min-height: 42px;
  }

  .zoom-controls-group .btn-sm {
    width: auto;
  }
}
