/* ==========================================================================
   Simulador 3D de Astrolabio Andalusí y Reloj Astronómico Medieval
   Fijate Tools - Estilos Canónicos Oficiales
   ========================================================================== */

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

  /* Paleta cromática de latón astronómico andalusí */
  --brass-gold-light: #fff2b2;
  --brass-gold: #d4af37;
  --brass-gold-dark: #8c6a18;
  --brass-border: rgba(212, 175, 55, 0.35);
  --brass-glow: rgba(212, 175, 55, 0.25);

  --bg-space: #070b12;
  --bg-card: #0f172a;
  --bg-card-hover: #17233d;
  --bg-input: #131c31;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-gold: #f8e39f;

  --accent-cyan: #38bdf8;
  --accent-emerald: #34d399;
  --accent-amber: #fbbf24;
  --accent-crimson: #f87171;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base de contención */
body {
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-space);
  color: var(--text-main);
  font-family: var(--font-main);
  margin: 0;
  padding: 0;
}

.tool-layout {
  max-width: 1280px;
  margin: 1rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
  box-sizing: border-box;
}

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

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Sidebar para desktop >= 1536px */
.tool-ad-sidebar {
  display: none;
  width: 300px;
  flex-shrink: 0;
}

@media (min-width: 1536px) {
  .tool-ad-sidebar {
    display: block;
    position: sticky;
    top: 2rem;
    height: fit-content;
  }
}

/* Tarjeta principal del simulador */
.astrolabe-main-card {
  background: linear-gradient(180deg, #10192e 0%, #0a1120 100%);
  border: 1px solid var(--brass-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55), 0 0 24px var(--brass-glow);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow: hidden;
}

@media (min-width: 768px) {
  .astrolabe-main-card {
    padding: 1.75rem;
  }
}

/* Barra superior de controles rápidos */
.astrolabe-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
}

.city-selector-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 260px;
  min-width: 0;
}

.control-label {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-gold);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Select canónico responsivo */
.astrolabe-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 40px 0 0.85rem;
  background-color: var(--bg-input);
  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='%23d4af37' 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 14px center;
  background-size: 16px;
  border: 1px solid var(--brass-border);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-main);
  font-size: 0.92rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  appearance: none;
  cursor: pointer;
  transition: var(--transition);
}

.astrolabe-select:focus {
  outline: none;
  border-color: var(--brass-gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.25);
}

.city-historic-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.35;
}

/* Botoneras de vista y acción */
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.btn-pill-group {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--brass-border);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}

.btn-pill {
  min-height: 38px;
  padding: 0 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: var(--transition);
}

.btn-pill.active {
  background: linear-gradient(135deg, #d4af37 0%, #a8841e 100%);
  color: #1a1103;
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.4);
}

.btn-action-gold {
  min-height: 40px;
  padding: 0 1rem;
  background: rgba(212, 175, 55, 0.12);
  border: 1px solid var(--brass-gold);
  color: var(--brass-gold-light);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: var(--transition);
}

.btn-action-gold:hover {
  background: var(--brass-gold);
  color: #110b02;
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.35);
  transform: translateY(-1px);
}

/* Área central de renderizado visual 3D / 2D */
.astrolabe-viewport-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (min-width: 1024px) {
  .astrolabe-viewport-grid {
    grid-template-columns: 1.15fr 0.85fr;
  }
}

.astrolabe-viewport-box {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 600px;
  background: radial-gradient(circle at 50% 50%, #0d1527 0%, #05080e 100%);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
}

#astrolabe-3d-wrapper,
#astrolabe-3d-canvas-container {
  width: 100%;
  height: 100%;
  position: relative;
}

#astrolabe-2d-wrapper {
  width: 100%;
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  box-sizing: border-box;
}

#astrolabe-2d-svg-container {
  width: 100%;
  height: 100%;
  max-width: 560px;
  max-height: 560px;
  cursor: crosshair;
}

/* Insignia de cara flotante en el visor */
.viewport-floating-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(10, 16, 28, 0.85);
  border: 1px solid var(--brass-border);
  backdrop-filter: blur(8px);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-gold);
  pointer-events: none;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Botones flotantes de cámara sobre el visor */
.viewport-floating-controls {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  z-index: 10;
}

.btn-icon-float {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--brass-border);
  color: var(--text-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(6px);
}

.btn-icon-float:hover {
  background: var(--brass-gold);
  color: #1a1103;
}

