/**
 * style.css - Hoja de estilos canónica para el Explorador 3D de fondos manga (España)
 * Fijate Tools
 */

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

  /* Colores temáticos */
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

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

  --accent-color: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="dark"] {
  --bg-primary: #090d16;
  --bg-surface: #111827;
  --bg-surface-elevated: #1e293b;
  --border-color: #1f293d;
  --border-focus: #60a5fa;

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

  --accent-color: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

/* Reset y estructura básica */
*, *::before, *::after {
  box-sizing: border-box;
}

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

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

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

/* Layout principal */
.tool-layout {
  max-width: 1320px;
  margin: 1rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
}

.tool-with-sidebar {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

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

/* Cuadrícula de la aplicación (Visor 3D a la izquierda, Panel lateral a la derecha) */
.manga-scout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 1.25rem;
  align-items: start;
  margin-top: 1rem;
}

/* Contenedor del visor 3D */
.viewport-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.stage-container {
  position: relative;
  width: 100%;
  height: min(72vh, 720px);
  min-height: 440px;
  background-color: #0d121d;
  overflow: hidden;
}

#canvas-3d {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Barras de control flotantes sobre el visor 3D */
.viewport-floating-top,
.viewport-floating-bottom {
  position: absolute;
  left: 10px;
  right: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
  z-index: 10;
}

.viewport-floating-top {
  top: 10px;
}

.viewport-floating-bottom {
  bottom: 10px;
  justify-content: space-between;
  align-items: center;
}

.control-pill-group {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-md);
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  pointer-events: auto;
}

[data-theme="dark"] .control-pill-group {
  background: rgba(17, 24, 39, 0.92);
  border-color: rgba(255, 255, 255, 0.12);
}

/* Segmented control para modos de render */
.mode-segmented {
  display: inline-flex;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 2px;
  border: 1px solid var(--border-color);
}

.btn-mode {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

.btn-mode.active {
  background: var(--accent-color);
  color: #ffffff;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Deslizadores compactos dentro de píldoras */
.pill-slider-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.pill-slider-item input[type="range"] {
  width: 75px;
  height: 4px;
  accent-color: var(--accent-color);
  cursor: pointer;
}

.pill-slider-item .pill-val {
  font-size: 11px;
  min-width: 24px;
  color: var(--text-main);
  font-weight: 600;
}

/* Botón icono de luz */
.btn-icon-pill {
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-pill:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

/* Popover de parámetros de luz solar y trama */
.light-popover {
  position: absolute;
  top: 52px;
  left: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-lg);
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 280px;
  pointer-events: auto;
}

.light-popover.hidden {
  display: none;
}

.light-popover-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}

.light-popover-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent-color);
}

/* Barra inferior del viewport: información de estado y atribución OSM */
.viewport-footer-info {
  padding: 8px 14px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.osm-attribution {
  font-size: 11px;
  color: var(--text-dim);
}

.osm-attribution a {
  color: inherit;
  text-decoration: underline;
}

/* Panel lateral (Side panel) */
.manga-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.card-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Formulario de búsqueda */
.search-form {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.search-input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-main);
  font-size: 13px;
  font-family: inherit;
}

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

.btn-search {
  height: 40px;
  padding: 0 16px;
  background: var(--accent-color);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

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

/* Lista de resultados de búsqueda */
.search-results-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px;
  margin-bottom: 8px;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-results-box.hidden {
  display: none;
}

.search-results-heading {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 2px 6px;
}

.search-result-item {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  background: var(--bg-surface);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text-main);
  cursor: pointer;
  line-height: 1.3;
}

.search-result-item:hover {
  border-color: var(--accent-color);
  background: var(--accent-soft);
}

/* Desplegable de presets y selects responsivos (Regla 5 y 10) */
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 40px 0 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-size: 13px;
  font-family: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  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='%2364748b' 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;
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Fila del mini-mapa y cruceta de movimiento */
.minimap-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-top: 10px;
}

