/**
 * Estilos canónicos - Calculadora de grasa corporal y composición muscular
 * fijate.com Tools
 */

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

  /* Colores del tema oscuro (por defecto) */
  --bg-body: #090d16;
  --bg-card: #0f172a;
  --bg-card-subtle: #1e293b;
  --bg-input: #131d33;
  --border-color: rgba(148, 163, 184, 0.15);
  --border-focus: #38bdf8;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-cyan: #38bdf8;
  --accent-green: #22c55e;
  --accent-amber: #f59e0b;
  --accent-rose: #ef4444;
  --accent-purple: #a855f7;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px -5px rgba(56, 189, 248, 0.25);
}

[data-theme="light"] {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-focus: #0284c7;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.06);
  --shadow-glow: 0 0 15px -3px rgba(2, 132, 199, 0.18);
}

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

body {
  font-family: var(--font-base);
  background-color: var(--bg-body);
  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, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.015em;
}

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

/* Layout de la herramienta */
.tool-layout {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1 0 auto;
}

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

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

/* Tarjeta principal */
.card-main {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

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

.card-header-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.card-title-group h2 {
  font-size: 1.35rem;
  margin-bottom: 0.25rem;
}

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

/* Selector de métodos (Segmented Tabs) */
.method-tabs-container {
  display: flex;
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.25rem;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5rem;
}

.method-tabs-container::-webkit-scrollbar {
  display: none;
}

.method-tab-btn {
  flex: 1 1 auto;
  white-space: nowrap;
  min-height: 42px;
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-base);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.method-tab-btn:hover {
  color: var(--text-main);
  background-color: rgba(148, 163, 184, 0.08);
}

.method-tab-btn.active {
  background-color: var(--bg-card);
  color: var(--accent-cyan);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Tabs Hombre / Mujer */
.gender-selector-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.btn-gender-tab {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-base);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-gender-tab:hover {
  border-color: var(--accent-cyan);
  color: var(--text-main);
}

.btn-gender-tab.active {
  background-color: rgba(56, 189, 248, 0.12);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* Cuadrículas de formulario */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

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

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

@media (min-width: 640px) {
  .form-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-hint-badge {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
}

/* Wrappers de inputs flexbox con sufijos de unidad */
.input-suffix-wrapper {
  display: flex;
  align-items: center;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  min-height: 42px;
}

.input-suffix-wrapper:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.input-suffix-wrapper input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  min-height: 40px;
  background: transparent;
  border: none;
  padding: 0.5rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-main);
  outline: none;
}

.input-suffix-label {
  padding: 0 0.85rem;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-dim);
  background-color: rgba(148, 163, 184, 0.06);
  min-height: 40px;
  display: flex;
  align-items: center;
  user-select: none;
}

/* Desplegable estilizado conforme a Lección 208 */
select.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 40px 0.5rem 0.85rem;
  font-family: var(--font-base);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  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='%2338bdf8' 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 14px center;
}

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

select.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

/* Panel de resultados principales */
.results-hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  align-items: center;
  margin-bottom: 1.75rem;
}

@media (min-width: 860px) {
  .results-hero-grid {
    grid-template-columns: 340px 1fr;
  }
}

.gauge-canvas-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

#canvas-gauge {
  width: 100%;
  max-width: 320px;
  height: 180px;
  display: block;
}

.gauge-center-stat {
  text-align: center;
  margin-top: 0.5rem;
}

.gauge-big-pct {
  font-family: var(--font-mono);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.status-badge {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffffff;
  margin-top: 0.4rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.res-desc-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  line-height: 1.45;
}

/* Barra de reparto de masas */
.composition-bar-section {
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.comp-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.comp-bar-track {
  height: 24px;
  display: flex;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--bg-input);
  margin-bottom: 0.65rem;
}

.comp-bar-fat {
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  transition: width 0.4s ease;
}

.comp-bar-lean {
  background: linear-gradient(90deg, #10b981, #38bdf8);
  transition: width 0.4s ease;
}

.comp-bar-legends {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.825rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Grilla de KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

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

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

.kpi-title {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

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

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Caja de comparación con el historial */
.diff-history-box {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background-color: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

/* Simulador de objetivo de grasa corporal */
.goal-simulator-card {
  background: linear-gradient(145deg, rgba(30, 41, 59, 0.5), rgba(15, 23, 42, 0.9));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.goal-controls-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
}

.slider-range {
  flex: 1 1 0%;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.goal-results-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 1rem;
  background-color: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
}

.goal-res-item {
  display: flex;
  flex-direction: column;
}

.goal-res-val {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 700;
}

.goal-summary-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* Botones de acción principales */
.action-buttons-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn-primary, .btn-secondary {
  min-height: 42px;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-base);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.btn-primary {
  background-color: var(--accent-cyan);
  color: #0f172a;
  border: none;
}

.btn-primary:hover {
  background-color: #7dd3fc;
  box-shadow: var(--shadow-glow);
}

.btn-secondary {
  background-color: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: rgba(148, 163, 184, 0.15);
  border-color: var(--text-muted);
}

/* Tabla de historial */
.table-responsive-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
}

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

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

.history-table th {
  font-weight: 600;
  color: var(--text-dim);
  background-color: var(--bg-card-subtle);
}

.badge-method {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  background-color: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.badge-fat-val {
  font-family: var(--font-mono);
  font-weight: 700;
}

.status-pill {
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  background-color: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
}

.btn-icon-delete {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease;
}

.btn-icon-delete:hover {
  color: var(--accent-rose);
}

/* Modales nativos accesibles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 440px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  animation: modalScaleIn 0.2s ease-out;
}

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  margin-bottom: 0.75rem;
}

.modal-header h3 {
  font-size: 1.2rem;
}

.modal-body p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toast flotante */
.app-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: #0f172a;
  color: #f8fafc;
  border: 1px solid var(--accent-cyan);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-pill);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  z-index: 1100;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
  pointer-events: none;
}

.app-toast.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Guía didáctica SEO */
.seo-guide-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-top: 1.5rem;
}

.seo-guide-section h2 {
  font-size: 1.4rem;
  margin-bottom: 1rem;
}

.seo-guide-section h3 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.5rem;
}

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

.seo-guide-section ul, .seo-guide-section ol {
  color: var(--text-muted);
  font-size: 0.925rem;
  line-height: 1.6;
  margin-left: 1.25rem;
  margin-bottom: 1.25rem;
}

.seo-table-wrapper {
  overflow-x: auto;
  margin: 1.25rem 0;
}

.seo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.seo-table th, .seo-table td {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-color);
}

.seo-table th {
  background-color: var(--bg-card-subtle);
  color: var(--text-main);
  font-weight: 600;
}

/* Preguntas frecuentes */
.seo-faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

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

.seo-faq-question {
  padding: 1rem;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

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

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

/* Media Print */
@media print {
  .app-header, .tools-ad-banner-section, .tool-ad-sidebar,
  .fijate-footer, .method-tabs-container, .gender-selector-grid,
  .card-main:first-of-type, .action-buttons-row, .modal-overlay,
  .app-toast, .diff-history-box {
    display: none !important;
  }

  body, .tool-layout, .card-main {
    background: #ffffff !important;
    color: #000000 !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .status-badge {
    border: 1px solid #000000 !important;
    color: #000000 !important;
    background: transparent !important;
  }
}
