/* ============================================================
   Beez Санхүүгийн Туслах — Personal Mode CSS
   Enqueue alongside app.css (depends on app.css tokens)
   ============================================================ */

/* ── Mode visibility helpers ──────────────────────────────────── */
[data-bf-mode="business"] .bf-personal-only { display: none !important; }
[data-bf-mode="personal"]  .bf-business-only  { display: none !important; }

/* The main chart's row pairs it with a business-only card. With that hidden the chart
   would sit in the wide column with an empty 320px gap beside it — let it span the row. */
[data-bf-mode="personal"] .bf-charts-row-main { grid-template-columns: minmax(0, 1fr); }

/* Category manager gains a third (Хуримтлал) column in personal mode */
[data-bf-mode="personal"] .bf-cat-cols { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) {
  [data-bf-mode="personal"] .bf-cat-cols { grid-template-columns: 1fr; }
}

/* ── Personal advisor side panel ──────────────────────────────── */
.bf-padvisor-card { }
.bf-padvisor-list {
  display: flex;
  flex-direction: column;
}
.bf-padvisor-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--bf-border);
}
.bf-padvisor-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.bf-padvisor-icon-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.bf-padvisor-icon {
  font-size: 17px;
  flex-shrink: 0;
  margin-top: 1px;
  line-height: 1;
}
.bf-padvisor-content { flex: 1; }
.bf-padvisor-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--bf-text-muted);
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.bf-padvisor-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--bf-text);
  line-height: 1.4;
}
.bf-padvisor-sub {
  font-size: 12px;
  color: var(--bf-text-muted);
  margin-top: 2px;
  line-height: 1.5;
}
.bf-padvisor-good { color: var(--bf-income) !important; }
.bf-padvisor-warn { color: var(--bf-warn, #f5a623) !important; }
.bf-padvisor-bad  { color: var(--bf-expense) !important; }

/* ── Budget bars ──────────────────────────────────────────────── */
.bf-budget-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.bf-budget-item { }
.bf-budget-row-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}
.bf-budget-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--bf-text);
}
.bf-budget-amounts {
  font-size: 12px;
  color: var(--bf-text-muted);
  font-weight: 500;
}
.bf-budget-track {
  height: 8px;
  background: var(--bf-track, var(--bf-surface2));
  border-radius: 4px;
  overflow: hidden;
}
.bf-budget-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .5s cubic-bezier(.25, .8, .25, 1);
  max-width: 100%;
}
.bf-budget-fill.ok   { background: var(--bf-income); }
.bf-budget-fill.warn { background: var(--bf-amber, #f5c298); }
.bf-budget-fill.over { background: var(--bf-expense); }
.bf-budget-pct {
  font-size: 11px;
  font-weight: 700;
  margin-top: 4px;
}
.bf-budget-pct.ok   { color: var(--bf-income); }
.bf-budget-pct.warn { color: var(--bf-amber, #f5a623); }
.bf-budget-pct.over { color: var(--bf-expense); }

/* Budget settings list (in Settings page) */
.bf-budget-settings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bf-budget-settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bf-border);
}
.bf-budget-settings-row:last-child { border-bottom: none; }
.bf-budget-settings-cat { flex: 1; font-size: 13px; font-weight: 600; }
.bf-budget-settings-limit {
  font-size: 13px;
  color: var(--bf-text-muted);
  min-width: 100px;
  text-align: right;
}
.bf-budget-del-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--bf-expense);
  font-size: 14px;
  padding: 0 4px;
  opacity: .7;
  transition: opacity .15s;
}
.bf-budget-del-btn:hover { opacity: 1; }

