/* ─── BudgetApp – Custom Styles ─────────────────────────────────────────────
   Mobile-first design. Bootstrap 5 handles the base grid.
   Touch targets: min 44×44px on all interactive elements.
─────────────────────────────────────────────────────────────────────────────── */

/* ─── Custom Properties ──────────────────────────────────────────────────── */
:root {
  --sidebar-width: 220px;
  --bottom-nav-height: 60px;
  --fab-size: 52px;
  --fab-bottom: calc(var(--bottom-nav-height) + 16px);
  --shadow-card: 0 1px 4px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.06);
  --radius-card: .75rem;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */

html, body {
  height: 100%;
}

body {
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}

/* Page wrapper: full height flex row (sidebar + content) */
.page-wrapper {
  min-height: calc(100vh - 56px); /* minus navbar */
}

/* ─── Sidebar (desktop only) ─────────────────────────────────────────────── */

#sidebar {
  width: var(--sidebar-width);
  min-height: 100%;
  position: sticky;
  top: 56px; /* navbar height */
  max-height: calc(100vh - 56px);
  overflow-y: auto;
}

.sidebar-item {
  color: #555;
  font-weight: 500;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
  min-height: 52px;
}

.sidebar-item:hover {
  background: #f0f4ff;
  color: var(--bs-primary);
}

.sidebar-item.active {
  background: #e8f0fe;
  color: var(--bs-primary);
  border-left-color: var(--bs-primary);
  font-weight: 600;
}

/* ─── Content area ───────────────────────────────────────────────────────── */

.content-area {
  min-width: 0; /* prevent overflow in flex */
}

.main-content {
  padding-top: .5rem;
}

/* Extra bottom padding when bottom nav is present */
.has-bottom-nav {
  padding-bottom: calc(var(--bottom-nav-height) + var(--fab-size) + 1.5rem) !important;
}

/* ─── Bottom Navigation ──────────────────────────────────────────────────── */

.bottom-nav {
  height: var(--bottom-nav-height);
  z-index: 1030;
}

.bottom-nav-item {
  color: #888;
  font-size: .6rem;
  font-weight: 500;
  transition: color .15s;
  min-width: 0;
  position: relative;
}

.bottom-nav-item.active {
  color: var(--bs-primary);
}

.bottom-nav-item .bi {
  font-size: 1.35rem;
  display: block;
}

.bottom-nav-label {
  display: block;
  font-size: .6rem;
  margin-top: 1px;
}

/* ─── FAB Button ─────────────────────────────────────────────────────────── */

.fab-btn {
  position: fixed;
  right: 20px;
  bottom: var(--fab-bottom);
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  background: var(--bs-primary);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(25,118,210,.45);
  transition: transform .15s, box-shadow .15s;
  z-index: 1031;
}

