/* pages/index.css – Startseite (Budget-Karte, Donut, Buchungsliste, FAB) */

/* ── TOPBAR */
.topbar-inner {
  position: relative;
  z-index: 1;
}
.topbar-label {
  font-size: clamp(.7rem, 2.5vw, 1rem);
  opacity: .6;
  text-transform: uppercase;
  letter-spacing: .12em;
  margin-bottom: 2px;
}
.total-balance {
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 12px;
}
.total-balance .currency {
  font-size: clamp(.7rem, 2.5vw, 1rem);
  opacity: .65;
  font-weight: 400;
}

/* ── HEADER MENU ICON ── */
@media (min-width: 768px) {
  /* index.html: Zahnrad als eigene dritte Spalte im Topbar-Grid, oben rechts */
  .topbar > .icon-btn.menu-toggle-btn {
      position: static;
      grid-column: 3;
      grid-row: 1;
      align-self: start;
      justify-self: end;
    }
}

/* ── INSIGHTS CHART ── */
/* account pills */
.account-pills {
  display: grid;
  flex-flow: column wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.account-pill-item {
  background: rgba(255, 255, 255, .18);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: clamp(.72rem, 2.5vw, .9rem);
  display: flex;
  align-items: center;
  gap: 6px;
}
.pill-name {
  opacity: .85;
}
.pill-val {
  font-weight: 600;
}

/* ── MAIN */
.month-label {
  text-align: center;
  font-size: clamp(.8rem, 2.5vw, .9rem);
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── BUDGET CARD */
.budget-section {
  display: flex;
  align-items: center;
  gap: 12px;
}
.budget-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.budget-info {
  flex: 1;
  min-width: 0;
}
.budget-amount {
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}
.budget-sub {
  font-size: clamp(.74rem, 2.5vw, .9rem);
  color: var(--muted);
  margin-top: 2px;
}
.budget-sub.over {
  color: var(--danger);
}

/* ── DONUT */
.donut-container {
  position: relative;
  width: 200px;
  height: 200px;
  /* Platz oben/unten für die Kategorie-Labels */
  margin: 24px auto;
}
.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.donut-center-budget {
  font-size: 1.2rem;
  color: var(--primary);
  line-height: 1;
}
.donut-center-spent {
  font-size: clamp(.75rem, 2.5vw, .9rem);
  color: var(--danger);
  font-weight: 600;
  margin-top: 3px;
}
.donut-arc {
  transition: stroke-dasharray .7s cubic-bezier(.34, 1.2, .64, 1),
              stroke-dashoffset .7s cubic-bezier(.34, 1.2, .64, 1),
              stroke .3s ease;
}
.donut-arc-pulse {
  animation: donutArcPulse .9s ease-in-out;
}
@keyframes donutArcPulse {
  0%, 100% { stroke-width: 28; }
  50%      { stroke-width: 36; }
}
.donut-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.donut-label {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  /* Breite unabhängig vom Platz bis zum Containerrand, sonst bricht
     rechts aussen jedes Wort um */
  width: max-content;
  font-size: .8rem;
  font-weight: 700;
  opacity: 0;
  transition: left .7s cubic-bezier(.34, 1.2, .64, 1),
              top .7s cubic-bezier(.34, 1.2, .64, 1),
              transform .7s cubic-bezier(.34, 1.2, .64, 1),
              opacity .4s ease;
}
.donut-label.show {
  opacity: 1;
}
.donut-label-name {
  /* lange Namen ab 90px auf zwei Zeilen umbrechen statt überlaufen */
  max-width: 90px;
  white-space: normal;
  line-height: 1.15;
  overflow-wrap: break-word;
  hyphens: auto;
}
@media (prefers-reduced-motion: reduce) {
  .donut-arc, .donut-label { transition: none; }
  .donut-arc-pulse { animation: none; }
}
.donut-center-label {
  font-size: clamp(.62rem, 2.5vw, .8rem);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: 2px;
}
.categories-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-top: 14px;
}
.cat-chip {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 10px;
  border-radius: var(--radius);
  background: var(--card-soft);
  border: 1.5px solid transparent;
  cursor: pointer;
  min-width: 0;
}
.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cat-name {
  flex: 1;
  font-size: clamp(.72rem, 2.5vw, .9rem);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cat-amount {
  font-size: clamp(.72rem, 2.5vw, .9rem);
  font-weight: 700;
  flex-shrink: 0;
}
.cat-amount.income {
  color: var(--income);
}
.cat-amount.expense {
  color: var(--danger);
}

/* ── TRANSACTIONS */
.tx-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.tx-chevron {
  color: var(--muted);
  font-size: 1rem;
  transition: transform .25s;
}
.tx-chevron.open {
  transform: rotate(180deg);
}

/* ── FAB */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h)+12px);
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 360px;
  justify-content: center;
  background: linear-gradient(135deg, #e91e63, #ff5f9e);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 14px 24px;
  font-size: clamp(.9rem, 2.5vw, 1.25rem);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-fab);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 40;
  white-space: nowrap;
  transition: box-shadow .2s, transform .15s;
}
.fab:active {
  transform: translateX(-50%) scale(.97);
}
.fab-icon {
  font-size: clamp(.9rem, 2.5vw, 1.25rem);
}