/* Panel lateral de controles angulares e interactividad */
.astrolabe-control-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.control-card {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.control-card-title {
  font-family: var(--font-heading);
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--brass-gold-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.slider-val-badge {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-gold);
}

.astrolabe-slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: #1e293b;
  accent-color: var(--brass-gold);
  outline: none;
  cursor: pointer;
}

/* Conmutador checkbox de Cielo en vivo */
.toggle-switch-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  user-select: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.toggle-switch-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--brass-gold);
  cursor: pointer;
}

/* Cuadrícula de inputs manuales de fecha/hora */
.manual-datetime-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.input-datetime {
  width: 100%;
  height: 40px;
  padding: 0 0.65rem;
  background: var(--bg-input);
  border: 1px solid var(--brass-border);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  box-sizing: border-box;
}

.preset-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.btn-preset-mini {
  min-height: 32px;
  padding: 0 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: var(--text-gold);
  font-size: 0.76rem;
  font-family: var(--font-heading);
  font-weight: 600;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.btn-preset-mini:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--brass-gold);
}

/* Panel de Resultados y Cálculos en Tiempo Real */
.astronomical-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .astronomical-kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.kpi-card {
  background: rgba(13, 20, 36, 0.8);
  border: 1px solid rgba(212, 175, 55, 0.22);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: var(--transition);
}

.kpi-card:hover {
  border-color: var(--brass-gold);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.kpi-title {
  font-family: var(--font-heading);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: none;
  color: var(--text-muted);
}

.kpi-value {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-gold);
  line-height: 1.2;
}

.kpi-value.gold-large {
  font-size: 1.35rem;
  color: #ffe699;
  text-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
}

.kpi-sub {
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.3;
}

/* Sección de Misiones Históricas Guiadas */
.missions-section {
  background: linear-gradient(180deg, #121c33 0%, #0d1527 100%);
  border: 1px solid var(--brass-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.missions-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.missions-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--brass-gold-light);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.missions-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.mission-selector-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

@media (min-width: 768px) {
  .mission-selector-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.btn-mission-step {
  min-height: 48px;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--brass-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 0.86rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-mission-step:hover {
  background: rgba(212, 175, 55, 0.15);
  border-color: var(--brass-gold);
}

.btn-mission-step.active {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.25) 0%, rgba(140, 106, 24, 0.25) 100%);
  border-color: var(--brass-gold);
  color: #fff4cc;
  box-shadow: 0 0 16px rgba(212, 175, 55, 0.2);
}

.mission-feedback-card {
  display: none;
  background: rgba(26, 38, 66, 0.75);
  border: 1px solid var(--accent-amber);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.1rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #fef3c7;
  animation: fadeIn 0.3s ease-out;
}

/* Lista interactiva de estrellas visibles */
.stars-drawer-card {
  background: rgba(11, 18, 32, 0.85);
  border: 1px solid var(--brass-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.stars-list-scrollable {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 6px;
  list-style: none;
  margin: 0;
  padding-left: 0;
}

@media (min-width: 640px) {
  .stars-list-scrollable {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .stars-list-scrollable {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.star-item {
  background: rgba(20, 30, 52, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.star-item:hover {
  background: rgba(212, 175, 55, 0.18);
  border-color: var(--brass-gold);
  transform: translateY(-1px);
}

.star-item.visible {
  border-left: 3px solid var(--brass-gold);
}

.star-item.hidden {
  opacity: 0.5;
  border-left: 3px solid #64748b;
}

.star-info-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.star-name {
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 700;
  color: #fff;
}

.star-name .arabic {
  font-size: 0.78rem;
  color: var(--text-gold);
  font-weight: 600;
}

.star-alt {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
}

.alt-positive {
  color: #facc15;
}

.alt-negative {
  color: #94a3b8;
}

.star-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Guía explicativa y Acordeones de FAQ Histórica */
.guide-accordion-section {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.accordion-item {
  background: var(--bg-card);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.accordion-summary {
  padding: 1rem 1.25rem;
  font-family: var(--font-heading);
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--brass-gold-light);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

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

.accordion-summary::after {
  content: '+';
  font-size: 1.25rem;
  color: var(--brass-gold);
  transition: transform 0.2s;
}

details[open] .accordion-summary::after {
  content: '−';
}

.accordion-content {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.9rem;
  line-height: 1.65;
  color: #cbd5e1;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.accordion-content p {
  margin: 0.75rem 0 0;
}

.accordion-content ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.accordion-content li {
  margin-bottom: 0.35rem;
}

/* Animaciones */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar personalizado */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #090e18;
}

::-webkit-scrollbar-thumb {
  background: #2b3954;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--brass-gold);
}
