/**
 * Estilos canónicos para Calculadora de fianza de alquiler e intereses por demora (LAU art. 36)
 * Fijate Tools - Finanzas y Vivienda
 */

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

  /* Tema Oscuro Canónico (Midnight Slate) */
  --bg-body: #0b0f17;
  --bg-card: #111827;
  --bg-card-subtle: #162032;
  --bg-input: #1e293b;
  --bg-input-hover: #243247;
  --border-color: #27354a;
  --border-focus: #3b82f6;

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

  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-glow: rgba(59, 130, 246, 0.2);

  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.12);
  --color-success-border: rgba(16, 185, 129, 0.3);

  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.12);
  --color-danger-border: rgba(239, 68, 68, 0.35);

  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.12);
  --color-warning-border: rgba(245, 158, 11, 0.3);

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.5);
  --shadow-hover: 0 8px 30px -4px rgba(0, 0, 0, 0.6);

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

[data-theme="light"],
body.light-theme {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --bg-input-hover: #f8fafc;
  --border-color: #cbd5e1;
  --border-focus: #2563eb;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;

  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-glow: rgba(37, 99, 235, 0.15);

  --color-success: #059669;
  --color-success-bg: #ecfdf5;
  --color-success-border: #a7f3d0;

  --color-danger: #dc2626;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;

  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;

  --shadow-card: 0 4px 16px -2px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 8px 24px -4px rgba(15, 23, 42, 0.1);
}

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

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

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

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

/* Layout canónico */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

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

/* Cabecera de la herramienta */
.tool-hero-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.5rem;
}

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

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

.badge-primary {
  background: var(--color-primary-glow);
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
}

.badge-neutral {
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

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

@media (min-width: 768px) {
  .tool-hero-title {
    font-size: 2.15rem;
  }
}

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

/* Workspace de 2 columnas */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .workspace-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.15fr);
    align-items: start;
  }
}

/* Paneles y secciones */
.form-panel, .results-panel {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 0;
}

.section-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.section-box-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

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

/* Grupos de formulario y controles táctiles */
.form-group {
  margin-bottom: 1.1rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

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

.form-hint {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
  line-height: 1.4;
}

/* Inputs y Selects */
.input-control,
.select-control {
  width: 100%;
  height: 42px;
  min-height: 42px;
  padding: 0.5rem 0.85rem;
  font-family: var(--font-main);
  font-size: 0.95rem;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.input-control:hover,
.select-control:hover {
  background-color: var(--bg-input-hover);
}

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

/* Select canónico anti-desborde */
.select-control {
  max-width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  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='%2394a3b8' 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;
  padding-right: 40px;
}

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

/* Input con wrapper y sufijo */
.input-with-suffix {
  display: flex;
  align-items: stretch;
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-input);
  overflow: hidden;
}

.input-with-suffix .input-control {
  border: none;
  border-radius: 0;
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  background: transparent;
}

.input-with-suffix .input-suffix {
  display: inline-flex;
  align-items: center;
  padding: 0 0.85rem;
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  border-left: 1px solid var(--border-color);
  user-select: none;
}

/* Input tipo Date con color-scheme */
input[type="date"] {
  color-scheme: dark;
}

[data-theme="light"] input[type="date"],
body.light-theme input[type="date"] {
  color-scheme: light;
}

/* Botones rápidos / Presets */
.quick-presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.btn-preset {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 32px;
}

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

/* Semáforo de estado */
.status-card {
  border-radius: var(--radius-md);
  padding: 1.25rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  transition: all 0.25s ease;
}

.status-card.mora-activa {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  margin-bottom: 0.75rem;
}

.status-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background-color: currentColor;
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

.status-pill--danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger-border);
}

.status-pill--success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
}

.status-title {
  font-size: 1.25rem;
  margin-bottom: 0.4rem;
}

.status-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* Grid de Estadísticas / Cifras */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.stat-card--featured {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(37, 99, 235, 0.05) 100%);
  border-color: var(--color-primary);
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.35rem;
}