/* ── Savings goals grid ───────────────────────────────────────── */
.bf-goals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.bf-goal-card {
  background: var(--bf-surface2);
  border: 1px solid var(--bf-border);
  border-radius: var(--bf-radius);
  padding: 18px;
  transition: box-shadow .15s;
}
.bf-goal-card:hover { box-shadow: var(--bf-shadow); }
.bf-goal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.bf-goal-name { font-size: 14px; font-weight: 700; color: var(--bf-text); }
.bf-goal-emoji { font-size: 22px; line-height: 1; }
.bf-goal-track {
  height: 10px;
  background: var(--bf-track, var(--bf-border));
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 12px;
}
.bf-goal-fill {
  height: 100%;
  border-radius: 5px;
  background: #c6b6ec;
  transition: width .6s cubic-bezier(.25, .8, .25, 1);
}
.bf-goal-nums {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.bf-goal-current {
  font-size: 15px;
  font-weight: 800;
  color: var(--bf-text);
  letter-spacing: -.01em;
}
.bf-goal-pct {
  font-size: 22px;
  font-weight: 800;
  color: var(--bf-accent);
}
.bf-goal-total {
  font-size: 12px;
  color: var(--bf-text-muted);
}
.bf-goal-remaining {
  font-size: 12px;
  color: var(--bf-text-muted);
  margin-top: 2px;
}
.bf-goal-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--bf-border);
}
.bf-goal-card-actions .bf-link-btn { font-size: 12px; }

/* Goal add card */
.bf-goal-add-card {
  background: var(--bf-accent-soft);
  border: 1.5px dashed var(--bf-accent-line, var(--bf-accent));
  border-radius: var(--bf-radius);
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--bf-accent);
  cursor: pointer;
  min-height: 120px;
  transition: background .15s;
  background-color: var(--bf-accent-soft);
}
.bf-goal-add-card:hover { filter: brightness(0.97); }
/* goals page full-row card */
#bf-goals-page-grid { margin-top: 0; }

/* ── Financial health grid ────────────────────────────────────── */
.bf-health-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.bf-health-card {
  background: var(--bf-surface2);
  border: 1px solid var(--bf-border);
  border-radius: var(--bf-radius);
  padding: 16px;
  text-align: center;
}
.bf-health-label {
  font-size: 12px;
  color: var(--bf-text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.bf-health-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--bf-text);
  letter-spacing: -.02em;
  margin-bottom: 4px;
}
.bf-health-sub {
  font-size: 11px;
  color: var(--bf-text-muted);
}

