/**
 * Calculadora de telescopios, oculares y prismáticos
 * Estilos canónicos adaptativos (claro / oscuro / responsive)
 */

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

  --bg-page: #0b0f17;
  --bg-card: #131b2a;
  --bg-card-header: #192438;
  --bg-input: #1a253a;
  --bg-input-hover: #22304a;
  --border-color: #24344d;
  --border-focus: #3b82f6;

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

  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: rgba(59, 130, 246, 0.15);

  --accent-color: #ff8507;
  --accent-hover: #e07200;
  --accent-light: rgba(255, 133, 7, 0.15);

  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-header: #f1f5f9;
  --bg-input: #ffffff;
  --bg-input-hover: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #94a3b8;

  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.08);

  --accent-color: #ff8507;
  --accent-hover: #e07200;
  --accent-light: rgba(255, 133, 7, 0.12);

  --shadow-card: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Reset y estructura canónica */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

h1, h2, h3, h4, .brand-title, .card-title, .faq-title {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
}

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

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

/* Pestañas */
.tool-tabs-container {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.25rem;
  overflow-x: auto;
  max-width: 100%;
  width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

.tool-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: 1px solid transparent;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.tool-tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-card);
}

.tool-tab-btn.active {
  color: var(--primary-color);
  background: var(--bg-card);
  border-color: var(--border-color) var(--border-color) transparent;
  border-bottom-color: var(--primary-color);
}

.tool-tab-pane {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
  max-width: 100%;
  width: 100%;
}

/* Tarjetas */
.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  min-width: 0;
  max-width: 100%;
}

.card-header-clean {
  margin-bottom: 1.25rem;
}

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

.card-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.title-with-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-accent {
  background: var(--accent-light);
  color: var(--accent-color);
  border: 1px solid rgba(255, 133, 7, 0.3);
}

.badge-pill {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-pill-optimal {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success-color);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-pill-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning-color);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-pill-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger-color);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Presets */
.presets-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed var(--border-color);
  flex-wrap: wrap;
}

.presets-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.presets-chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.chip-btn {
  padding: 0.35rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

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

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

/* Formularios */
.grid-form-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

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

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

.form-label-xs {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.field-hint {
  font-size: 0.74rem;
  color: var(--text-subtle);
}

.select-wrapper {
  position: relative;
  width: 100%;
}

.form-select, .form-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 2.25rem 0 0.85rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.92rem;
  appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 6px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2394a3b8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
}

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

select {
  cursor: pointer;
  color-scheme: dark light;
}

select option,
select optgroup {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.form-select-sm {
  height: 36px;
  padding: 0 1.85rem 0 0.65rem;
  font-size: 0.82rem;
}

/* Tablas y Eyepieces */
.eyepieces-table-wrap,
.table-responsive {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  display: block;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-top: 1rem;
}

.table-clean {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.table-clean th {
  background: var(--bg-card-header);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table-clean td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.table-clean tr:last-child td {
  border-bottom: none;
}

.table-clean tr.is-active-eyepiece {
  background: var(--primary-light);
}

.btn-row-action {
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.15s;
}

.btn-row-action:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
  border-color: var(--danger-color);
}

.radio-eyepiece {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--primary-color);
}

.btn-action-small {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-action-small:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

/* Highlight card */
.highlight-card {
  border-color: rgba(59, 130, 246, 0.35);
  background: linear-gradient(180deg, var(--bg-card) 0%, rgba(59, 130, 246, 0.04) 100%);
}

.result-hero-box {
  text-align: center;
  padding: 1.25rem 0 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.result-hero-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.5rem;
}

.result-hero-time {
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
  margin-bottom: 0.4rem;
}

.result-hero-desc {
  font-size: 0.95rem;
  color: var(--primary-color);
  font-weight: 500;
}

.metrics-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-top: 1.5rem;
}

.metric-card {
  background: var(--bg-card-header);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.metric-val {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
}

.metric-sub {
  font-size: 0.72rem;
  color: var(--text-subtle);
}

/* Simulador Canvas */
.sim-object-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sim-canvas-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: #03060b;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
}

.sim-canvas {
  width: 100%;
  max-width: 580px;
  height: auto;
  aspect-ratio: 600 / 420;
  display: block;
}

.sim-overlay-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 0.75rem 1.25rem 0.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.sim-badge {
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
}

.sim-scale-bar-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sim-scale-line {
  width: 60px;
  height: 2px;
  background: #e2e8f0;
  position: relative;
}

.sim-scale-line::before, .sim-scale-line::after {
  content: '';
  position: absolute;
  top: -3px;
  width: 2px;
  height: 8px;
  background: #e2e8f0;
}

.sim-scale-line::before { left: 0; }
.sim-scale-line::after { right: 0; }

.sim-scale-text {
  font-size: 0.72rem;
  color: #94a3b8;
  font-family: var(--font-mono);
}

/* Modal dialog */
.clean-dialog {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  color: var(--text-main);
  padding: 0;
  max-width: 480px;
  width: 90%;
  margin: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.clean-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.dialog-content {
  padding: 1.5rem;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.dialog-title {
  font-size: 1.15rem;
}

.dialog-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-subtle);
  cursor: pointer;
  line-height: 1;
}

.dialog-close:hover {
  color: var(--text-main);
}

.dialog-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Regla estricta: botones naranja con texto e icono en negro */
.btn-action-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0 1.5rem;
  background-color: var(--accent-color);
  color: #000000;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.15s;
}

.btn-action-primary:hover {
  background-color: var(--accent-hover);
  color: #000000;
}

.btn-action-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0 1.15rem;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-action-secondary:hover {
  border-color: var(--text-muted);
}

/* SEO y FAQs */
.seo-article-card {
  margin-top: 2rem;
}

.seo-prose h3 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--text-main);
}

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

.faq-accordion-container {
  margin-top: 2rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.faq-title {
  font-size: 1.15rem;
  margin-bottom: 1rem;
}

.faq-item {
  border-bottom: 1px solid var(--border-color);
}

.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  list-style: none;
}

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

.faq-arrow {
  color: var(--text-subtle);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.faq-item[open] .faq-arrow {
  transform: rotate(180deg);
  color: var(--primary-color);
}

.faq-answer {
  padding: 0 0 1rem;
}

.faq-answer p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Adaptación móvil estricta */
@media (max-width: 900px) {
  .grid-form-3 {
    grid-template-columns: 1fr;
  }

  .metrics-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 580px) {
  .metrics-grid-4 {
    grid-template-columns: 1fr;
  }

  .chip-btn {
    flex: 1 1 calc(50% - 0.4rem);
    text-align: center;
  }
}
