/**
 * Estilos canónicos: Calculadora de desistimiento del contrato de alquiler e indemnización (LAU)
 * fijate.com/tools/calculadora-desistimiento-alquiler-lau
 */

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

  /* Paleta institucional modo claro */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-card-highlight: #eff6ff;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --accent-primary: #0284c7;
  --accent-primary-hover: #0369a1;
  --accent-secondary: #0ea5e9;

  --color-green: #16a34a;
  --color-green-bg: #dcfce7;
  --color-green-border: #86efac;

  --color-red: #dc2626;
  --color-red-bg: #fee2e2;
  --color-red-border: #fca5a5;

  --color-amber: #d97706;
  --color-amber-bg: #fef3c7;
  --color-amber-border: #fcd34d;

  --color-purple: #7c3aed;
  --color-purple-bg: #ede9fe;
  --color-purple-border: #c4b5fd;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="dark"] {
  --bg-page: #0b0f17;
  --bg-card: #131b26;
  --bg-card-subtle: #1a2434;
  --bg-card-highlight: #18283f;
  --border-color: #233148;
  --border-focus: #38bdf8;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-light: #64748b;

  --accent-primary: #38bdf8;
  --accent-primary-hover: #7dd3fc;
  --accent-secondary: #0284c7;

  --color-green: #4ade80;
  --color-green-bg: rgba(34, 197, 94, 0.15);
  --color-green-border: rgba(34, 197, 94, 0.35);

  --color-red: #f87171;
  --color-red-bg: rgba(239, 68, 68, 0.15);
  --color-red-border: rgba(239, 68, 68, 0.35);

  --color-amber: #fbbf24;
  --color-amber-bg: rgba(245, 158, 11, 0.15);
  --color-amber-border: rgba(245, 158, 11, 0.35);

  --color-purple: #c084fc;
  --color-purple-bg: rgba(168, 85, 247, 0.15);
  --color-purple-border: rgba(168, 85, 247, 0.35);

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

/* Reset y base institucional */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Layout institucional y sidebar AdSense */
.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%;
}

/* Header de la herramienta */
.tool-intro-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.tool-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: none;
}

.badge-tag-blue {
  background: var(--bg-card-highlight);
  color: var(--accent-primary);
  border: 1px solid var(--border-color);
}

.badge-tag-legal {
  background: var(--color-purple-bg);
  color: var(--color-purple);
  border: 1px solid var(--color-purple-border);
}

.tool-intro-title {
  font-size: 1.65rem;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

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

/* Banner de estado semafórico */
.status-banner {
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem;
  margin-bottom: 1.5rem;
  border: 1px solid transparent;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: all 0.2s ease;
}

.status-banner.status-optimal {
  background: var(--color-green-bg);
  border-color: var(--color-green-border);
  color: var(--color-green);
}

.status-banner.status-warning_notice {
  background: var(--color-amber-bg);
  border-color: var(--color-amber-border);
  color: var(--color-amber);
}

.status-banner.status-warning_early {
  background: var(--color-red-bg);
  border-color: var(--color-red-border);
  color: var(--color-red);
}

.status-banner.status-abusive {
  background: var(--color-purple-bg);
  border-color: var(--color-purple-border);
  color: var(--color-purple);
}

.status-icon-box {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-content {
  flex: 1;
}

.status-header-line {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.25rem;
}

.status-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  color: inherit;
}

.status-desc {
  font-size: 0.88rem;
  margin: 0;
  color: var(--text-main);
  opacity: 0.9;
}

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

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

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: none;
}

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

.kpi-sub-tag {
  display: block;
  font-family: var(--font-main);
  font-size: 0.72rem;
  font-weight: 500;
  margin-top: 0.35rem;
  color: var(--text-muted);
}

.green-text {
  color: var(--color-green) !important;
}

.warn-text {
  color: var(--color-amber) !important;
}

.text-green {
  color: var(--color-green) !important;
}

.text-red {
  color: var(--color-red) !important;
}

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

.text-bold {
  font-weight: 700;
}

.text-right {
  text-align: right;
}

/* Escudo frente a cláusulas abusivas */
.abusive-shield-box {
  background: var(--color-purple-bg);
  border: 1.5px solid var(--color-purple-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.shield-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.shield-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-purple);
  margin: 0;
}

.shield-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin: 1rem 0;
  background: var(--bg-card);
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.shield-metric-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

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

.shield-savings {
  color: var(--color-green);
}

.shield-demanded {
  color: var(--color-red);
}

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

.shield-explanation {
  font-size: 0.86rem;
  color: var(--text-main);
  line-height: 1.55;
  margin: 0;
}

