/* ============================================================
   LAYOUT — app shell, sidebar, header, content, bottom nav,
             floating action button, auth screen
   ============================================================ */

/* ── App Shell ───────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100dvh;
}

/* ── Sidebar (desktop) ───────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  height: 100dvh;
  position: fixed;
  left: 0;
  top: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: var(--z-nav);
  flex-shrink: 0;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: calc(var(--space-5) + env(safe-area-inset-top, 0px)) var(--space-6) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar__logo {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: var(--text-lg);
  font-weight: var(--fw-extrabold);
  flex-shrink: 0;
}

.sidebar__app-name {
  font-size: var(--text-base);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover           { background: var(--accent-light); color: var(--accent); }
.nav-item.active          { background: var(--accent-light); color: var(--accent); font-weight: var(--fw-semibold); }

.sidebar__footer {
  padding: var(--space-3);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.sidebar__user:hover { background: var(--surface-2); }
.sidebar__user-info { flex: 1; min-width: 0; }
.sidebar__user-name  { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user-email { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Main Wrapper ────────────────────────────────────────── */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── App Header ──────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  background: var(--bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0px) var(--space-6) 0;
  z-index: var(--z-raised);
  flex-shrink: 0;
}

.app-header__title {
  font-size: var(--text-xl);
  font-weight: var(--fw-bold);
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── Main Content Area ───────────────────────────────────── */
.main-content {
  flex: 1;
  padding: var(--space-6);
  width: 100%;
  max-width: var(--content-max-width);
  margin: 0 auto;
  align-self: stretch;
}

/* ── Tab Panels ──────────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active {
  display: block;
  animation: tab-in var(--transition) ease both;
}
@keyframes tab-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Bottom Nav (mobile only — shown via responsive.css) ─── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: var(--z-nav);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav__items {
  display: flex;
  height: var(--bottom-nav-height);
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: color var(--transition-fast);
  user-select: none;
  border: none;
  background: none;
  padding: 0;
}
.bottom-nav__item svg  { width: 22px; height: 22px; }
.bottom-nav__item.active { color: var(--accent); }

/* Centre + button in bottom nav */
.bottom-nav__add {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  user-select: none;
}
.bottom-nav__add-circle {
  width: 46px;
  height: 46px;
  background: var(--accent);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px var(--accent-glow);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  color: #fff;
}
.bottom-nav__add-circle svg { width: 22px; height: 22px; }
.bottom-nav__add:active .bottom-nav__add-circle { transform: scale(0.93); }

/* ── Floating Action Button ──────────────────────────────── */
.fab {
  position: fixed;
  right: var(--space-6);
  bottom: calc(var(--bottom-nav-height) + var(--space-4));
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg), var(--shadow-accent);
  z-index: calc(var(--z-nav) + 1);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  flex-shrink: 0;
}
.fab svg { width: 24px; height: 24px; }
.fab:hover  { background: var(--accent-hover); transform: scale(1.06); }
.fab:active { transform: scale(0.94); }

/* ── Auth Screen ─────────────────────────────────────────── */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: var(--space-6);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  box-shadow: var(--shadow-xl);
}

.auth-card__logo {
  width: 60px;
  height: 60px;
  background: var(--accent);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-2xl);
  font-weight: var(--fw-extrabold);
  color: #fff;
  box-shadow: var(--shadow-accent);
}

.auth-card__heading { font-size: var(--text-2xl); font-weight: var(--fw-extrabold); text-align: center; }
.auth-card__sub     { font-size: var(--text-sm); color: var(--text-secondary); text-align: center; margin-top: calc(-1 * var(--space-2)); }
.auth-card__form    { width: 100%; display: flex; flex-direction: column; gap: var(--space-4); }
.auth-card__footer  { font-size: var(--text-xs); color: var(--text-muted); text-align: center; }

/* ── Loading Screen ──────────────────────────────────────── */
.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 9999;
}

/* ── Transaction list items (Dashboard + Transactions tab) ── */
.tx-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.tx-item:last-child { border-bottom: none; }
.tx-item:active     { background: var(--surface-2); margin: 0 calc(-1 * var(--space-4)); padding-left: var(--space-4); padding-right: var(--space-4); border-radius: var(--radius-md); }

.tx-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  user-select: none;
}

