@import url("https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800&display=swap");

:root {
  --primary-color: #101010;
  --primary-dark: #222222;
  --primary-black: #1a1a1a;
  --primary-light: #ffffff;
  --hightlight-background: #101010;
  --primary-border: #e2e8f0;
  --text-dark: #1a1a1a;
  --text-medium: #4a5568;
  --text-light: #6b7280;
  --bg: #f5f7fa;
  --border: #e2e8f0;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", sans-serif;
  background: white;
  height: 100vh;
  color: var(--text-dark);
  line-height: 1.6;
}

/* Layout */
.main_container {
  display: flex;
  flex-wrap: wrap;
  padding-bottom: 5px;
}

.div-left,
.div-right {
  flex: 1;
  box-sizing: border-box;
}

.div-left {
  flex: 0.45;
}

.div-right {
  flex: 0.55;
}

.div-left .child,
.div-left .parallel-options {
  margin-right: 5px;
}

.div-right .child,
.div-right .parallel-options {
  margin-left: 5px;
}

/* Cards & Containers */
.child {
  margin: 10px;
  padding: 5px 15px;
  vertical-align: top;
  background: #ffffff;
  border: 1px solid var(--primary-border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
}

.child-note {
  padding: 0 10px;
  vertical-align: top;
  box-sizing: border-box;
  font-size: 10px;
  text-align: center;
}

/* Parallel Options */
.parallel-options {
  column-gap: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background-color: var(--bg);
  margin: 10px 10px 0;
  padding: 15px;
  border: 1px solid var(--primary-border);
  border-radius: 8px 8px 0 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  box-sizing: border-box;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.parallel-options > div:first-child {
  width: 60%;
}

.parallel-options > div:last-child {
  margin: auto;
}

.parallel-options:has(+ .hidden) {
  border-radius: 8px;
  margin-bottom: 10px;
}

.parallelInvestmentOneTable:not(.hidden),
.parallelInvestmentTwoTable:not(.hidden) {
  margin-top: 0;
  border-radius: 0 0 8px 8px;
}

.parallelInvestmentOneTable:not(.hidden) > .child,
.parallelInvestmentTwoTable:not(.hidden) > .child {
  margin-top: 0;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Headers & Sections */
.overview,
.overviewHeader {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  line-height: 30px;
}

.overview h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary-black);
}

.overviewHeader {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-dark);
}

div.section-heading {
  padding: 5px;
}

table.section-heading {
  margin: 10px 0;
}

table.section-heading tr {
  text-align: center;
  font-weight: 700;
}

table.section-heading-button {
  margin: 0;
}

/* Investment Overview Grid */
.investmentOverviewGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 18px;
  align-items: stretch;
}

.statCard {
  background: #ffffff;
  border: 1px solid var(--primary-border);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.statCard:hover {
  background: #f9fafb;
}

.statCard .label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-medium);
  margin-bottom: 4px;
  line-height: 1.3;
}

.statCard .value {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary-black);
  line-height: 1.4;
  word-break: break-word;
}

/* Buttons */
.calculate-button,
.reset-button,
.downloadBtn,
.downloadCalculations,
.yearMonthToggleBtn,
.json-button {
  font-family: "Inter", sans-serif;
  color: white;
  background-color: var(--hightlight-background);
  border: none;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  width: 100%;
  height: 50px;
  font-weight: 600;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.calculate-button:hover,
.reset-button:hover,
.json-button:hover,
.downloadBtn:hover,
.downloadCalculations:hover,
.yearMonthToggleBtn:hover {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
}

.downloadCalculations {
  width: 13%;
}

.downloadButtons {
  padding-top: 10px;
}

.yearMonthToggleBtn.active {
  border-bottom: 3px solid #979797;
}

.add-goal-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--hightlight-background);
  color: white;
  border: none;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.add-goal-btn:hover {
  background-color: var(--primary-dark);
  transform: translateY(-1px);
}

.goal-remove {
  border: none;
  cursor: pointer;
  background-color: #fff;
  font-size: 14px;
  transition: background-color 0.2s ease;
  border-radius: 6px;
}

.danger-btn {
  background-color: #dc2626;
  color: #fff;
}

