/* ─── Container and Typography ─── */
#mortgageCalc {
  max-width: 980px;
  margin: 2em auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 30px rgba(24,86,131,0.10);
  padding: 28px 18px;
  font-family: Arial, sans-serif;
}

#mortgageCalc h2, #mortgageCalc h1 {
  color: #185683;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  font-weight: 800;
}

/* ─── Form Inputs ─── */
#mortgageCalc label {
  display: block;
  margin-bottom: 12px;
  color: #17446a;
  font-size: 1em;
}
#mortgageCalc input,
#mortgageCalc select {
  width: 100%;
  padding: 8px;
  margin-top: 4px;
  box-sizing: border-box;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f5f8fa;
  color: #17324b;
  font-size: 1em;
}

/* ─── Buttons ─── */
#mortgageCalc button,
#mortgageCalc .result-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  min-width: 110px;
  padding: 10px 18px;
  margin: 10px 6px 0 0;
  border: none;
  background: #185683;
  color: #fff;
  font-size: 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .13s;
  justify-content: center;
  text-align: center;
}
#mortgageCalc button:active,
#mortgageCalc .result-actions button:active {
  background: #143e5c;
}
#mortgageCalc .result-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin: 1.4em 0;
  flex-wrap: wrap;
}
#mortgageCalc .result-actions button span:first-child {
  font-size: 1.17em;
}

/* ─── Insight Bars ─── */
#insightBar {
  background: #fefce8;
  color: #92400e;
  border: 2px solid #fde68a;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-weight: 600;
  border-radius: 8px;
}
#taxInsightBar {
  font-weight: bold;
  margin-bottom: 16px;
  color: #197b56;
}

/* ─── Summary Bar ─── */
#summarySnapshot {
  background: #e7f4fb;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 12px;
  font-weight: 600;
  color: #17446a;
  justify-content: center;
  align-items: center;
}

/* ─── DTI Badge ─── */
.dti-badge {
  margin-left: 8px;
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 0.96em;
  font-weight: 600;
  vertical-align: middle;
  display: inline-block;
}
.dti-danger { background: #fca5a5; color: #7f1d1d; }
.dti-warn   { background: #fde68a; color: #92400e; }
.dti-safe   { background: #bbf7d0; color: #166534; }

/* ─── Results Boxes ─── */
.result-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #e2e8f0;
  font-size: 1.05em;
  width: 100%;
}
.result-box:last-child {
  border-bottom: none;
}
.result-label {
  color: #16507f;
  font-weight: 500;
}
.result-value {
  font-weight: 700;
}

/* ─── DTI Warning Text ─── */
#dtiWarning {
  color: #b45309;
  font-size: 0.97em;
  margin-top: 4px;
}

/* ─── Chart Container ─── */
#costBreakdownChart {
  max-width: 320px;
  width: 100%;
  height: auto;
  margin: 0 auto;
  display: block;
  background: #f5faff;
  border-radius: 8px;
}

/* ─── Advanced Settings Content ─── */
#advSettings {
  display: none;
  margin-bottom: 24px;
  padding: 10px 0 0 0;
}

/* ─── Accordion/Panel for Amortization Chart ─── */
#amortAccordion {
  width: 100%;
  font-size: 1.08rem;
  margin-bottom: 0.5em;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  color: #185683;
  font-weight: 700;
  padding: 10px 8px;
  transition: background .13s;
}
#amortAccordion:hover {
  background: #e5e7eb;
}
#amortPanel {
  display: none;
  background: #f9fafb;
  padding: 12px 0;
  border-radius: 0 0 8px 8px;
  margin-bottom: 12px;
  width: 100%;
  overflow-x: auto;
}

/* ─── Responsive Fixes ─── */
@media (max-width: 700px) {
  #mortgageCalc {
    padding: 10px 1vw;
    max-width: 100vw;
    border-radius: 0;
    box-shadow: none;
  }
  #summarySnapshot, .summary-sticky {
    flex-direction: column;
    gap: 8px 0;
    font-size: 1em;
    align-items: flex-start;
    text-align: left;
    width: 100%;
  }
  .result-box {
    flex-direction: column;
    align-items: flex-start;
    font-size: 1em;
    padding: 10px 0;
    width: 100%;
  }
  #affordCalcForm {
    flex-direction: column;
    gap: 0;
    width: 100%;
  }
  .result-actions {
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }
  #downloadBtn, #printBtn, #shareBtn {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 0 10px 0 !important;
    justify-content: center;
    text-align: center;
  }
  #resetBtn {
    width: 100% !important;
    margin: 16px 0 0 0 !important;
    display: flex !important;
    justify-content: center !important;
    text-align: center !important;
  }
  #costBreakdownChart {
    max-width: 98vw;
    height: auto;
  }
  #amortPanel {
    padding: 6px 0;
  }
}

