/* Page-specific styles - home, transactions, budget, settings */

/* --- Home Calendar --- */
.home-metrics{
  display:grid; grid-template-columns: repeat(3, 1fr); gap:16px; margin: 6px 0 16px;
}
.home-metrics .metric{ display:flex; flex-direction:column; align-items:center; text-align: center; }
.home-metrics .metric-label{
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 6px;
}
.home-metrics .metric-box{
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display:flex;
  justify-content:center;
  align-items:center;
}
.home-metrics .val{
  font-size: 28px;
  font-weight: 800;
  text-align: center;
}

.cal-head{ display:grid; grid-template-columns:repeat(7,1fr); gap:12px; padding:12px 12px 0; color:var(--muted); font-size:12px; }
.cal{
  display:grid; grid-template-columns: repeat(7, 1fr);
  gap: 12px; padding: 12px;
}
.cal .day{
  position:relative; min-height: 120px;
  border:1px solid var(--line); border-radius:12px; padding:10px;
  background: var(--panel-2);
  display:flex; flex-direction:column; justify-content:space-between;
  cursor:pointer;
}
.cal .day.muted{ opacity:.45; }
.cal .day .d{ font-weight:600; color:var(--muted); }
.cal .day .bal{ position:absolute; right:10px; top:8px; font-weight:700; }
.cal .row{ font-size:12px; color: var(--muted); }
.cal .row .chg{ font-weight:700; }
.cal .pos{ color: var(--mint); }
.cal .neg{ color: var(--danger); }

/* Home calendar day visual enhancements */
.cal .day.negative-balance {
  background: rgba(255, 107, 107, 0.15) !important;
  border-color: rgba(255, 107, 107, 0.3) !important;
}

.cal .day.no-change {
  opacity: 0.4 !important;
}

.cal .day.low-balance {
  background: rgba(255, 193, 7, 0.15) !important;
  border-color: rgba(255, 193, 7, 0.3) !important;
}

/* Adjacent month days styling */
.cal .day.adjacent-month {
  background: rgba(15, 18, 22, 0.6) !important;
  opacity: 0.3;
  border-color: rgba(38, 48, 58, 0.5) !important;
}

/* Override background for adjacent month days with balance warnings */
.cal .day.adjacent-month.negative-balance {
  background: rgba(255, 107, 107, 0.10) !important;
  border-color: rgba(255, 107, 107, 0.25) !important;
}

.cal .day.adjacent-month.low-balance {
  background: rgba(255, 193, 7, 0.10) !important;
  border-color: rgba(255, 193, 7, 0.25) !important;
}

/* Today highlighting on home calendar */
.cal .day.today {
  border: 2px solid var(--mint) !important;
  box-shadow: 0 0 0 1px var(--mint);
  opacity: 1 !important;
}

/* Expected transaction indicator dot */
.cal .day .bal .expected-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #ffc107;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* Home: month nav above metrics spacing */
#home .month-nav{ margin: 0 0 12px; }
#home .home-metrics{ margin: 0 0 16px; }

/* --- Transactions page --- */
.tx-layout{
  display:grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 1000px){
  .tx-layout{ grid-template-columns: 1fr; }
}

/* Month switcher alignment within transactions layout */
.tx-layout .month-nav{
  grid-column: 1 / 2;
  justify-self: center;
}

/* Pin grid items to intended columns */
.tx-layout > .tx-card{ grid-column: 1 / 2; }
.tx-layout > .summary-card{ grid-column: 2 / 3; }
@media (max-width: 1000px){
  .tx-layout > .tx-card,
  .tx-layout > .summary-card,
  .tx-layout .month-nav{ grid-column: 1 / 2; }
}

