/* ==========================================================================
   Calculadora de viabilidad de apertura por aforo y esfuerzo de alquiler
   Fijate Tools - Estilos corporativos y responsive
   ========================================================================== */

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

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --border-color: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;

  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #0284c7;
  --info-bg: #f0f9ff;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

[data-theme="dark"] {
  --bg-page: #0b0f17;
  --bg-card: #131b26;
  --bg-card-subtle: #1a2434;
  --border-color: #243144;
  --border-focus: #60a5fa;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-light: #1e293b;

  --success: #22c55e;
  --success-bg: #052e16;
  --warning: #f59e0b;
  --warning-bg: #451a03;
  --danger: #ef4444;
  --danger-bg: #450a0a;
  --info: #38bdf8;
  --info-bg: #082f49;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  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;
}

/* Contención canónica */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
}

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
  margin-top: 0;
}

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

.hero-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.hero-badge-primary {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(37, 99, 235, 0.25);
}

.hero-title {
  font-size: 1.75rem;
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.hero-desc {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 75ch;
  margin-bottom: 1.5rem;
}

/* Presets rápidos */
.presets-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border-color);
}

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

.btn-preset {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 36px;
}

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

/* Grid del simulador */
.simulator-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-bottom: 2.5rem;
}

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

/* Tarjetas de formulario */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.form-card-title {
  font-size: 1.2rem;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-card-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}

.fields-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.1rem;
}

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

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

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

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.input-with-symbol {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
}

.input-with-symbol input {
  padding-right: 2.5rem;
}

.input-symbol {
  position: absolute;
  right: 0.85rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  pointer-events: none;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  height: 42px;
  min-height: 40px;
  padding: 0 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

select {
  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;
  padding-right: 2.5rem;
}

.slider-container {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.slider-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
}

input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 9999px;
  background: var(--border-color);
  outline: none;
  cursor: pointer;
  accent-color: var(--primary);
}

/* Columna de Resultados y KPIs */
.results-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Tarjeta Principal de Aforo */
.kpi-main-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.kpi-main-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, #10b981, var(--primary));
}

.kpi-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.kpi-big-value {
  font-family: var(--font-heading);
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
  margin-bottom: 0.4rem;
}

.kpi-subtext {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Grid de Escenarios */
.escenarios-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.escenario-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
}

.escenario-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}

.escenario-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
}

.kpi-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(22, 163, 74, 0.2);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(217, 119, 6, 0.2);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.escenario-metric-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.escenario-metric-row strong {
  color: var(--text-main);
}

/* Acciones */
.actions-row {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

@media (min-width: 480px) {
  .actions-row {
    flex-direction: row;
  }
}

.btn-primary {
  flex: 1;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background-color 0.2s ease;
}

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

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

/* Guía didáctica y SEO */
.seo-guide-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  margin-top: 3rem;
  box-shadow: var(--shadow-sm);
}

.seo-guide-section h2 {
  font-size: 1.6rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.seo-guide-section h3 {
  font-size: 1.2rem;
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
}

.seo-guide-section p, 
.seo-guide-section li {
  color: var(--text-muted);
  line-height: 1.65;
  font-size: 0.95rem;
}

.formula-card {
  background: var(--bg-card-subtle);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1.25rem 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-main);
}

/* Acordeón FAQ */
.faq-details {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  background: var(--bg-card-subtle);
}

.faq-summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-heading);
}

.faq-content {
  padding: 0 1.25rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.925rem;
  line-height: 1.55;
}

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

.modal-overlay[hidden] {
  display: none !important;
}

.modal-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 740px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

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

.modal-title {
  margin: 0;
  font-size: 1.2rem;
}

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

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Plantilla informe */
.informe-printable {
  font-family: var(--font-main);
  color: #0f172a;
}

.informe-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
}

.informe-header h2 {
  font-size: 1.35rem;
  color: #0f172a;
  margin: 0 0 0.25rem;
}

.informe-meta {
  font-size: 0.8rem;
  color: #64748b;
  margin: 0;
}

.informe-dictamen-tag {
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
}

.dictamen-bajo { background: #dcfce7; color: #166534; }
.dictamen-medio { background: #fef3c7; color: #92400e; }
.dictamen-alto { background: #fee2e2; color: #991b1b; }

.informe-sec-title {
  font-size: 1.05rem;
  color: #0f172a;
  margin-top: 1.25rem;
  margin-bottom: 0.6rem;
  border-left: 3px solid #2563eb;
  padding-left: 0.5rem;
}

.informe-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.informe-table th,
.informe-table td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
}

.row-highlight {
  background: #f8fafc;
  font-weight: 600;
}

.informe-nota {
  font-size: 0.78rem;
  color: #64748b;
  margin: 0.4rem 0 1rem;
  line-height: 1.45;
}

.informe-footer-firma {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #cbd5e1;
  font-size: 0.725rem;
  color: #64748b;
  line-height: 1.4;
}

@media print {
  body * {
    visibility: hidden;
  }
  .modal-overlay,
  .modal-container,
  .modal-body,
  .informe-printable,
  .informe-printable * {
    visibility: visible;
  }
  .modal-overlay {
    position: absolute;
    inset: 0;
    background: transparent;
    padding: 0;
  }
  .modal-container {
    border: none;
    box-shadow: none;
    max-width: 100%;
    width: 100%;
    height: auto;
  }
  .modal-header,
  .modal-footer,
  .app-header,
  .fijate-footer,
  .tools-ad-banner-section,
  .tool-ad-sidebar {
    display: none !important;
  }
}
