/* ==========================================================
   EpicTools — Budget Planner styles
   Requires css/main.css (design tokens) to be loaded first.
   ========================================================== */

/* ──────────────────────────────────────────────────────────
   VISUALLY HIDDEN (accessible file input)
────────────────────────────────────────────────────────── */
.bp-visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ──────────────────────────────────────────────────────────
   ACTION BAR
────────────────────────────────────────────────────────── */
.bp-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  justify-content: flex-end;
  margin-bottom: var(--sp-4);
}

/* ──────────────────────────────────────────────────────────
   BUTTONS
────────────────────────────────────────────────────────── */
.bp-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.bp-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

.bp-btn--primary {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}
.bp-btn--primary:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

.bp-btn--secondary {
  background: var(--color-bg-elevated);
  color: var(--color-text);
  border-color: var(--color-border-solid);
}
.bp-btn--secondary:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-strong);
}

.bp-btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border-solid);
}
.bp-btn--ghost:hover {
  color: var(--color-accent);
  background: var(--color-accent-dim);
  border-color: var(--color-accent);
}

.bp-btn--add-row {
  margin-top: var(--sp-2);
  width: 100%;
  justify-content: center;
  font-size: 0.8125rem;
}

/* ──────────────────────────────────────────────────────────
   BUDGET TABS
────────────────────────────────────────────────────────── */
.bp-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: var(--sp-1);
  border-bottom: 2px solid var(--color-border-solid);
  margin-bottom: 0;
  padding-bottom: 0;
  scrollbar-width: none;
}
.bp-tabs::-webkit-scrollbar { display: none; }

.bp-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: var(--radius) var(--radius) 0 0;
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease),
              background var(--dur-fast) var(--ease);
  margin-bottom: -2px;
}
.bp-tab:hover { color: var(--color-text); background: var(--color-bg-elevated); }
.bp-tab:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.bp-tab--active {
  color: var(--color-text-heading);
  background: var(--color-bg-card);
  border-color: var(--color-border-solid) var(--color-border-solid) var(--color-bg-card);
  border-bottom-color: var(--color-bg-card);
}

.bp-tab--add {
  color: var(--color-accent);
  border-style: dashed;
  border-color: var(--color-border-solid);
  margin-left: var(--sp-1);
}
.bp-tab--add:hover {
  color: var(--color-accent-hover);
  background: var(--color-accent-dim);
}

.bp-tab__name { pointer-events: none; }

.bp-tab__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  font-size: 0.875rem;
  line-height: 1;
  color: var(--color-text-subtle);
  transition: color var(--dur-fast), background var(--dur-fast);
  cursor: pointer;
  flex-shrink: 0;
  pointer-events: all;
}
.bp-tab__remove:hover { color: #ef4444; background: rgba(239,68,68,0.12); }

/* ──────────────────────────────────────────────────────────
   PANELS
────────────────────────────────────────────────────────── */
.bp-panel { display: none; padding-top: var(--sp-6); }
.bp-panel--active { display: block; }

/* ──────────────────────────────────────────────────────────
   BUDGET NAME ROW
────────────────────────────────────────────────────────── */
.bp-name-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}

.bp-name-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.bp-name-input {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
  padding: var(--sp-2) var(--sp-3);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-solid);
  border-radius: var(--radius);
  color: var(--color-text-heading);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.bp-name-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: var(--shadow-focus);
}

/* ──────────────────────────────────────────────────────────
   INCOME / EXPENSE GRID
────────────────────────────────────────────────────────── */
.bp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-6);
  margin-bottom: var(--sp-8);
}

@media (max-width: 700px) {
  .bp-grid { grid-template-columns: 1fr; }
}

/* ──────────────────────────────────────────────────────────
   SECTION (Income or Expenses)
────────────────────────────────────────────────────────── */
.bp-section {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
}

.bp-section__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
  gap: var(--sp-2);
}

.bp-section__title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-heading);
  margin: 0;
}

.bp-section__total {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
}
.bp-section__total--income   { color: #10B981; }
.bp-section__total--expenses { color: #EF4444; }

/* ──────────────────────────────────────────────────────────
   ROW LIST
────────────────────────────────────────────────────────── */
.bp-row--header {
  display: grid;
  grid-template-columns: 1fr 110px 28px;
  gap: var(--sp-2);
  margin-bottom: var(--sp-1);
}

.bp-row__col-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.bp-row__col-label--amt    { text-align: right; }
.bp-row__col-label--action { /* empty spacer */ }

.bp-rows { display: flex; flex-direction: column; gap: var(--sp-2); }

.bp-row {
  display: grid;
  grid-template-columns: 1fr 110px 28px;
  gap: var(--sp-2);
  align-items: center;
}

/* Category input */
.bp-row__cat {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-solid);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.bp-row__cat:focus { outline: none; border-color: var(--color-accent); box-shadow: var(--shadow-focus); }

/* Amount input */
.bp-row__amt {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-solid);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  text-align: right;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  /* Hide spinner arrows */
  -moz-appearance: textfield;
}
.bp-row__amt::-webkit-inner-spin-button,
.bp-row__amt::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.bp-row__amt:focus { outline: none; border-color: var(--color-accent); box-shadow: var(--shadow-focus); }

/* Remove button */
.bp-row__remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--color-text-subtle);
  font-size: 1rem;
  cursor: pointer;
  transition: color var(--dur-fast), background var(--dur-fast);
  flex-shrink: 0;
}
.bp-row__remove:hover { color: #ef4444; background: rgba(239,68,68,0.12); }
.bp-row__remove:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: 50%; }

/* ──────────────────────────────────────────────────────────
   SUMMARY CARDS
────────────────────────────────────────────────────────── */
.bp-summary { margin-top: var(--sp-2); }

.bp-summary__cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-8);
}

@media (max-width: 900px) {
  .bp-summary__cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .bp-summary__cards { grid-template-columns: 1fr; }
}

.bp-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-5);
  border-left-width: 3px;
}

.bp-card--income      { border-left-color: #10B981; }
.bp-card--expenses    { border-left-color: #EF4444; }
.bp-card--balance-pos { border-left-color: #06B6D4; }
.bp-card--balance-neg { border-left-color: #F59E0B; }
.bp-card--savings     { border-left-color: #8B5CF6; }

.bp-card__label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: var(--sp-1);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bp-card__value {
  font-family: var(--font-heading);
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--color-text-heading);
  line-height: 1.2;
}

/* ──────────────────────────────────────────────────────────
   CHARTS
────────────────────────────────────────────────────────── */
.bp-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-6);
  margin-bottom: var(--sp-6);
}

@media (max-width: 700px) {
  .bp-charts { grid-template-columns: 1fr; }
}

.bp-chart-wrap {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
}

.bp-chart__title {
  font-family: var(--font-heading);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text-heading);
  margin: 0 0 var(--sp-4) 0;
}

.bp-chart__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  color: var(--color-text-subtle);
  font-size: 0.875rem;
  font-style: italic;
}

/* ──────────────────────────────────────────────────────────
   TOAST NOTIFICATION
────────────────────────────────────────────────────────── */
.bp-toast {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  pointer-events: none;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
}
.bp-toast--visible { opacity: 1; transform: translateY(0); }
.bp-toast--success { background: #10B981; color: #fff; }
.bp-toast--error   { background: #EF4444; color: #fff; }
.bp-toast--info    { background: var(--color-bg-elevated); color: var(--color-text); border: 1px solid var(--color-border-solid); }

@media (max-width: 480px) {
  .bp-toast { bottom: var(--sp-4); right: var(--sp-4); left: var(--sp-4); max-width: none; }
}