/* Summary Card */
.summary-card{ padding: 12px; }
.summary-header h3{ margin: 10px 8px 12px; font-size: 14px; color: var(--muted); }
.summary-list{ list-style:none; margin: 0; padding: 0; display: grid; gap: 10px; }
.summary-item{
  display:flex; justify-content: space-between; align-items: baseline;
  padding: 10px 12px; border:1px solid var(--line); border-radius: 12px; background: var(--panel-2);
}
.summary-item .label{ font-size: 12px; color: var(--muted); }
.summary-item .value{ font-weight: 700; font-variant-numeric: tabular-nums; }
.summary-item .value.income{ color: var(--mint); }
.summary-item .value.expense{ color: var(--danger); }

/* Summary: faded colors for remaining expected totals */
.summary-item .value.income.pending { color: rgba(52, 241, 201, 0.40); }
.summary-item .value.expense.pending { color: rgba(255, 107, 107, 0.40); }

/* --- Budget page --- */
.budget-layout {
  display: grid;
  grid-template-columns: 75% 1fr;
  gap: 16px;
  align-items: start;
}

.budget-layout .month-nav {
  grid-column: 1 / -1;
  justify-self: center;
  margin-bottom: 16px;
}

.budget-grid{ 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 16px;
  grid-column: 1 / 2;
}

.budget-sidebar {
  grid-column: 2 / 3;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Budget Summary Card Styling */
.budget-summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}

.budget-remaining-header {
  text-align: center;
}

.budget-remaining-amount {
  font-size: 42px;
  font-weight: 800;
  color: var(--mint);
  margin-bottom: 8px;
  line-height: 1;
}

.budget-remaining-amount.negative {
  color: var(--danger);
}

.budget-remaining-label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}

/* Budget Summary Tabs */
.budget-summary-tabs {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}