.danger-btn:hover {
  background-color: #b91c1c;
}

.goalActions {
  white-space: nowrap;
}

.goalActions button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  color: #4b5563;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.goalActions button:hover {
  color: #111827;
}

/* Button Container Layout */
.button-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 1rem;
}

.left-button {
  flex: 60%;
  display: flex;
  gap: 0.5rem;
}

.right-button {
  flex: 30%;
  display: flex;
  gap: 0.5rem;
}

.left-button .calculate-button {
  flex: 1.5;
}

.left-button .reset-button {
  flex: 1;
}

.right-button .json-button {
  flex: 1;
}

.left-button button,
.right-button button {
  width: 100%;
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  box-sizing: border-box;
}

.left-container,
.right-container {
  display: flex;
  gap: 5px;
}

.hide-reset-button {
  display: none;
}

.div-left .child.sticky-buttons {
  position: sticky;
  bottom: 0;
  background: #fff;
  z-index: 10;
  padding: 15px;
}

/* Tables */
table {
  font-weight: 400;
  width: 100%;
  max-width: none;
  border-collapse: collapse;
  table-layout: fixed;
  border: none;
  margin: 20px 0;
}

table.parallelTable,
table.resultTable,
table.section-heading-button {
  margin-top: 0;
}

div.resultTable {
  margin-top: 20px;
}

table.firstTable {
  margin-top: 10px;
}

th,
td {
  padding: 5px 0;
  height: 30px;
}

th {
  font-weight: 600;
}

.sub-table {
  margin: 0;
}