/* ── MODALS */
.type-toggle {
  display: flex;
  background: var(--card-soft);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-top: 4px;
  gap: 3px;
}
.type-btn {
  flex: 1;
  border: none;
  background: none;
  border-radius: 8px;
  padding: 9px;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: background .18s, color .18s;
}
.type-btn.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 5px rgba(0, 0, 0, .07);
}

/* ── BREAKPOINT ≥480px */
@media (min-width:480px) {
  .total-balance {
      font-size: 3rem;
    }
  .donut-container {
      width: 220px;
      height: 220px;
    }
}

/* ── BREAKPOINT ≥768px */
@media (min-width:768px) {
  .topbar {
      display: grid;
      grid-template-columns: .8fr 1.1fr auto;
      align-items: start;
      gap: 32px;
    }
  .topbar-inner {
      display: flex;
      flex-direction: column;
      justify-content: center;
    }
  .topbar-inner-accounts {
      max-height: 120px;
      overflow: hidden;
    }
  .fab {
      width: auto;
      min-width: 220px;
      max-width: 320px;
    }
  .account-pill-item {
      display: inline-flex;
      width: auto;
      max-width: 220px;
      break-inside: avoid;
    }
  .pill-name {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  .account-pills {
      display: flex;
      flex-flow: column wrap;
      gap: 6px;
      height: 120px;
      overflow: hidden;
    }
  .month-label {
      grid-column: 1/span 10;
      grid-row: 1;
    }
  .budget-section {
      grid-column: 1/span 4;
      grid-row: 2/span 2;
    }
  .donut-wrapper {
      grid-column: 5/span 6;
      grid-row: 2/span 16;
    }
  .total-balance {
      font-size: clamp(2.8rem, 4vw, 3.4rem);
    }
  .categories-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  .donut-container {
      width: 240px;
      height: 240px;
    }
  .donut-center-budget {
      font-size: 1.4rem;
    }
  .tx-chevron {
      font-size: 1.8rem;
    }
  .fab:hover {
      transform: translateX(-50%) translateY(-2px);
      box-shadow: 0 10px 32px rgba(233, 30, 99, .4);
    }
}

/* ── BREAKPOINT ≥1024px */
@media (min-width:1024px) {
  .total-balance {
      font-size: 3.8rem;
    }
  .categories-grid {
      grid-template-columns: repeat(2, 1fr);
      gap: 9px;
    }
  .donut-container {
      width: 260px;
      height: 260px;
    }
}

/* ── SAFE AREA */
@supports (padding-bottom:env(safe-area-inset-bottom)) {
  .fab {
      bottom: calc(64px + env(safe-area-inset-bottom) + 12px);
    }
}