.budget-tab {
  flex: 1;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.budget-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.budget-tab.active {
  background: var(--panel-2);
  color: var(--text);
}

/* Budget Summary Content */
.budget-summary-content {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  min-height: 300px;
}

.budget-tab-content {
  display: none;
}

.budget-tab-content.active {
  display: block;
}

.budget-summary-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.budget-summary-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.budget-summary-top-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.budget-summary-header {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}

.budget-summary-budget-amount {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

/* Sidebar Progress Bars */
.sidebar-progress-bar {
  width: 100%;
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

.sidebar-progress-fill {
  height: 100%;
  transition: width 0.3s ease, background-color 0.3s ease;
  border-radius: 6px;
  background: var(--mint);
}

.sidebar-progress-fill.over-budget {
  background: var(--danger);
}

.sidebar-progress-fill.at-budget {
  background: #ffc107;
}

.budget-summary-bottom-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.budget-summary-actual {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.budget-summary-remaining {
  font-size: 13px;
  color: var(--mint);
  font-weight: 600;
}

.budget-summary-remaining.negative {
  color: var(--danger);
}

/* Individual group items in Income/Expenses tabs */
.budget-group-item {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.budget-group-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.budget-group-item-top-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.budget-group-item-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.budget-group-item-budget {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.budget-group-item-bottom-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.budget-group-item-actual {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.budget-group-item-remaining {
  font-size: 13px;
  color: var(--mint);
  font-weight: 600;
}

.budget-group-item-remaining.negative {
  color: var(--danger);
}

.budget-head h2{ font-size:16px; font-weight:700; margin:0; }
.budget-head .cols{ color: var(--muted); font-size:12px; }

/* Budget: align titles with table and add cushion */
.budget-head{
  padding: 16px 16px 8px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

/* Budget: container padding on cards */
.budget-grid .card{ padding-left: 24px; padding-right: 24px; }
.type-card .type-body{ padding:12px 14px 16px; padding-left: 12px; border-top:1px solid var(--line); }
.type-card .empty-state{ opacity:.6; font-size:13px; text-align:center; padding:24px 8px; }

.budget-incometotals-container,
.budget-expensestotals-container,
.budget-goalstotals-container {
  min-height: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  margin: 16px 0;
}

/* Subtle colored backgrounds for type totals */
.budget-incometotals-container {
  background: rgba(52, 241, 201, 0.08);
  border-color: rgba(52, 241, 201, 0.15);
}

.budget-expensestotals-container {
  background: rgba(255, 107, 107, 0.08);
  border-color: rgba(255, 107, 107, 0.15);
}

.budget-goalstotals-container {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.15);
}

/* Increased left padding for type totals first column */
.budget-incometotals-container .budget-table td:first-child,
.budget-expensestotals-container .budget-table td:first-child,
.budget-goalstotals-container .budget-table td:first-child {
  padding-left: 16px;
}

.budget-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

/* Budget table column widths */
.budget-table th:nth-child(1),
.budget-table td:nth-child(1) {
  width: 25%;
}

.budget-table th:nth-child(2),
.budget-table td:nth-child(2) {
  width: 35%;
}

.budget-table th:nth-child(3),
.budget-table td:nth-child(3),
.budget-table th:nth-child(4),
.budget-table td:nth-child(4),
.budget-table th:nth-child(5),
.budget-table td:nth-child(5) {
  width: 13.33%;
  text-align: center;
}

.budget-table th {
  padding: 8px 4px;
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  border: none;
}

.budget-table td {
  padding: 12px 4px;
  border: none;
}

.budget-table tbody tr:last-child td {
  border-bottom: none;
}

.budget-header-container {
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.budget-group-container {
  margin-bottom: 16px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.budget-group-container:last-of-type {
  border-bottom: none;
}

/* Category row separation lines */
.budget-group-categories .budget-table tbody tr {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.budget-group-categories .budget-table tbody tr:first-child {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.budget-group-categories .budget-table tbody tr:last-child {
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Budget button styling */
.budget-add-btn {
  background: var(--mint);
  color: #042420;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 2px 6px;
  margin-left: 8px;
  border-radius: 4px;
  font-weight: 600;
  transition: opacity 0.15s ease, filter 0.15s ease;
  opacity: 0;
}

.budget-add-btn:hover {
  filter: brightness(1.1);
}

.budget-settings-btn,
.group-settings-btn,
.category-settings-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 4px;
  margin-left: 8px;
  border-radius: 4px;
  opacity: 0;
  display: inline-block;
  transition: color 0.15s ease, opacity 0.15s ease, background-color 0.15s ease;
}

.budget-header-container tr:hover .budget-add-btn,
.budget-header-container tr:hover .budget-settings-btn,
.budget-group-container tr:hover .budget-add-btn,
.budget-group-container tr:hover .group-settings-btn,
.budget-group-container tr:hover .category-settings-btn {
  opacity: 1;
}

.budget-settings-btn:hover,
.group-settings-btn:hover,
.category-settings-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

/* Budget button styling */
.budget-amount-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  min-width: 85px;
  text-align: center;
}

.budget-amount-btn:hover {
  border-color: rgba(52, 241, 201, 0.3);
  background: rgba(255, 255, 255, 0.02);
}

.budget-amount-btn:focus {
  outline: none;
  border-color: var(--mint);
  box-shadow: 0 0 0 3px rgba(52, 241, 201, 0.15);
}

.budget-amount-btn.has-budget {
  color: var(--text);
}

.budget-amount-btn.no-budget {
  color: var(--muted);
}

/* Progress bar styling for budget visualization */
.budget-progress-container {
  width: 100%;
  height: 20px;
  position: relative;
  display: flex;
  align-items: center;
}

.budget-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.budget-progress-fill {
  height: 100%;
  transition: width 0.3s ease;
  border-radius: 4px;
}

/* Progress bar colors based on performance */
.budget-progress-fill.under-budget {
  background: var(--mint);
}

.budget-progress-fill.at-budget {
  background: #ffc107;
}

.budget-progress-fill.over-budget {
  background: var(--danger);
}

.budget-progress-fill.no-budget {
  background: var(--muted);
}

/* Progress percentage text */
.budget-progress-text {
  font-size: 10px;
  color: var(--muted);
  margin-left: 8px;
  font-variant-numeric: tabular-nums;
  min-width: 35px;
  text-align: right;
}

/* Category remaining amount styling */
.budget-table tbody tr td:nth-child(5) .remaining-amount.remaining-positive {
  background: rgba(52, 241, 201, 0.15);
  color: var(--mint);
  border-radius: 6px;
  padding: 4px 8px;
  display: inline-block;
}

.budget-table tbody tr td:nth-child(5) .remaining-amount.remaining-zero {
  background: rgba(159, 176, 178, 0.15);
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 8px;
  display: inline-block;
}

.budget-table tbody tr td:nth-child(5) .remaining-amount.remaining-negative {
  background: rgba(255, 107, 107, 0.15);
  color: var(--danger);
  border-radius: 6px;
  padding: 4px 8px;
  display: inline-block;
}

/* Type and Group totals remaining amount text coloring */
.budget-table td.remaining-positive {
  color: var(--mint) !important;
}

.budget-table td.remaining-zero {
  color: var(--muted) !important;
}

.budget-table td.remaining-negative {
  color: var(--danger) !important;
}

/* Form group styles for modals */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* --- Settings page --- */
.settings-layout {
  display: flex;
  gap: 16px;
  min-height: 400px;
}

.settings-sidebar {
  width: 25%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.settings-main {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

/* Settings navigation styling */
.settings-nav-item {
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 8px;
  background: transparent;
  border: none;
  border-radius: 10px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.settings-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.settings-nav-item.active {
  background: var(--accent);
  color: var(--text);
  font-weight: 600;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

/* Settings form styling */
.setting-group {
  margin-bottom: 24px;
}

.setting-group h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

#balanceWarningThreshold {
  width: 200px;
  padding: 10px 12px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#balanceWarningThreshold:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 230, 184, 0.15);
}

#balanceWarningThreshold::-webkit-outer-spin-button,
#balanceWarningThreshold::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#balanceWarningThreshold[type=number] {
  -moz-appearance: textfield;
}

/* --- Day modal transaction table --- */
.day-modal-table {
  width: 100%; 
  border-collapse: collapse; 
  font-size: 14px;
}

.day-modal-table th {
  text-align: left; 
  padding: 8px 4px; 
  color: var(--muted); 
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}

.day-modal-table td {
  padding: 8px 4px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.day-modal-actions {
  text-align: center;
}

.day-modal-btn {
  font-size: 12px; 
  padding: 4px 8px;
}

/* Collapsible groups */
.collapse-toggle{
  appearance:none;
  border:2px solid transparent;
  background:transparent;
  padding:0;
  margin-right:8px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border-radius:50%;
  width:30px;
  height:30px;
  outline:none;
  line-height:0;
}
.collapse-toggle:hover{ border-color: var(--mint); background: transparent; }
.collapse-toggle:focus{ outline:none; }
.collapse-toggle:focus-visible{ box-shadow: 0 0 0 2px var(--mint) inset; }

.caret{
  position:relative;
  width:14px;
  height:14px;
  display:block;
  transform-origin:50% 50%;
  transition: transform .18s ease;
}
.caret::before{
  content:'';
  position:absolute;
  top:50%; left:50%;
  transform: translate(-50%, -48%);
  width:0; height:0;
  border-left:7px solid transparent;
  border-right:7px solid transparent;
  border-top:9px solid currentColor;
}

.budget-group-container.collapsed .caret{ transform: rotate(-90deg); }

.budget-group-container .budget-group-categories{
  overflow:hidden;
  transition: max-height .2s ease, opacity .2s ease, margin-top .2s ease;
  max-height:1200px;
  opacity:1;
  margin-top:4px;
  display:block;
}
.budget-group-container.collapsed .budget-group-categories{
  max-height:0;
  opacity:0;
  margin-top:0;
}

.type-groups-wrap{
  overflow:hidden;
  transition: max-height .25s ease, opacity .2s ease, margin-top .2s ease;
  max-height: 2000px;
  opacity: 1;
  margin-top: 8px;
}
.type-groups-wrap.collapsed{
  max-height: 0;
  opacity: 0;
  margin-top: 0;
}
.type-collapse-toggle.is-collapsed .caret{ transform: rotate(-90deg); }