.tx-info  { flex: 1; min-width: 0; }
.tx-name  { font-size: var(--text-sm); font-weight: var(--fw-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-primary); }
.tx-meta  { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

.tx-amount { text-align: right; flex-shrink: 0; }
.tx-total  { font-size: var(--text-sm); font-weight: var(--fw-bold); color: var(--text-primary); }
.tx-split  { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

/* Group date header in the Transactions tab */
.tx-group-header {
  padding: var(--space-3) 0 var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  position: sticky;
  top: var(--header-height);
  background: var(--bg);
  z-index: var(--z-raised);
}

/* ── Editable split dollar amount inputs ─────────────────── */
.split-amt-wrap   { display: flex; align-items: center; gap: 2px; }
.split-amt-prefix { font-size: var(--text-base); font-weight: var(--fw-bold); color: var(--text-muted); }
.split-amt-input  {
  width: 80px;
  font-size: var(--text-base);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--border-strong);
  padding: 2px 4px;
  text-align: right;
  outline: none;
  border-radius: 0;
  -moz-appearance: textfield;
}
.split-amt-input::-webkit-inner-spin-button,
.split-amt-input::-webkit-outer-spin-button { -webkit-appearance: none; }
.split-amt-input:focus { border-bottom-color: var(--accent); }

/* ── Balance tab hero card ───────────────────────────────── */
.balance-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  margin-bottom: var(--space-6);
}
.balance-hero__label  { font-size: var(--text-xs); font-weight: var(--fw-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: var(--space-2); }
.balance-hero__amount { font-size: var(--text-4xl); font-weight: var(--fw-extrabold); line-height: 1.1; margin-bottom: var(--space-2); }
.balance-hero__sub    { font-size: var(--text-sm); color: var(--text-muted); }

.balance-hero--green  { border-top: 4px solid var(--green); }
.balance-hero--green  .balance-hero__amount { color: var(--green); }
.balance-hero--red    { border-top: 4px solid var(--red); }
.balance-hero--red    .balance-hero__amount { color: var(--red); }
.balance-hero--accent { border-top: 4px solid var(--accent); }
.balance-hero--accent .balance-hero__amount { color: var(--accent); }

/* ── Toggle switch (used in Settings) ───────────────────── */
.toggle          { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input    { opacity: 0; width: 0; height: 0; }
.toggle__slider  { position: absolute; inset: 0; background: var(--surface-3); border-radius: var(--radius-full); cursor: pointer; transition: background var(--transition); }
.toggle__slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: var(--radius-full); transition: transform var(--transition); }
.toggle input:checked + .toggle__slider                { background: var(--accent); }
.toggle input:checked + .toggle__slider::before        { transform: translateX(20px); }

/* ── Bulk action bar (slides up when transactions are selected) ── */
.bulk-bar {
  position: fixed;
  bottom: var(--bottom-nav-height);
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 2px solid var(--accent);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  z-index: calc(var(--z-nav) + 2);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
  animation: bulk-in var(--transition) ease both;
}
@keyframes bulk-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
.bulk-bar__count { font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--accent); white-space: nowrap; }
.bulk-bar__actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }

/* Desktop: shift right to clear sidebar */
@media (min-width: 769px) {
  .bulk-bar { left: var(--sidebar-width); bottom: 0; }
}

/* ── Transaction row checkbox (shown in select mode) ────── */
.tx-checkbox {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  background: transparent;
}
.tx-checkbox--checked {
  background: var(--accent);
  border-color: var(--accent);
}
.tx-checkbox--checked::after {
  content: '';
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}
.tx-item--selected { background: var(--accent-light); border-radius: var(--radius-md); }

/* ── Activity feed items ─────────────────────────────────── */
.activity-item { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 34px; height: 34px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 0.95rem; flex-shrink: 0; margin-top: 2px; }
.activity-info { flex: 1; min-width: 0; }
.activity-text { font-size: var(--text-sm); color: var(--text-primary); line-height: 1.4; }
.activity-text strong { font-weight: var(--fw-semibold); }
.activity-time { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

/* ── CSV import preview rows ─────────────────────────────── */
.import-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.import-row:last-child { border-bottom: none; }
.import-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.import-info { flex: 1; min-width: 0; }
.import-desc { font-size: var(--text-sm); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.import-meta { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.import-selects { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
