/* ── Calculator Page Styles ── */

/* Tabs */
.calc-tabs {
  display: flex;
  gap: var(--sp-2);
  background: var(--bg-light-grey);
  padding: var(--sp-2);
  border-radius: var(--radius-lg);
  margin-bottom: var(--sp-6);
  width: fit-content;
  flex-wrap: wrap;
}
.calc-tab {
  padding: var(--sp-3) var(--sp-6);
  border: none;
  background: none;
  border-radius: var(--radius-md);
  font-size: var(--fs-14);
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.calc-tab:hover { color: var(--text-brand); }
.calc-tab.active { background: var(--bg-dark); color: var(--text-white); box-shadow: var(--shadow-flat); }

/* Inflation toggle */
.inflation-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  color: var(--text-brand);
  cursor: pointer;
}
.infl-rate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--sp-4);
}
.infl-rate-row.hidden { display: none; }
.infl-label { font-size: var(--fs-13); color: var(--text-secondary); }

/* Donut output */
.calc-donut-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-7);
  flex-wrap: wrap;
  justify-content: center;
  padding: var(--sp-3) 0;
}
.calc-legend { display: flex; flex-direction: column; gap: var(--sp-3); }
.result-real { font-size: var(--fs-12); color: var(--text-tertiary); margin-top: var(--sp-1); }

.calc-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: var(--sp-6);
  align-items: start;
}

.calc-inputs {
  position: sticky;
  top: calc(var(--ticker-height) + var(--nav-height) + var(--sp-5));
}

.calc-field {
  margin-bottom: var(--sp-7);
}

.calc-field:last-child {
  margin-bottom: 0;
}

.calc-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-4);
}

.calc-field-header label {
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  color: var(--text-brand);
}

.calc-input-wrapper {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  font-size: var(--fs-14);
  width: 170px;            /* wide enough for large amounts like ₹5,00,00,000 */
  max-width: 100%;
}

.calc-input-wrapper span {
  color: var(--text-tertiary);
  font-size: var(--fs-13);
  flex-shrink: 0;
}

.calc-input-wrapper input {
  flex: 1;
  width: auto;
  min-width: 0;            /* allow the input to shrink inside the flex row */
  text-align: right;
  font-weight: var(--fw-semibold);
  color: var(--text-brand);
  font-variant-numeric: tabular-nums;
}
/* hide the number-spinner arrows that eat horizontal space */
.calc-input-wrapper input::-webkit-outer-spin-button,
.calc-input-wrapper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.calc-input-wrapper input[type=number] { -moz-appearance: textfield; appearance: textfield; }

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-11);
  color: var(--text-tertiary);
  margin-top: var(--sp-2);
}

/* Result cards */
.result-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}

