/**
 * Estilos canónicos para la Calculadora de Revalorización de Alquileres Antiguos (LAU 1964)
 * Fijate Tools
 */

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

  /* Paleta base clara */
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-card-hover: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #475569;
  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;

  /* Acentos jurídicos elegantes (Azul zafiro / Índigo y Ámbar cálido) */
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --primary-subtle: #eff6ff;
  --accent-gold: #b45309;
  --accent-gold-subtle: #fffbeb;
  --accent-teal: #0f766e;
  --accent-teal-subtle: #f0fdf4;
  --danger: #b91c1c;

  /* KPIs */
  --kpi-bg: #f8fafc;
  --kpi-border: #e2e8f0;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
}

[data-theme="dark"] {
  --bg-primary: #0b0f17;
  --bg-card: #131b26;
  --bg-card-subtle: #1a2433;
  --bg-card-hover: #222f42;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #243042;
  --border-hover: #334155;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-subtle: rgba(59, 130, 246, 0.12);
  --accent-gold: #f59e0b;
  --accent-gold-subtle: rgba(245, 158, 11, 0.12);
  --accent-teal: #14b8a6;
  --accent-teal-subtle: rgba(20, 184, 166, 0.12);
  --danger: #ef4444;

  --kpi-bg: #16202e;
  --kpi-border: #243042;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  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,
.hero-title,
.section-title,
.card-header-title {
  font-family: var(--font-heading);
}

.font-mono,
.kpi-value,
code {
  font-family: var(--font-mono);
}

.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 1536px) {
  .tool-with-sidebar {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
}

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

/* Hero informativo */
.hero-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.hero-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.hero-badge-gold {
  background: var(--accent-gold-subtle);
  color: var(--accent-gold);
  border-color: rgba(245, 158, 11, 0.25);
}

.hero-badge-teal {
  background: var(--accent-teal-subtle);
  color: var(--accent-teal);
  border-color: rgba(20, 184, 166, 0.25);
}

.hero-title {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.hero-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Presets rápidos */
.presets-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.presets-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.presets-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.btn-preset {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  transition: all 0.15s ease;
  min-height: 40px;
}

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

/* Pestañas de navegación de la herramienta */
.tool-nav-tabs {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.tool-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  transition: all 0.15s ease;
  min-height: 42px;
}

.tool-tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tool-tab-btn.is-active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--primary-subtle);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

/* Paneles de pestañas */
.tool-tab-pane {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

.tool-tab-pane.is-active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tarjetas de formulario y configuración */
.card-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card-section-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.card-header-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-header-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* Rejilla de campos */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

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

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

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

.form-hint {
  font-size: 0.775rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Controles de input y select */
.input-control,
.select-control {
  width: 100%;
  min-height: 42px;
  padding: 0.6rem 0.85rem;
  font-family: var(--font-main);
  font-size: 0.925rem;
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

/* Desplegable select con contención estricta */
.select-control {
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  padding-right: 40px;
  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='%23475569' stroke-width='2.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 12px center;
  background-size: 16px;
}

[data-theme="dark"] .select-control {
  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='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

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

/* Flexbox wrapper para inputs con sufijo / prefijo */
.input-with-suffix {
  display: flex;
  align-items: center;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.input-with-suffix:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.input-with-suffix .input-control {
  border: none;
  box-shadow: none;
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
}

.input-suffix {
  padding: 0 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg-card-subtle);
  border-left: 1px solid var(--border-color);
  height: 42px;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

/* Radio buttons compactos */
.radio-pills-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.radio-pill-label {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
  transition: all 0.15s ease;
}

.radio-pill-label input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-pill-label:has(input[type="radio"]:checked) {
  border-color: var(--primary);
  background: var(--primary-subtle);
  color: var(--primary);
}

/* Checkbox toggle llamativo */
.checkbox-toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  min-height: 48px;
}

.checkbox-toggle-card input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: var(--primary);
}

.toggle-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  display: block;
}

.toggle-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
}

/* Panel de KPIs y Resultados */
.kpis-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

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

@media (min-width: 1024px) {
  .kpis-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.kpi-card {
  background: var(--kpi-bg);
  border: 1px solid var(--kpi-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi-card-total {
  background: var(--primary-subtle);
  border-color: rgba(59, 130, 246, 0.3);
}

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

.kpi-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-card-total .kpi-value {
  color: var(--primary);
  font-size: 1.85rem;
}

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

/* Badges de estado */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-badge-info {
  background: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.status-badge-warning {
  background: var(--accent-gold-subtle);
  color: var(--accent-gold);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-pct {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

/* Tablas responsivas */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

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

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

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

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

.lau-table tr.row-selected {
  background: var(--primary-subtle);
}

.text-accent {
  color: var(--primary);
}

/* Desglose de recibo mensual */
.receipt-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.receipt-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px dashed var(--border-color);
  gap: 1rem;
}

.receipt-item:last-child {
  border-bottom: none;
}

.receipt-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.receipt-item-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.receipt-item-subtitle {
  font-size: 0.775rem;
  color: var(--text-muted);
}

.receipt-item-val {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.receipt-item-total {
  padding-top: 1rem;
  border-top: 2px solid var(--border-color);
}

.receipt-item-total .receipt-item-title {
  font-size: 1.1rem;
}

.receipt-item-total .receipt-item-val {
  font-size: 1.4rem;
}

/* Preaviso Burofax */
.burofax-textarea {
  width: 100%;
  min-height: 380px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  background-color: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  resize: vertical;
}

.burofax-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-family: var(--font-main);
  font-size: 0.925rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 42px;
  transition: background 0.15s ease;
}

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

.btn-secondary {
  background: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  font-family: var(--font-main);
  font-size: 0.925rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 42px;
  transition: all 0.15s ease;
}

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

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

.fijate-modal-backdrop.is-active {
  display: flex;
}

.fijate-modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-body-text {
  font-size: 0.925rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Sección de Preguntas Frecuentes (SEO) */
.faq-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

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

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

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

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

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

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

/* @media print: Salida formal A4 para el requerimiento fehaciente */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .app-header,
  .fijate-footer,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .hero-box,
  .presets-card,
  .tool-nav-tabs,
  .card-section,
  .actions-row,
  .faq-section,
  .related-tools-section,
  #fijate-app-modal {
    display: none !important;
  }
  .tool-layout,
  .tool-with-sidebar,
  .tool-main-content {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    display: block !important;
  }
  #tab-burofax {
    display: block !important;
  }
  .card-section:has(#burofax-preview-text) {
    display: block !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .card-section-header {
    display: none !important;
  }
  .burofax-textarea {
    border: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 10.5pt !important;
    line-height: 1.5 !important;
    padding: 0 !important;
    min-height: auto !important;
    height: auto !important;
    overflow: visible !important;
  }
}