/* Reset Button Alignment Fix */
#resetBtn {
  display: flex;
  justify-content: center;
  align-items: center;
  width: auto;
  min-width: 110px;
  margin-top: 10px;
  margin-left: 0;
  text-align: center;
}

/* ─── Dark Mode ─── */
body.dark-mode, #mortgageCalc.dark-mode {
  background: #131a24 !important;
  color: #e6e6e6 !important;
}
body.dark-mode #mortgageCalc,
#mortgageCalc.dark-mode {
  background: #192132 !important;
  color: #e6e6e6 !important;
}
body.dark-mode input,
body.dark-mode select,
#mortgageCalc.dark-mode input,
#mortgageCalc.dark-mode select {
  background: #24304b !important;
  color: #f3f3f3 !important;
  border-color: #2d3c5c !important;
}
body.dark-mode .summary-sticky,
body.dark-mode #summarySnapshot {
  background: #22305a !important;
  color: #f3f3f3 !important;
}
body.dark-mode #insightBar,
body.dark-mode #taxInsightBar {
  background: #232616 !important;
  color: #eedc82 !important;
  border-color: #bba620 !important;
}
body.dark-mode label {
  color: #e6e6e6 !important;
}
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode #mortgageCalc h2,
body.dark-mode #mortgageCalc h1 {
  color: #f7fafc !important;
  text-shadow: 0 2px 8px #102440;
}
body.dark-mode .result-label {
  color: #e0e0e0 !important;
}
body.dark-mode .result-box {
  border-bottom: 1px solid #2d3c5c !important;
}
body.dark-mode #amortAccordion {
  background: #222c3a !important;
  color: #e6e6e6 !important;
  border-color: #42506b !important;
}
body.dark-mode #amortPanel {
  background: #1a2330 !important;
  color: #e6e6e6 !important;
}
body.dark-mode #costBreakdownChart {
  background: #162028 !important;
}

/* ─── Print Styles: Fix Cutoff & Center ─── */
@media print {
  html, body {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }
  body * {
    visibility: hidden !important;
    box-shadow: none !important;
  }
  #mortgageCalc, #mortgageCalc * {
    visibility: visible !important;
    box-shadow: none !important;
  }
  #mortgageCalc {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100vw !important;
    min-width: 0 !important;
    max-width: 100vw !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: 0 !important;
    background: #fff !important;
    color: #000 !important;
    box-sizing: border-box !important;
  }
  #affordCalcForm, .summary-sticky, #summarySnapshot, .result-box, .result-actions, #amortPanel {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  #costBreakdownChart {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    display: block !important;
    margin: 0 auto !important;
  }
  #downloadBtn, #shareBtn, #printBtn {
    display: none !important;
  }
  /* Make sure pie and amortization fit on the page */
  #amortPanel {
    overflow-x: auto !important;
  }
}
/* ─── Print Styles: Center Calculator and Prevent Cut-off ─── */
@media print {
  body, html {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  #mortgageCalc {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    background: #fff !important;
    color: #222 !important;
    page-break-inside: avoid !important;
  }
  #mortgageCalc * {
    color: #222 !important;
    background: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    text-shadow: none !important;
  }
  /* Remove controls/buttons for print */
  #themeToggle,
  #langSelect,
  .result-actions,
  .result-actions button,
  .accordion,
  #amortAccordion {
    display: none !important;
  }
  /* Make tables and pie chart fit page */
  #costBreakdownChart,
  #amortizationChartContainer {
    max-width: 100% !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 auto !important;
    display: block;
  }
  /* Prevent table columns from shrinking/cutting off */
  table, th, td {
    page-break-inside: avoid !important;
    word-break: break-all !important;
    font-size: 13px !important;
  }
  /* Headings larger for print clarity */
  #mortgageCalc h1, #mortgageCalc h2 {
    font-size: 1.5em !important;
    color: #17446a !important;
    margin-top: 0.5em !important;
    margin-bottom: 0.5em !important;
  }
  /* Form inputs look like plain text for print */
  #mortgageCalc input,
  #mortgageCalc select {
    border: none !important;
    background: none !important;
    color: #333 !important;
    font-size: 1em !important;
    width: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    display: inline !important;
  }
  /* Fix margins and centering for all content */
  #mortgageCalc form,
  #mortgageCalc > * {
    margin-left: auto !important;
    margin-right: auto !important;
    float: none !important;
    clear: both !important;
  }
  /* Force pie chart legend to wrap if wide */
  #costBreakdownChart + div {
    max-width: 100% !important;
    word-break: break-word !important;
    white-space: normal !important;
  }
}


/* ─── End ─── */