/* ── KPI card 4 personal variant ─────────────────────────────── */
/* When in personal mode the 4th KPI shows savings rate as a % value */
[data-bf-mode="personal"] #bf-kpi-cash {
  font-size: 28px;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .bf-goals-grid   { grid-template-columns: repeat(2, 1fr); }
  .bf-health-grid  { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .bf-goals-grid   { grid-template-columns: 1fr 1fr; }
  .bf-health-grid  { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .bf-goals-grid   { grid-template-columns: 1fr; }
  .bf-health-grid  { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   Mobile app-style banner — personal AND business accounts, phones only.
   On the dashboard the slim top bar is replaced by this rounded
   gradient hero (logo + name, balance, add-income / add-expense).
   Personal shows the balance, business the cash balance.
   Desktop never sees it.
   ============================================================ */
.beez-fin-root                { --bf-hero-bg: #4d3785; --bf-hero-glow: rgba(0,0,0,.45); }
.beez-fin-root.bf-light       { --bf-hero-bg: #6e51b5; --bf-hero-glow: rgba(88,67,158,.5); }
.beez-fin-root.bf-theme-pastel { --bf-hero-bg: #6e51b5; --bf-hero-glow: rgba(88,67,158,.5); }
.beez-fin-root.bf-theme-calm  { --bf-hero-bg: #5d8e6d; --bf-hero-glow: rgba(79,128,98,.5); }
.beez-fin-root.bf-theme-ocean   { --bf-hero-bg: #1d7ba2; --bf-hero-glow: rgba(26,122,154,.5); }
.beez-fin-root.bf-theme-hotpink { --bf-hero-bg: #e8215a; --bf-hero-glow: rgba(232,33,90,.55); }

.bf-hero { display: none; }

@media (max-width: 768px) {
  /* The hero is the app bar on this page; other pages keep the normal header */
  [data-bf-page="dashboard"] .bf-header { display: none; }
  #bf-page-dashboard { padding-top: 0; }

  .bf-hero {
    display: block; position: relative; overflow: hidden;
    margin: 0 -14px 16px;
    padding: calc(env(safe-area-inset-top, 0px) + 18px) 20px 22px;
    border-radius: 0 0 28px 28px;
    background: var(--bf-hero-bg); color: #fff;
    box-shadow: 0 14px 30px -14px var(--bf-hero-glow);
  }
  /* soft decorative glows */
  .bf-hero::before, .bf-hero::after { content: ''; position: absolute; border-radius: 50%; pointer-events: none; }
  .bf-hero::before { width: 220px; height: 220px; right: -70px; top: -90px; background: rgba(255,255,255,0.11); }
  .bf-hero::after  { width: 180px; height: 180px; left: -70px; bottom: -110px; background: rgba(255,255,255,0.07); }
  .bf-hero > * { position: relative; z-index: 1; }

  .bf-hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .bf-hero-user { display: flex; align-items: center; gap: 11px; min-width: 0; }
  .bf-hero-avatar {
    flex: none; width: 42px; height: 42px; border-radius: 50%; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,.2); border: 2px solid rgba(255,255,255,.55);
    font-size: 17px; font-weight: 800; color: #fff;
  }
  .bf-hero-avatar.has-logo { background: #fff; }
  .bf-hero-avatar img { width: 100%; height: 100%; object-fit: contain; display: block; }
  .bf-hero-hello { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
  .bf-hero-hello span { font-size: 12px; opacity: .8; }
  .bf-hero-hello strong { font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .bf-hero-tools { display: flex; gap: 8px; flex: none; }
  .bf-hero-icon {
    width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,.18); color: #fff; font-size: 16px; text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  .bf-hero-icon:active { background: rgba(255,255,255,.3); }

  .bf-hero-label { margin-top: 24px; font-size: 13px; font-weight: 600; opacity: .85; }
  .bf-hero-balance {
    margin: 4px 0 2px; font-size: clamp(30px, 10vw, 40px); font-weight: 800;
    letter-spacing: -.5px; line-height: 1.15; overflow-wrap: anywhere;
  }
  .bf-hero-sub { font-size: 12px; opacity: .75; }
  /* Package expiry pill under the balance */
  .bf-sub-hero {
    display: inline-flex; align-items: center; gap: 7px; max-width: 100%;
    margin-top: 12px; padding: 7px 14px; border-radius: 18px;
    background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3);
    font-size: 12px; font-weight: 600; line-height: 1.3; color: #fff;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .bf-sub-hero:active { background: rgba(255,255,255,.28); }
  .bf-sub-hero .bf-sub-dot { background: rgba(255,255,255,.75); }
  .bf-sub-hero.bf-sub-active  .bf-sub-dot { background: #8fd4b2; }
  .bf-sub-hero.bf-sub-soon    { background: rgba(246,178,143,.32); border-color: rgba(246,178,143,.75); }
  .bf-sub-hero.bf-sub-soon    .bf-sub-dot { background: #f6b28f; }
  .bf-sub-hero.bf-sub-expired { background: rgba(242,90,120,.38); border-color: rgba(255,170,190,.85); }
  .bf-sub-hero.bf-sub-expired .bf-sub-dot { background: #ffb3c4; }

  .bf-hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; }
  .bf-hero-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px; padding: 0 10px; border-radius: 14px; cursor: pointer;
    background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3); color: #fff;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    font: inherit; font-size: 14px; font-weight: 700; white-space: nowrap;
    transition: background .15s, transform .12s;
    -webkit-tap-highlight-color: transparent;
  }
  .bf-hero-btn:active { transform: scale(.96); background: rgba(255,255,255,.3); }

  /* Business: the cash balance now lives in the hero — drop its duplicate card and let the remaining odd card span the row.
     Business: hero = Мөнгөн үлдэгдэл (card 4), so Цэвэр ашиг spans.
     Personal keeps all four cards: the hero is the running balance, "Үлдэгдэл" is just the period's income − expense. */
  [data-bf-mode="business"] .bf-kpi-cash   { display: none; }
  [data-bf-mode="business"] .bf-kpi-profit { grid-column: 1 / -1; }
}

/* ── Sign-out button ──────────────────────────────────────────── */
.bf-signout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--bf-hdr-fg);
}
.bf-signout-btn:hover {
  background: rgba(242, 100, 100, .25) !important;
  color: #ff8080;
}