.fab-btn:hover, .fab-btn:focus {
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(25,118,210,.55);
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */

.card {
  border-radius: var(--radius-card) !important;
  box-shadow: var(--shadow-card);
}

/* ─── Category icon badge ────────────────────────────────────────────────── */

.cat-icon-badge {
  flex-shrink: 0;
}

/* ─── Transaction type toggle ────────────────────────────────────────────── */

.type-toggle .btn {
  min-height: 48px;
  font-size: 1rem;
}

/* ─── Category selection grid ────────────────────────────────────────────── */

.cat-select-btn {
  min-height: 64px;
  transition: background .15s, border-color .15s;
  border-color: #dde1e7;
  background: #fff;
  font-size: .72rem;
}

.cat-select-btn:hover {
  background: #f0f4ff;
  border-color: var(--bs-primary);
}

.btn-check:checked + .cat-select-btn {
  background: color-mix(in srgb, var(--cat-color, var(--bs-primary)) 12%, #fff);
  border-color: var(--cat-color, var(--bs-primary));
  border-width: 2px;
}

/* ─── Icon picker ────────────────────────────────────────────────────────── */

.icon-picker-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-picker-btn.active {
  background: var(--bs-primary);
  color: #fff;
  border-color: var(--bs-primary);
}

/* ─── Preset color dots ──────────────────────────────────────────────────── */

.color-dot {
  transition: transform .1s, outline .1s;
  outline: 2px solid transparent;
  outline-offset: 2px;
}

.color-dot:hover, .color-dot:focus {
  transform: scale(1.2);
  outline-color: #666;
}

/* ─── Auth pages ─────────────────────────────────────────────────────────── */

.auth-page {
  background: linear-gradient(135deg, #e8f0fe 0%, #f8f9fa 100%);
}

.auth-card {
  border-radius: 1.25rem !important;
}

/* ─── Touch target enforcement ───────────────────────────────────────────── */

.btn, .form-control, .form-select, a.list-group-item,
.nav-link, .bottom-nav-item, .sidebar-item {
  min-height: 44px;
}

.btn-sm {
  min-height: 36px; /* slightly smaller for compact contexts */
}

/* ─── Utilities ──────────────────────────────────────────────────────────── */

.min-width-0 {
  min-width: 0;
}

.font-monospace {
  font-family: 'Courier New', monospace;
  font-size: .82rem;
}

/* ─── Progress bars ──────────────────────────────────────────────────────── */

.progress {
  border-radius: 99px;
}

/* ─── Transaction date label ─────────────────────────────────────────────── */

.tx-date-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ─── Swipe-to-delete ────────────────────────────────────────────────────── */

.tx-card.swipeable {
  position: relative;
  overflow: hidden;
}

.tx-card .swipe-bg {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}

.tx-card.swiping .swipe-bg {
  opacity: 1;
}

.tx-card .card-body {
  transition: transform .2s ease;
  background: var(--bs-body-bg, #fff);
  position: relative;
  z-index: 1;
}

/* ─── Dark Mode ──────────────────────────────────────────────────────────── */
/* Bootstrap 5.3 handles most dark mode via data-bs-theme="dark".
   We only override our custom components and fix specifics. */

[data-bs-theme="dark"] .bg-light {
  background-color: var(--bs-body-bg) !important;
}

[data-bs-theme="dark"] .card {
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

[data-bs-theme="dark"] .card-header.bg-white {
  background-color: var(--bs-tertiary-bg) !important;
}

[data-bs-theme="dark"] #sidebar {
  background-color: var(--bs-tertiary-bg) !important;
  border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .sidebar-item {
  color: var(--bs-body-color);
}

[data-bs-theme="dark"] .sidebar-item:hover {
  background: var(--bs-tertiary-bg);
  color: #82b1ff;
}

[data-bs-theme="dark"] .sidebar-item.active {
  background: rgba(130,177,255,.1);
  color: #82b1ff;
  border-left-color: #82b1ff;
}

[data-bs-theme="dark"] .bottom-nav {
  background-color: var(--bs-tertiary-bg) !important;
  border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .bottom-nav-item.active {
  color: #82b1ff;
}

[data-bs-theme="dark"] .progress {
  background-color: var(--bs-secondary-bg);
}

[data-bs-theme="dark"] .fab-btn {
  background: #5c9cff;
  box-shadow: 0 4px 12px rgba(92,156,255,.35);
}

[data-bs-theme="dark"] .tx-card .card-body {
  background: var(--bs-body-bg);
}

[data-bs-theme="dark"] .cat-icon-badge {
  opacity: .9;
}

/* ─── Responsive adjustments ─────────────────────────────────────────────── */

/* On mobile, reduce horizontal padding of page content */
@media (max-width: 575.98px) {
  .container-fluid {
    padding-left: .75rem !important;
    padding-right: .75rem !important;
  }
}

/* On desktop (md+): no bottom nav/FAB padding, sidebar visible */
@media (min-width: 768px) {
  .has-bottom-nav {
    padding-bottom: 1.5rem !important;
  }
}
