/**
 * Calculadora de sección de cable eléctrico según REBT
 * 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-card-subtle: #1a253a;
  --bg-input: #151e2f;
  --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-green: #10b981;
  --accent-green-bg: rgba(16, 185, 129, 0.12);
  --accent-amber: #f59e0b;
  --accent-amber-bg: rgba(245, 158, 11, 0.12);
  --accent-blue: #0284c7;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
}

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

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-subtle: #64748b;

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

  --accent-green: #059669;
  --accent-green-bg: #ecfdf5;
  --accent-amber: #d97706;
  --accent-amber-bg: #fffbeb;
  --accent-blue: #0369a1;

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

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

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

/* Layout */
.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%;
}

/* Tarjeta de cálculo */
.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 2rem;
  overflow: hidden;
}

.calc-card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card-header);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card-headline {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.chip-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.btn-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

/* Formulario */
.calc-grid-form {
  padding: 1.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.75rem;
}

@media (max-width: 820px) {
  .calc-grid-form {
    grid-template-columns: 1fr;
    gap: 1.25rem;
    padding: 1rem;
  }
}

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

.section-subtitle {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-color);
  margin: 0 0 0.25rem 0;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-color);
}

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

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

.form-row-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 480px) {
  .form-row-group {
    grid-template-columns: 1fr;
  }
}

/* Desplegables y campos canónicos */
.form-select,
.form-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 42px;
  padding: 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;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-select {
  appearance: none;
  -webkit-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 0.85rem center;
  background-size: 16px 16px;
  padding-right: 40px;
  cursor: pointer;
  color-scheme: dark light;
}

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

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

.input-with-unit {
  display: flex;
  align-items: center;
  position: relative;
}

.input-with-unit .form-input {
  padding-right: 70px;
}

.input-unit {
  position: absolute;
  right: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  pointer-events: none;
}

.unit-select {
  position: absolute;
  right: 4px;
  width: 65px;
  height: 34px;
  border: none;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0 20px 0 8px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  cursor: pointer;
}

/* Resultados */
.results-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.results-main-hero {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
  position: relative;
}

.hero-badge-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.status-pill {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
}

.status-ok {
  background: var(--accent-green-bg);
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
}

.standard-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  background: var(--primary-light);
  color: var(--primary-color);
}

.hero-label {
  display: block;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.hero-val-num {
  font-family: var(--font-heading);
  font-size: 3.25rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--primary-color);
}

.hero-val-unit {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-muted);
}

.hero-subtext {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
}

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

.kpi-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

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

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

.kpi-desc {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

/* Tabla comparativa */
.breakdown-box {
  margin-bottom: 1.5rem;
}

.breakdown-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
  color: var(--text-main);
}

.breakdown-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

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

.breakdown-table th,
.breakdown-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.breakdown-table th {
  background: var(--bg-card-header);
  font-weight: 600;
  color: var(--text-muted);
}

.badge-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  background: var(--accent-green-bg);
  color: var(--accent-green);
}

.badge-tag-lead {
  background: var(--accent-amber-bg);
  color: var(--accent-amber);
}

/* Acordeón de fórmulas */
.formula-details {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card-subtle);
  overflow: hidden;
}

.formula-summary {
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--primary-color);
  user-select: none;
}

.formula-content {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-main);
}

.formula-step-block {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}

.step-label {
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.35rem;
}

/* FAQ */
.seo-faq-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.75rem;
  margin-bottom: 2rem;
}

.faq-headline {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 1.25rem 0;
  color: var(--text-main);
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card-subtle);
  overflow: hidden;
}

.faq-question {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

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

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

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

.faq-answer {
  padding: 0 1rem 1rem 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.faq-answer p {
  margin: 0;
}
