/* Modal overlay + interactive modules (top, compare, calculator, wizard, news,
   history, favorites, subscribe). */

body.modal-open { overflow: hidden; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 30, 60, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modal-in 0.18s ease-out;
}
@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: #fff;
  border-radius: 24px;
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  padding: 36px 32px 28px;
  box-shadow: 0 30px 80px rgba(0, 30, 60, 0.35);
  animation: modal-zoom 0.18s ease-out;
}
@keyframes modal-zoom {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0)   scale(1);    opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(0, 30, 60, 0.06);
  color: var(--navy, #003D6A);
  border-radius: 50%;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  transition: background .15s;
}
.modal-close:hover { background: rgba(0, 30, 60, 0.12); }

.modal-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--navy, #003D6A);
  margin: 0 0 8px;
  line-height: 1.25;
}
.modal-desc { color: var(--text-muted, #5A6E8A); font-size: 14px; margin: 0 0 18px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted, #5A6E8A);
}
.form-grid label > span { font-weight: 600; color: var(--text, #1B2A4A); }
.form-grid input,
.form-grid select,
.form-grid textarea,
.calc-form input,
.calc-form select {
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(0, 61, 106, 0.2));
  font-family: inherit;
  font-size: 14px;
  background: #fafbf8;
  color: var(--text, #1B2A4A);
  outline: none;
  transition: border-color .15s, background .15s;
}
.form-grid input:focus,
.form-grid select:focus,
.calc-form input:focus,
.calc-form select:focus {
  border-color: var(--cyan, #00A1CA);
  background: #fff;
}
.form-grid input.invalid { border-color: #dc2626; }

.form-grid button[type="submit"],
.btn-primary {
  grid-column: 1 / -1;
  background: var(--cyan, #00A1CA);
  color: #fff;
  border: none;
  border-radius: 100px;
  padding: 13px 28px;
  font-weight: 600;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, transform .15s, box-shadow .15s;
}
.form-grid button[type="submit"]:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
  background: var(--navy, #003D6A);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 161, 202, 0.35);
}
.form-grid button[type="submit"]:disabled,
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-secondary {
  background: transparent;
  color: var(--navy, #003D6A);
  border: 1px solid var(--border, rgba(0, 61, 106, 0.25));
  border-radius: 100px;
  padding: 12px 24px;
  font-weight: 600;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-secondary:hover { background: rgba(0, 161, 202, 0.08); border-color: var(--cyan, #00A1CA); }

.btn-link {
  background: transparent;
  border: none;
  color: var(--cyan, #00A1CA);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
}
.btn-link:hover { color: var(--navy, #003D6A); text-decoration: underline; }

/* ─── Modal answer / loader / errors ─── */

.modal-result { margin-top: 16px; }
.modal-loader {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted, #5A6E8A);
  font-size: 14px;
  padding: 16px 0;
}
.modal-error {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 14px;
}
.modal-success {
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  color: #065f46;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
}
.modal-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted, #5A6E8A);
  font-size: 14px;
}

.modal-answer {
  background: #f8faf5;
  border: 1px solid var(--border, rgba(0, 61, 106, 0.12));
  border-radius: 16px;
  padding: 22px 24px;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text, #1B2A4A);
}
.modal-answer-meta { font-size: 12px; color: var(--text-muted, #5A6E8A); margin-bottom: 12px; }
.modal-answer-body p { margin: 0 0 10px 0; }
.modal-answer-body strong { color: var(--navy, #003D6A); }
.modal-answer-body a { color: var(--cyan, #00A1CA); }
.modal-answer-body ul, .modal-answer-body ol { margin: 6px 0 10px 22px; }
.modal-answer-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border, rgba(0, 61, 106, 0.18));
  font-size: 12px;
  color: var(--text-muted, #5A6E8A);
}

.modal-head-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 8px;
  /* Reserve space for the × close button (top-right of .modal-box). */
  padding-right: 52px;
  flex-wrap: wrap;
}
.modal-head-row .modal-title { flex: 1 1 auto; min-width: 0; }
@media (max-width: 480px) {
  .modal-head-row { padding-right: 44px; }
}

/* ─── Calculator inline (page section) ─── */

.calc-form {
  background: #fff;
  border: 1px solid var(--border, rgba(0, 61, 106, 0.12));
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.calc-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.calc-row label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text, #1B2A4A);
}
.calc-result {
  margin-top: 18px;
  background: var(--bg, #F3F5EF);
  border-radius: 16px;
  padding: 20px 22px;
  display: flex; flex-direction: column; gap: 10px;
}
.calc-result-row,
.calc-result-total {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
}
.calc-result-total {
  border-top: 1px solid var(--border, rgba(0, 61, 106, 0.12));
  padding-top: 12px;
  font-size: 16px;
}
.calc-result-label { color: var(--text-muted, #5A6E8A); font-size: 13px; }
.calc-result-value { color: var(--navy, #003D6A); font-weight: 600; font-size: 15px; }
.calc-result-total .calc-result-value { font-size: 18px; }
.calc-result-disclaimer { font-size: 12px; color: var(--text-muted, #5A6E8A); margin-top: 8px; }

.calc-cta {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border, rgba(0, 61, 106, 0.12));
}
.calc-cta-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--navy, #003D6A);
  margin: 0 0 6px;
}
.calc-cta-desc {
  font-size: 13.5px;
  color: var(--text-muted, #5A6E8A);
  margin: 0 0 14px;
}
.calc-cta-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.calc-cta-actions .btn-primary,
.calc-cta-actions .btn-secondary {
  flex: 1 1 auto;
  min-width: 200px;
  padding: 12px 22px;
  font-size: 14px;
}
@media (max-width: 480px) {
  .calc-cta-actions .btn-primary,
  .calc-cta-actions .btn-secondary { min-width: 0; width: 100%; }
}

/* ─── Wizard ─── */

.wizard-progress {
  display: flex; gap: 6px;
  margin: 4px 0 22px;
}
.wizard-dot {
  flex: 1;
  height: 6px;
  border-radius: 100px;
  background: var(--border, rgba(0, 61, 106, 0.18));
  transition: background .2s;
}
.wizard-dot.done    { background: var(--cyan, #00A1CA); }
.wizard-dot.current { background: var(--navy, #003D6A); }

.wizard-q {
  font-size: 16px;
  color: var(--navy, #003D6A);
  font-weight: 700;
  margin: 0 0 16px;
}

.wizard-options {
  display: flex; flex-direction: column; gap: 10px;
}
.wizard-option {
  text-align: left;
  background: #fafbf8;
  border: 1px solid var(--border, rgba(0, 61, 106, 0.18));
  border-radius: 14px;
  padding: 14px 18px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .12s;
}
.wizard-option:hover { border-color: var(--cyan, #00A1CA); background: #fff; transform: translateX(2px); }

.wizard-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(0, 61, 106, 0.18));
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 12px;
}
.wizard-input.invalid { border-color: #dc2626; }

.wizard-custom-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-top: 10px;
}
.wizard-custom-row .wizard-input {
  flex: 1 1 auto;
  margin: 0;
}
.wizard-custom-row .btn-primary {
  flex: 0 0 auto;
  padding: 0 22px;
  font-size: 14px;
  min-width: 120px;
}
@media (max-width: 480px) {
  .wizard-custom-row { flex-direction: column; }
  .wizard-custom-row .btn-primary { width: 100%; padding: 12px 22px; }
}

/* ─── Result actions row (Save / Start over) for module modals ─── */

.module-result-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border, rgba(0, 61, 106, 0.12));
  flex-wrap: wrap;
}
.module-result-actions .btn-link {
  font-size: 13px;
  padding: 8px 14px;
}
.module-result-actions .btn-secondary,
.module-result-actions .btn-primary {
  padding: 10px 20px;
  font-size: 13.5px;
  min-width: 0;
  flex: 0 0 auto;
  grid-column: auto;
}

/* ─── Progress / running-state for in-modal background tasks ─── */

.module-progress {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 0;
}
.module-progress-line {
  height: 4px;
  background: var(--border, rgba(0, 61, 106, 0.15));
  border-radius: 100px;
  overflow: hidden;
  position: relative;
}
.module-progress-line::before {
  content: '';
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--cyan, #00A1CA), transparent);
  border-radius: 100px;
  animation: progress-slide 1.6s ease-in-out infinite;
}
@keyframes progress-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
.module-progress-label {
  font-size: 13px;
  color: var(--text-muted, #5A6E8A);
  text-align: center;
}
.module-progress-hint {
  font-size: 12px;
  color: var(--text-muted, #5A6E8A);
  text-align: center;
  font-style: italic;
}

.wizard-actions {
  display: flex; gap: 10px;
  margin-top: 16px;
}

/* ─── History / Favorites lists ─── */

.history-list, .fav-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }

.history-item, .fav-item {
  background: #f8faf5;
  border: 1px solid var(--border, rgba(0, 61, 106, 0.12));
  border-radius: 14px;
  padding: 12px 16px;
  transition: border-color .15s;
}
.history-item.open, .fav-item.open { border-color: var(--cyan, #00A1CA); }

.history-item-head {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  font-size: 13px;
}
.history-kind { color: var(--text-muted, #5A6E8A); font-size: 12px; flex-shrink: 0; }
.history-q    { color: var(--text, #1B2A4A); flex: 1; font-weight: 500; }
.history-date { color: var(--text-muted, #5A6E8A); font-size: 12px; flex-shrink: 0; }

.history-item-body, .fav-body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border, rgba(0, 61, 106, 0.18));
  font-size: 13.5px;
  line-height: 1.6;
}
.history-item-answer { margin-bottom: 12px; }
.history-item-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.history-item-actions .btn-secondary {
  padding: 6px 14px;
  font-size: 12.5px;
}

.fav-head { display: flex; align-items: center; gap: 12px; }
.fav-q { flex: 1; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text, #1B2A4A); }
.fav-remove {
  background: transparent;
  border: none;
  color: var(--text-muted, #5A6E8A);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  width: 28px; height: 28px;
  border-radius: 50%;
}
.fav-remove:hover { background: #fee2e2; color: #dc2626; }

/* ─── Feedback modal ─── */

.modal-feedback textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(0, 61, 106, 0.2));
  font-family: inherit;
  font-size: 14px;
  background: #fafbf8;
  color: var(--text, #1B2A4A);
  outline: none;
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
  transition: border-color .15s, background .15s;
}
.modal-feedback textarea:focus {
  border-color: var(--cyan, #00A1CA);
  background: #fff;
}

.feedback-context-card {
  background: #fff4e6;
  border: 1px solid #fdba74;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 12.5px;
  color: #9a3412;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}
.feedback-context-label {
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #c2410c;
}
.feedback-context-card code {
  background: rgba(255,255,255,0.6);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  word-break: break-word;
}

.feedback-foot {
  font-size: 11.5px;
  color: var(--text-muted, #5A6E8A);
  margin-top: 12px;
  text-align: center;
}

@media (max-width: 640px) {
  .modal-overlay { padding: 0; }
  .modal-box { max-height: 100vh; border-radius: 0; padding: 60px 18px 24px; max-width: none; }
  .form-grid { grid-template-columns: 1fr; }
  .calc-row { grid-template-columns: 1fr; }
  .modal-title { font-size: 18px; }
}