.stat-val {
  display: block;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
}

.stat-card--featured .stat-val {
  font-size: 1.85rem;
  color: var(--color-primary);
}

.stat-subtext {
  display: block;
  font-size: 0.76rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* Desglose de intereses día a día */
.desglose-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.desglose-title {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.interes-item-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.65rem 0;
  border-bottom: 1px dashed var(--border-color);
  font-size: 0.88rem;
}

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

.interes-item-header {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.interes-item-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.interes-item-val {
  color: var(--color-danger);
  font-family: var(--font-mono);
  font-weight: 700;
}

/* Tarjeta informativa CCAA */
.ccaa-card-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

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

.ccaa-card-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
  font-size: 1rem;
}

.ccaa-card-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.88rem;
}

.ccaa-detail-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.ccaa-detail-label {
  color: var(--text-muted);
}

.ccaa-detail-val {
  text-align: right;
  color: var(--text-main);
}

.ccaa-alert-box {
  margin-top: 0.65rem;
  padding: 0.65rem 0.85rem;
  background: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  border-radius: var(--radius-sm);
  color: var(--color-warning);
  font-size: 0.82rem;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  line-height: 1.45;
}

/* Tarjeta de sanción autonómica estimada */
.sancion-card {
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.sancion-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-danger);
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.sancion-rango-val {
  font-size: 1.45rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--color-danger);
  margin-bottom: 0.5rem;
}

.sancion-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* Generador de Burofax Formal */
.burofax-generator-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.burofax-fields-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

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

.burofax-preview-wrapper {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  max-height: 380px;
  overflow-y: auto;
}

.burofax-preview-text {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-main);
  margin: 0;
}

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

@media (min-width: 640px) {
  .action-buttons-row {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

.btn-action {
  height: 44px;
  min-height: 44px;
  padding: 0 1.25rem;
  font-family: var(--font-main);
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  border: none;
  flex: 1 1 auto;
}

.btn-action-primary {
  background-color: var(--color-primary);
  color: #ffffff;
}

.btn-action-primary:hover {
  background-color: var(--color-primary-hover);
  box-shadow: 0 4px 14px var(--color-primary-glow);
}

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

.btn-action-secondary:hover {
  background-color: var(--bg-input-hover);
  border-color: var(--text-muted);
}

/* Sección FAQ y marco legal educativo */
.faq-legal-section {
  margin-top: 2.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 2rem;
}

.faq-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

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

.faq-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.faq-card-title {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.faq-card-text {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

/* Modal Canónico (Lección 242 y 247) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

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

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

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

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

.modal-body p {
  margin: 0 0 0.5rem;
}

.modal-body p:last-child {
  margin-bottom: 0;
}

.modal-muted-tip {
  font-size: 0.82rem;
  color: var(--text-dim);
  background: var(--bg-card-subtle);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

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

.modal-btn-close {
  height: 40px;
  min-height: 40px;
  padding: 0 1.25rem;
  background: var(--color-primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Vista Imprimible Canónica (.print-sheet) (Lección 238) */
.print-sheet {
  display: none;
}

@media print {
  /* Ocultar interfaz interactiva y elementos no imprimibles */
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .app-header,
  .tools-ad-banner-section,
  .tool-ad-sidebar,
  .card-main,
  .fijate-footer,
  .modal-overlay {
    display: none !important;
  }

  .tool-layout {
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
  }

  .print-sheet {
    display: block !important;
    padding: 20mm 15mm;
    font-family: 'Times New Roman', Times, serif;
    font-size: 12pt;
    line-height: 1.5;
    color: #000000;
  }

  .print-doc-header {
    border-bottom: 2px solid #000000;
    padding-bottom: 10px;
    margin-bottom: 20px;
  }

  .print-doc-header h2 {
    font-size: 16pt;
    margin: 0 0 5px;
    color: #000000;
  }

  .print-doc-header p {
    font-size: 10pt;
    margin: 0;
    color: #555555;
  }
}