.result-card {
  padding: var(--sp-5) var(--sp-6);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.invested-card {
  background: linear-gradient(135deg, #e8f4fd, #d5eeff);
}

.returns-card {
  background: linear-gradient(135deg, #e8fdf0, #d5ffe5);
}

.total-card {
  background: linear-gradient(135deg, #151e28, #2a3a4c);
  color: var(--text-white);
  position: relative;
}

.result-label {
  font-size: var(--fs-12);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: var(--fw-medium);
  opacity: 0.7;
}

.result-value {
  font-size: var(--fs-24);
  font-weight: var(--fw-bold);
}

.total-card .result-label { color: rgba(255,255,255,0.7); }
.total-card .result-value { color: #fff; }

.result-multiplier {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-4);
  background: rgba(255,255,255,0.15);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
  color: #98dfea;
}

/* Growth area chart */
.calc-growth-wrap { position: relative; width: 100%; }
.calc-growth-wrap canvas { width: 100%; display: block; }
.calc-growth-legend { display: flex; gap: var(--sp-4); }
.calc-growth-legend .legend-item { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-12); color: var(--text-secondary); }
.calc-growth-legend .legend-dot { width: 9px; height: 9px; border-radius: 50%; }

/* Chart legend */
.chart-legend-inline {
  display: flex;
  justify-content: center;
  gap: var(--sp-6);
  margin-top: var(--sp-4);
}

/* Scenarios */
.scenarios-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}

.scenario-card {
  padding: var(--sp-5);
  background: var(--bg-light-grey);
  border-radius: var(--radius-md);
}

.scenario-header {
  padding-left: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.scenario-label {
  font-size: var(--fs-13);
  font-weight: var(--fw-semibold);
  color: var(--text-brand);
  display: block;
}

.scenario-rate {
  font-size: var(--fs-12);
  color: var(--text-tertiary);
}

.scenario-value {
  font-size: var(--fs-20);
  font-weight: var(--fw-bold);
  color: var(--text-brand);
  margin-bottom: var(--sp-1);
}

.scenario-returns {
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
}

@media (max-width: 1024px) {
  .calc-layout { grid-template-columns: 1fr; }
  .calc-inputs { position: static; }
}

@media (max-width: 768px) {
  .result-cards { grid-template-columns: 1fr; }
  .scenarios-grid { grid-template-columns: 1fr; }
}

/* Goal planner — lumpsum alternative note */
.goal-alt {
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-subtle, #f1f4f9);
  border-radius: var(--radius-md);
  font-size: var(--fs-13);
  color: var(--text-secondary);
}
.goal-alt b { color: var(--text-brand); }

/* ── SIP Backtest ── */
.calc-sub-label { display:block; font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--text-secondary); margin-bottom: var(--sp-2); }
.bt-fund-picker { margin-bottom: var(--sp-5); }
.bt-search-group { position: relative; }
.bt-search-group .search-input { width: 100%; padding-left: 38px; height: 40px; border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.bt-search-group .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-tertiary); }
.bt-fund-picker .autocomplete-dropdown { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; }
.bt-selected { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--border-default); background: var(--bg-subtle, #f1f4f9); border-radius: var(--radius-md); }
.bt-sel-name { font-size: var(--fs-13); font-weight: var(--fw-semibold); color: var(--text-brand); }
.bt-change { background: none; border: none; color: var(--text-secondary); font-size: var(--fs-12); font-weight: var(--fw-semibold); cursor: pointer; text-decoration: underline; }
.bt-change:hover { color: var(--text-brand); }
.bt-note { margin-top: var(--sp-4); font-size: var(--fs-12); color: var(--text-tertiary); line-height: 1.5; }
.bt-note b { color: var(--text-secondary); }
.bt-headline { font-size: var(--fs-14); color: var(--text-secondary); margin-bottom: var(--sp-4); line-height: 1.5; }
.bt-headline b { color: var(--text-brand); }
.bt-disclaimer { margin-top: var(--sp-3); font-size: var(--fs-11); color: var(--text-tertiary); }
.bt-empty { text-align: center; padding: var(--sp-7) var(--sp-4); }
.bt-empty-ic { font-size: var(--fs-32); margin-bottom: var(--sp-3); }
.bt-empty-title { font-size: var(--fs-15); font-weight: var(--fw-semibold); color: var(--text-secondary); margin-bottom: var(--sp-2); }
.bt-empty-sub { font-size: var(--fs-13); color: var(--text-tertiary); line-height: 1.5; max-width: 320px; margin: 0 auto; }

/* ── Backtest: modes, month range, XIRR grid, min/max ── */
.bt-modes { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.bt-mode { display: inline-flex; align-items: center; gap: 6px; padding: 6px var(--sp-3); border: 1px solid var(--border-default); border-radius: var(--radius-full); font-size: var(--fs-12); font-weight: var(--fw-semibold); color: var(--text-secondary); cursor: pointer; transition: all var(--transition-fast); }
.bt-mode input { display: none; }
.bt-mode:hover { border-color: var(--text-brand); color: var(--text-brand); }
.bt-mode.active { background: var(--bg-dark); border-color: var(--bg-dark); color: var(--text-white); }
.bt-month-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.bt-month input[type="month"] { width: 100%; height: 40px; padding: 0 var(--sp-3); border: 1px solid var(--border-default); border-radius: var(--radius-md); font-size: var(--fs-13); color: var(--text-primary); background: var(--bg-white); }
.bt-date-row { margin-bottom: var(--sp-4); }
.calc-select { width: 100%; height: 40px; padding: 0 var(--sp-3); border: 1px solid var(--border-default); border-radius: var(--radius-md); font-size: var(--fs-13); background: var(--bg-white); color: var(--text-primary); cursor: pointer; }
.bt-submit { width: 100%; margin-top: var(--sp-2); }

.bt-xirr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: var(--sp-2); margin: var(--sp-4) 0; }
.bt-xirr-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--sp-3) 4px; border: 1px solid var(--border-light); border-radius: var(--radius-md); background: var(--bg-white); }
.bt-xirr-cell .bxc-day { font-size: var(--fs-11); color: var(--text-tertiary); font-weight: var(--fw-semibold); }
.bt-xirr-cell .bxc-val { font-size: var(--fs-13); font-weight: var(--fw-bold); color: var(--text-brand); font-variant-numeric: tabular-nums; }
.bt-xirr-cell.is-best { background: rgba(18,161,80,0.10); border-color: var(--color-up, #12a150); }
.bt-xirr-cell.is-best .bxc-val { color: var(--color-up-dark, #0f7a3d); }
.bt-xirr-cell.is-worst { background: rgba(226,58,78,0.08); border-color: var(--color-down, #e23a4e); }
.bt-xirr-cell.is-worst .bxc-val { color: var(--color-down, #e23a4e); }

.bt-minmax { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); margin-top: var(--sp-3); }
.bt-mm { display: flex; flex-direction: column; gap: 2px; padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-md); color: #fff; }
.bt-mm b { font-size: var(--fs-20); font-variant-numeric: tabular-nums; }
.bt-mm span { font-size: var(--fs-11); opacity: 0.92; }
.bt-mm-max { background: var(--color-up, #12a150); }
.bt-mm-min { background: var(--color-down, #e23a4e); }

@media (max-width: 600px) {
  .bt-minmax { grid-template-columns: 1fr; }
  .bt-xirr-grid { grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); }
}

/* Backtest data-coverage warning */
.bt-warn {
  display: block;
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  background: #fff7e6;
  border: 1px solid #f5d27a;
  border-radius: var(--radius-md);
  font-size: var(--fs-12);
  color: #8a5a00;
  line-height: 1.5;
}
.bt-warn b { color: #6b4500; }