.minimap-wrapper {
  flex: 1 1 0%;
  height: 220px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #1a202c;
  position: relative;
}

#mini-map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Cruceta de movimiento a manzanas vecinas (D-pad) */
.move-pad {
  display: grid;
  grid-template-columns: repeat(2, 34px);
  grid-template-areas:
    "n n"
    "w e"
    "s s";
  gap: 4px;
  justify-content: center;
  align-content: center;
}

.btn-move-pad {
  width: 34px;
  height: 34px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-move-pad:hover {
  border-color: var(--accent-color);
  background: var(--accent-soft);
  color: var(--accent-color);
}

.btn-move-pad[data-dir="n"] { grid-area: n; }
.btn-move-pad[data-dir="s"] { grid-area: s; }
.btn-move-pad[data-dir="w"] { grid-area: w; }
.btn-move-pad[data-dir="e"] { grid-area: e; }

/* Botones de acción del pin y cámara */
.pin-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-action-pin {
  flex: 1 1 0%;
  height: 40px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-action-pin:hover:not(:disabled) {
  border-color: var(--accent-color);
  background: var(--accent-soft);
  color: var(--accent-color);
}

.btn-action-pin:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.btn-action-pin.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

/* Ayudas contextuales */
.panel-hint {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Opciones de escena */
.options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.form-label {
  font-size: 12.5px;
  color: var(--text-muted);
}

.btn-reroll {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: all 0.15s ease;
}

.btn-reroll:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
  background: var(--accent-soft);
}

/* Sección de exportación */
.export-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-export {
  flex: 1 1 0%;
  height: 42px;
  background: #16a34a;
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.15s ease;
}

.btn-export:hover {
  background: #15803d;
}

.btn-secondary {
  height: 40px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 12px;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  border-color: var(--accent-color);
  color: var(--accent-color);
}

.export-links-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.export-links-row .btn-secondary {
  flex: 1;
}

/* Notificación flotante de exportación */
.export-feedback {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  display: none;
}

.export-feedback.show {
  display: block;
}

.export-feedback.info {
  background: var(--accent-soft);
  color: var(--accent-color);
  border: 1px solid var(--border-color);
}

.export-feedback.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.export-feedback.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* Cortina de carga (Overlay) */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13, 18, 29, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 50;
  color: #ffffff;
}

.loading-overlay.hidden {
  display: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 13.5px;
  font-weight: 600;
  max-width: 80%;
  text-align: center;
}

/* Guía de uso y acordeón de información */
.seo-guide-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-top: 1.5rem;
}

.seo-guide-section h2 {
  font-size: 1.15rem;
  margin-top: 0;
  margin-bottom: 0.75rem;
  color: var(--text-main);
}

.seo-guide-section p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.seo-guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.seo-guide-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.seo-guide-card h3 {
  font-size: 0.95rem;
  margin-top: 0;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.seo-guide-card p {
  font-size: 0.85rem;
  margin: 0;
}

/* Adaptabilidad para dispositivos móviles y tablets */
@media (max-width: 1024px) {
  .manga-scout-grid {
    grid-template-columns: 1fr;
  }

  .stage-container {
    height: 55vh;
    min-height: 380px;
  }
}

@media (max-width: 640px) {
  .stage-container {
    height: 48vh;
    min-height: 320px;
  }

  .viewport-floating-top {
    position: static;
    padding: 8px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
  }

  .viewport-floating-bottom {
    position: static;
    padding: 8px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
  }

  .mode-segmented {
    width: 100%;
    display: flex;
    overflow-x: auto;
  }

  .btn-mode {
    flex: 1 1 auto;
    text-align: center;
  }

  .minimap-row {
    flex-direction: column;
  }

  .move-pad {
    grid-template-columns: repeat(4, 1fr);
    grid-template-areas: "w n s e";
    width: 100%;
  }

  .btn-move-pad {
    width: 100%;
    height: 40px;
  }
}