/* Formulario principal y secciones */
.form-section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.section-heading-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.section-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.section-title {
  font-size: 1.15rem;
  margin: 0;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.15rem;
  margin-bottom: 1rem;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.15rem;
  margin-bottom: 1rem;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.15rem;
  margin-bottom: 1rem;
}

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

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.form-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Inputs, selects y controles táctiles */
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-main);
  font-size: 0.92rem;
  min-height: 42px;
  padding: 0.55rem 0.85rem;
  background-color: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="date"] {
  font-family: var(--font-mono);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 40px;
  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%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

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

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

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

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

/* Cronograma / Timeline interactivo */
.timeline-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
}

.timeline-title {
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.timeline-flow {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  position: relative;
}

.timeline-step {
  display: flex;
  flex-direction: column;
  position: relative;
  padding-top: 1.5rem;
}

.timeline-step::before {
  content: '';
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border-color);
  z-index: 1;
}

.timeline-step:first-child::before {
  left: 50%;
}

.timeline-step:last-child::before {
  right: 50%;
}

.timeline-dot {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent-primary);
  border: 3px solid var(--bg-card);
  z-index: 2;
}

.timeline-dot.dot-green {
  background: var(--color-green);
}

.timeline-dot.dot-amber {
  background: var(--color-amber);
}

.timeline-dot.dot-blue {
  background: var(--accent-primary);
}

.timeline-step-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 0.25rem;
}

.timeline-step-date {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-main);
}

.badge-mini {
  display: block;
  font-family: var(--font-main);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  margin-top: 0.25rem;
}

.badge-green {
  background: var(--color-green-bg);
  color: var(--color-green);
}

.badge-red {
  background: var(--color-red-bg);
  color: var(--color-red);
}

.badge-blue {
  background: var(--bg-card-highlight);
  color: var(--accent-primary);
}

/* Tabla de liquidación */
.table-responsive-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

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

.breakdown-table th {
  background: var(--bg-card-subtle);
  font-weight: 600;
  text-align: left;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.breakdown-table tr.row-header td {
  background: var(--bg-card-subtle);
  font-weight: 700;
  color: var(--accent-primary);
  font-size: 0.82rem;
  text-transform: none;
}

.breakdown-table tfoot td {
  border-top: 2px solid var(--border-color);
  border-bottom: none;
  font-weight: 600;
  background: var(--bg-card-subtle);
}

/* Generador de documentos */
.doc-generator-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.doc-tabs-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.tab-btn {
  padding: 0.65rem 1.15rem;
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 40px;
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-subtle);
}

.tab-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
}

.doc-preview-textarea {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  width: 100%;
  min-height: 380px;
  padding: 1rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  resize: vertical;
  white-space: pre-wrap;
  word-break: break-word;
}

.doc-actions-row {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1rem;
  flex-wrap: wrap;
}

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

.btn-primary {
  background: var(--accent-primary);
  color: #ffffff;
  border: 1px solid transparent;
}

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

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

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

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

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

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

.seo-guide-section p {
  color: var(--text-main);
  line-height: 1.7;
  margin-bottom: 1rem;
}

.seo-guide-section ul,
.seo-guide-section ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.seo-guide-section li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.legal-callout {
  background: var(--bg-card-subtle);
  border-left: 4px solid var(--accent-primary);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 1.25rem 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* Modales accesibles (sustituto obligatorio de window.alert) */
.app-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.app-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.app-modal.active .modal-dialog {
  transform: translateY(0);
}

.modal-title {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
}

/* Reglas responsivas */
@media (max-width: 992px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .timeline-flow {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .timeline-step {
    padding-top: 0;
    padding-left: 2rem;
  }

  .timeline-step::before {
    top: 0;
    bottom: 0;
    left: 7px;
    width: 3px;
    height: 100%;
    right: auto;
  }

  .timeline-step:first-child::before {
    top: 7px;
    left: 7px;
  }

  .timeline-step:last-child::before {
    height: 7px;
  }

  .timeline-dot {
    top: 7px;
    left: 0;
    transform: none;
  }

  .timeline-step-label,
  .timeline-step-date {
    text-align: left;
  }

  .shield-metrics {
    grid-template-columns: 1fr;
  }

  .form-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .form-grid-2,
  .form-grid-3,
  .form-grid-4 {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .doc-actions-row {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
  }

  .tab-btn {
    flex: 1;
    text-align: center;
    padding: 0.6rem 0.5rem;
    font-size: 0.8rem;
  }
}

/* Reglas de impresión */
@media print {
  .app-header,
  .fijate-footer,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .tool-intro-card,
  .status-banner,
  .kpi-grid,
  .abusive-shield-box,
  .form-section-card,
  .timeline-card,
  .doc-tabs-row,
  .doc-actions-row,
  .seo-guide-section,
  .tools-affiliate-section,
  .related-tools-section {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .tool-layout,
  .tool-with-sidebar,
  .tool-main-content,
  .doc-generator-card {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    border: none !important;
    box-shadow: none !important;
  }

  .doc-preview-textarea {
    border: none !important;
    background: transparent !important;
    color: #000000 !important;
    font-size: 11pt !important;
    line-height: 1.5 !important;
    height: auto !important;
    min-height: 100% !important;
  }
}