/* Result Tables */
.resultTable {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.resultTable th,
.resultTable td {
  text-align: left;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  height: 20px;
}

.resultTable table td:last-child {
  font-weight: 500;
}

.resultTable tr:nth-child(odd) {
  background: #fafafa;
}

.resultTable tr:hover {
  background: #f1f5f9;
}

.resultTable tr:first-child,
.resultHeader {
  background: linear-gradient(to right, #f9fafb, #f3f4f6);
  font-weight: 600;
  font-size: 14px;
  color: #374151;
  padding: 10px 6px;
  border: 1px solid #e5e7eb;
  text-align: center;
  letter-spacing: 0.3px;
  text-transform: capitalize;
}

.resultTable th:first-child,
.resultTable td:first-child {
  padding-left: 0;
  width: 10%;
  text-align: center;
}

/* Data Tables */
table.dataTable th:not(.no-border) {
  border-bottom: 1px solid var(--border);
}

.subtable-wrapper:not(.no-border) {
  border-bottom: 2px solid var(--border);
}

table.dataTable th,
table.total th,
table.heading th,
table.heading td {
  text-align: left;
}

table.dataTable th {
  align-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  height: 40px;
}

table.dataTable > thead > tr > th:first-child,
table.dataTable > tbody > tr > td:first-child,
table.sub-table > thead > tr > th:first-child,
table.sub-table > tbody > tr > td:first-child {
  width: 60%;
}

table.heading tr {
  border-bottom: 1px solid grey;
}

table.sub-table th:first-child,
table.sub-table td:first-child,
table.parallelInvYear th:first-child,
table.parallelInvYear td:first-child {
  width: auto;
}

table td:nth-child(2),
table td:nth-child(4),
table th:nth-child(2),
table th:nth-child(4),
.sub-table td:nth-child(4) {
  padding-left: 10px;
}

/* Goal Withdrawal Table */
table.goalWithdrawalTable th {
  font-weight: 500;
}

table.goalWithdrawalTable th:not(:first-child),
table.goalWithdrawalTable td:not(:first-child) {
  padding: 8px;
}

table.goalWithdrawalTable th:first-child,
table.goalWithdrawalTable td:first-child {
  padding-right: 8px;
  width: 30%;
}

table.goalWithdrawalTable th:first-child input,
table.goalWithdrawalTable td:first-child input {
  text-align: left;
}

table.goalWithdrawalTable th:nth-child(2),
table.goalWithdrawalTable td:nth-child(2) {
  text-align: center;
  width: 15%;
}

table.goalWithdrawalTable th:nth-child(3),
table.goalWithdrawalTable td:nth-child(3) {
  width: 20%;
}

table.goalWithdrawalTable th:nth-child(4),
table.goalWithdrawalTable td:nth-child(4) {
  text-align: center;
  width: 10%;
}

/* Investment Overview Tables */
.investmentOverview td:last-child,
.investmentOverview input,
.parallelInvestmentOverview input,
.combinedInvestmentOverview input {
  font-weight: 600;
}

.investmentOverview td:last-child span,
.parallelInvestmentOverview td:last-child span,
.combinedInvestmentOverview td:last-child span {
  font-weight: 600;
  font-family: "Inter", sans-serif;
  font-size: 16px;
  color: rgb(84, 84, 84);
}

.combinedInvestmentOverview,
.investmentOverview,
.parallelInvestmentOneOverview,
.parallelInvestmentTwoOverview {
  margin-bottom: 10px;
}

.investmentDetails {
  margin-bottom: 0;
}

/* Forms & Inputs */
.divWrapper {
  border-bottom: 1px solid rgb(228, 228, 228);
  padding: 0 2px;
  max-width: 100%;
  height: 30px;
  display: flex;
  align-items: center;
  position: relative;
}

.divWrapper .container {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.divWrapper input.goalAmount {
  padding-left: 15px;
  text-align: left;
}

.divWrapper:has(.divWrapperInner) {
  border-bottom: none;
  gap: 10px;
}

.divWrapperInner {
  border-bottom: 1px solid rgb(228, 228, 228);
  display: flex;
  align-items: center;
  height: 30px;
  width: 50%;
  position: relative;
}

.divWrapper .selectWrapper {
  width: 50%;
}

.selectWrapper {
  padding: 0 2px;
  max-width: 100%;
  height: 35px;
  display: flex;
  align-items: center;
}

.container {
  width: 8px;
  display: flex;
  align-items: center;
}

.pWrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

input {
  font-family: "Inter", sans-serif;
  font-size: 16px;
  height: 100%;
  width: 100%;
  flex: 1;
  text-align: center;
  box-sizing: border-box;
  background: none;
  border: none;
  outline: none;
  margin-left: 3px;
  transition: all 0.2s;
}

input.inflationRate,
input.interestRate,
input.years,
input.months {
  text-align: center;
}

input.total-sal-annual,
input.total-sal-monthly,
input.payslip-total {
  font-weight: 700;
}

select {
  appearance: none;
  outline: none;
  cursor: pointer;
  border: 1px solid var(--primary-border);
  border-radius: 8px;
  padding: 5px 10px;
  width: 100%;
  height: 100%;
  font-family: "proxima-nova", sans-serif;
  text-align: center;
  background: white;
  transition: all 0.2s;
}

select:focus {
  border-color: var(--primary-black);
  box-shadow: 0 0 0 3px rgba(16, 16, 16, 0.1);
}

/* Flex Row (Years/Months) */
.flexRow {
  display: flex;
  gap: 20px;
  align-items: center;
}

.flexRow > div {
  display: flex;
  align-items: center;
  gap: 6px;
}

.flexRow span {
  font-size: 14px;
  font-weight: 500;
  color: #444;
  white-space: nowrap;
}

.flexRow .divWrapper {
  flex: 0 0 80px;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 22px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--hightlight-background);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.toggle-label {
  margin-left: 10px;
  font-size: 14px;
  color: #333;
}

/* Radio Wrapper */
.radio-wrapper {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.radio-wrapper div {
  margin-right: 5px;
}

/* Typography */
p {
  margin: 0;
  text-align: center;
  max-height: 30px;
}

.info {
  font-size: 11px;
  margin-top: 10px;
  color: #555;
  max-height: 30px;
  font-weight: normal;
}

a {
  text-decoration: none;
}

.dataTable td,
.dataTable th,
.overviewHeader,
input,
select {
  color: var(--text-medium);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

/* Utility Classes */
.centered-content {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  height: 100%;
}

.resultNumberWrapper {
  display: flex;
  align-items: center;
}

.resultNumber {
  margin-left: 3px;
}

.totalWrapper,
.totalwrapper {
  border-bottom: none;
}

h.no-height,
td.no-height {
  height: 0;
}

.last-child {
  border-radius: 0;
}

.hidden {
  display: none;
}

/* Color Classes */
.red {
  color: #ed0f0f;
}

.green {
  color: #6a3;
}

.blue {
  color: #20aaee;
}

.grey {
  background-color: #767676;
}

.orange {
  color: #ff8c00;
}

.highlight {
  background-color: #efefef;
  font-weight: 500;
}

.goal-compromised {
  background-color: #f8d7da;
}

/* Tooltip */
.info-icon {
  position: relative;
  display: inline-block;
  margin-left: 5px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-medium);
}

.info-icon:hover .tooltip {
  visibility: visible;
  opacity: 1;
}

.tooltip {
  visibility: hidden;
  opacity: 0;
  width: 220px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 8px;
  position: absolute;
  z-index: 100;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  transition: opacity 0.2s ease-in-out;
  font-size: 12px;
  line-height: 1.4;
}

.tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #333 transparent transparent transparent;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  background: #333;
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  font-size: 14px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  min-width: 200px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #e74c3c;
}

/* Custom Dialog */
.custom-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.custom-dialog-box {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  width: min(600px, 90vw);
  max-height: 80vh;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
  padding: 18px;
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}

.custom-dialog-content {
  overflow-y: auto;
  padding-right: 6px;
}

.custom-dialog-content .dialog-message {
  margin: 0 0 8px 0;
  white-space: pre-wrap;
}

.custom-dialog-actions {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 12px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.custom-dialog-actions button {
  padding: 8px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 14px;
  background: var(--hightlight-background);
  color: white;
  font-weight: 600;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.custom-dialog-actions button:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

/* ===========================
   Responsive Media Queries
   =========================== */

/* Desktop to Tablet (≤1200px) - Stack columns */
@media (max-width: 1200px) {
  .main_container {
    flex-direction: column;
  }

  .div-left,
  .div-right {
    flex: 1 0 100%;
    width: 100%;
  }

  .div-left .child,
  .div-left .overview,
  .div-left .parallel-options,
  .div-right .child,
  .div-right .overview,
  .div-right .parallel-options {
    margin-left: 10px;
    margin-right: 10px;
  }
}

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

/* Mobile (≤768px) */
@media (max-width: 768px) {
  .desktop-only {
    display: none;
  }

  .resultTable {
    font-size: 10px;
  }

  .resultTable th:nth-child(5),
  .resultTable td:nth-child(5) {
    display: none;
  }

  .goalWithdrawalTable th,
  .goalWithdrawalTable td input,
  .goalWithdrawalTable td select {
    font-size: 14px;
  }

  /* Button layout - only for calc-button container */
  .button-container.calc-button {
    flex-wrap: wrap;
    gap: 8px;
  }

  .button-container.calc-button .left-button,
  .button-container.calc-button .right-button {
    flex: 0 0 100%;
    gap: 8px;
  }

  .button-container.calc-button .calculate-button,
  .button-container.calc-button .reset-button,
  .button-container.calc-button .json-button {
    flex: 1 1 50%;
    max-width: 50%;
    height: 48px;
    font-size: 14px;
  }

  .button-container.calc-button .right-button {
    margin-top: 6px;
  }

  .left-container,
  .right-container {
    width: 45%;
  }

  .add-goal-btn {
    font-size: 10px;
  }
}

/* Small Mobile (≤600px) */
@media (max-width: 600px) {
  .investmentOverviewGrid {
    grid-template-columns: 1fr;
  }
}

/* Extra Small (≤500px) */
@media (max-width: 500px) {
  .resultTable {
    font-size: 10px;
  }

  .resultTable th,
  .resultTable td {
    padding: 8px 5px;
  }

  .divWrapper {
    flex-direction: column;
    height: auto;
    min-height: 30px;
    align-items: stretch;
  }

  .divWrapperInner,
  .divWrapper .selectWrapper {
    width: 100%;
  }

  .downloadCalculations {
    width: 20%;
  }

  .child,
  .overview,
  .parallel-options,
  .div-left .child,
  .div-left .overview,
  .div-left .parallel-options,
  .div-right .child,
  .div-right .overview,
  .div-right .parallel-options {
    margin: 0;
    border-radius: 0;
  }

  .overview h1,
  .overviewHeader {
    font-size: 0.9rem;
  }
}
