/* Estilos específicos para la Calculadora de actualización de alquiler con IPC (INE) */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.1);
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --card-bg: #1e293b;
  --card-border: #334155;
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  --input-bg: #0f172a;
  --input-border: #475569;
  --input-focus: #3b82f6;
  --badge-bg: #334155;
  --surface-hover: #2d3d54;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --shadow-main: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
}

[data-theme="light"] {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.08);
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #475569;
  --input-bg: #f8fafc;
  --input-border: #cbd5e1;
  --input-focus: #2563eb;
  --badge-bg: #f1f5f9;
  --surface-hover: #f1f5f9;
  --shadow-main: 0 10px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-body, #0b1120);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
}

.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 16px 60px;
  width: 100%;
}

/* Encabezado de la herramienta */
.tool-header-block {
  text-align: center;
  margin-bottom: 32px;
}

.badge-official {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
}

[data-theme="light"] .badge-official {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.tool-title {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-bottom: 8px;
}

.tool-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 760px;
  margin: 0 auto;
}

/* Grid principal con minmax(0, 1fr) estricto */
.calculator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 24px;
  margin-bottom: 24px;
  width: 100%;
}

@media (max-width: 900px) {
  .calculator-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Tarjetas */
.app-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-main);
  min-width: 0;
  width: 100%;
}

.card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  color: var(--text-main);
}

.card-title svg {
  color: var(--primary-color);
  flex-shrink: 0;
}

/* Formularios y controles */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.input-unit-wrapper {
  display: flex;
  align-items: center;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-unit-wrapper:focus-within {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.input-unit-wrapper input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.05rem;
  font-family: inherit;
  outline: none;
}

.input-unit-wrapper .unit-tag {
  padding: 0 14px;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.1);
  height: 44px;
  display: flex;
  align-items: center;
  border-left: 1px solid var(--input-border);
  user-select: none;
  flex-shrink: 0;
}

/* Selectores responsivos */
.select-custom {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  background-color: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  display: block;
}

.select-custom:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.grid-2-cols {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 500px) {
  .grid-2-cols {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Opciones de método de cálculo */
.method-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 20px;
  background: var(--input-bg);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--input-border);
}

@media (max-width: 600px) {
  .method-tabs {
    grid-template-columns: minmax(0, 1fr);
  }
}

.method-btn {
  background: transparent;
  border: none;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.method-btn.active {
  background: var(--primary-color);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Botón de acción principal */
.btn-action-primary {
  width: 100%;
  height: 48px;
  background: var(--primary-color);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
  transition: background 0.2s ease, transform 0.1s ease;
}

.btn-action-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* Tarjeta de Resultados */
.result-hero {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15), rgba(16, 185, 129, 0.1));
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  margin-bottom: 20px;
}

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

.result-rent-big {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.8rem, 3.5vw, 2.4rem);
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
  margin-bottom: 6px;
  word-break: break-word;
}

.result-difference-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
}

.tag-increase {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.tag-neutral {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
}

/* Desglose en 3 métricas */
.breakdown-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
  width: 100%;
}

@media (max-width: 600px) {
  .breakdown-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

.metric-box {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 12px 8px;
  text-align: center;
  min-width: 0;
  overflow: hidden;
}

.metric-title {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(0.95rem, 2vw, 1.1rem);
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Alerta informativa legal */
.legal-notice {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.legal-notice svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.btn-group-actions {
  display: flex;
  gap: 10px;
}

.btn-secondary {
  flex: 1;
  height: 44px;
  background: var(--surface-hover);
  color: var(--text-main);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s ease;
}

.btn-secondary:hover {
  background: var(--card-border);
}

/* Gráfico de evolución */
.chart-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 250px;
  overflow: hidden;
}

.chart-container canvas {
  width: 100% !important;
  max-width: 100% !important;
  height: 240px !important;
  display: block;
}

/* Sección de carta oficial */
.letter-box {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 20px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-main);
  max-height: 380px;
  overflow-y: auto;
}

/* Modales */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  padding: 24px;
  box-shadow: var(--shadow-main);
  transform: translateY(20px);
  transition: transform 0.2s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.active .modal-container {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

/* Acordeón FAQ */
.faq-section {
  margin-top: 0;
}

.faq-item {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
}

.faq-question {
  width: 100%;
  padding: 16px 20px;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-answer {
  padding: 0 20px 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  display: none;
}

.faq-item.open .faq-answer {
  display: block;
}

.faq-item.open .faq-question svg {
  transform: rotate(180deg);
}
