/* =============================================
   Boom's Financial — Modern UI
   ============================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f4f6fb;
  --surface:   #ffffff;
  --surface2:  #f0f2f8;
  --border:    #e4e7f0;
  --primary:   #6c63ff;
  --primary-light: #8b85ff;
  --income:    #16a34a;
  --expense:   #e11d48;
  --text:      #1a1d2e;
  --text-2:    #64687d;
  --text-3:    #a0a3b1;
  --radius:    16px;
  --radius-sm: 10px;
}

body {
  font-family: 'Quicksand', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  padding: 24px 16px;
  z-index: 50;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  margin-bottom: 32px;
}

.logo-icon {
  font-size: 24px;
  line-height: 1;
}

.logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  padding: 0 12px;
  margin-bottom: 6px;
}

.sidebar ul { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}
.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active {
  background: linear-gradient(135deg, #6c63ff22, #a78bfa11);
  color: var(--primary-light);
  border: 1px solid #6c63ff33;
}
.nav-icon { display: flex; align-items: center; opacity: 0.8; }
.nav-link.active .nav-icon { opacity: 1; }

.sidebar-footer { margin-top: auto; }

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--primary), #a78bfa);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  flex-shrink: 0;
}

.user-name { display: block; font-size: 13px; font-weight: 600; color: var(--text); }
.user-sub  { display: block; font-size: 11px; color: var(--text-3); }

/* =============================================
   MAIN CONTENT
   ============================================= */
.main {
  margin-left: 240px;
  flex: 1;
  padding: 32px 40px;
  max-width: 1200px;
}

.page { display: none; }
.page.active { display: block; }

.page-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

.page-sub {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 2px;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* =============================================
   MONTH NAV
   ============================================= */
.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}

.month-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  min-width: 110px;
  text-align: center;
}

.month-btn {
  background: none;
  border: none;
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.month-btn:hover { color: var(--text); background: var(--surface2); }

/* =============================================
   HERO CARD (Dashboard)
   ============================================= */
.hero-card {
  background: linear-gradient(135deg, #6c63ff, #a78bfa);
  border-radius: 20px;
  padding: 28px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: rgba(255,255,255,0.07);
  border-radius: 50%;
}
.hero-card::after {
  content: '';
  position: absolute;
  bottom: -80px; right: 80px;
  width: 250px; height: 250px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}

.hero-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.7);
  margin-bottom: 6px;
}

.hero-amount {
  font-size: 40px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -1px;
  line-height: 1;
}

.hero-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  margin-top: 6px;
}

.hero-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 1;
}

.hero-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 12px 16px;
  backdrop-filter: blur(10px);
  min-width: 180px;
}

.hero-stat-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.income-icon  { background: rgba(34,197,94,0.3); color: #86efac; }
.expense-icon { background: rgba(244,63,94,0.3);  color: #fda4af; }

.hero-stat-label { font-size: 11px; color: rgba(255,255,255,0.65); font-weight: 500; }
.hero-stat-value { font-size: 16px; font-weight: 700; color: #fff; }

/* =============================================
   CHARTS
   ============================================= */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 20px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.chart-card-header {
  margin-bottom: 20px;
}
.chart-card-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.chart-wrap { position: relative; min-height: 220px; display: flex; align-items: center; justify-content: center; }
.donut-wrap canvas { max-height: 220px; }

.chart-empty {
  display: none;
  font-size: 13px;
  color: var(--text-3);
  position: absolute;
}

/* =============================================
   TRANSACTIONS LIST
   ============================================= */
.tx-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tx-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: border-color 0.15s;
  animation: fadeIn 0.2s ease;
}
.tx-item:hover { border-color: var(--primary); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tx-cat-icon {
  width: 40px; height: 40px;
  background: var(--surface2);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.tx-info { flex: 1; min-width: 0; }
.tx-name  { font-size: 14px; font-weight: 600; color: var(--text); }
.tx-meta  { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.tx-right { text-align: right; flex-shrink: 0; }
.tx-amount { font-size: 15px; font-weight: 700; }
.tx-amount.income  { color: var(--income); }
.tx-amount.expense { color: var(--expense); }
.tx-date-sm { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.tx-delete {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
  opacity: 0;
}
.tx-item:hover .tx-delete { opacity: 1; }
.tx-delete:hover { color: var(--expense); background: #f43f5e18; }

.tx-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.tx-empty p { font-size: 15px; margin-bottom: 6px; color: var(--text-2); }
.tx-empty span { font-size: 13px; }

/* =============================================
   ACCOUNTS
   ============================================= */
.accounts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.account-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
  animation: fadeIn 0.2s ease;
}
.account-card:hover { border-color: var(--primary); transform: translateY(-2px); }

.account-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.account-card.bank::before        { background: linear-gradient(90deg, #6c63ff, #a78bfa); }
.account-card.credit_card::before { background: linear-gradient(90deg, #f43f5e, #fb7185); }
.account-card.cash::before        { background: linear-gradient(90deg, #22c55e, #4ade80); }
.account-card.investment::before  { background: linear-gradient(90deg, #f59e0b, #fbbf24); }

.account-type-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 12px;
}

.account-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

.account-balance {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}

/* =============================================
   BUDGETS
   ============================================= */
.budget-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.budget-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  animation: fadeIn 0.2s ease;
}

.budget-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.budget-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.budget-amounts {
  font-size: 13px;
  color: var(--text-2);
}
.budget-amounts strong { color: var(--text); }

.budget-bar-bg {
  background: var(--surface2);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}

.budget-bar-fill {
  height: 8px;
  border-radius: 99px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}
.budget-bar-fill.ok   { background: linear-gradient(90deg, #22c55e, #4ade80); }
.budget-bar-fill.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.budget-bar-fill.over { background: linear-gradient(90deg, #f43f5e, #fb7185); }

.budget-footer {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-3);
}

.budget-pct.ok   { color: var(--income); }
.budget-pct.warn { color: #f59e0b; }
.budget-pct.over { color: var(--expense); }

.budgets-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}

/* =============================================
   BUTTONS
   ============================================= */
.btn-primary {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Quicksand', sans-serif;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary:hover  { background: var(--primary-light); }
.btn-primary:active { transform: scale(0.97); }

/* =============================================
   MODALS
   ============================================= */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal.open { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  width: 460px;
  max-width: 95vw;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  animation: slideUp 0.2s cubic-bezier(0.4,0,0.2,1);
}

@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 17px; font-weight: 700; color: var(--text); }

.modal-close {
  background: var(--surface2);
  border: none;
  color: var(--text-2);
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--border); color: var(--text); }

/* Type toggle */
.type-toggle {
  display: flex;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
  gap: 4px;
}
.toggle-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-2);
  padding: 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Quicksand', sans-serif;
  transition: all 0.15s;
}
.toggle-btn.active {
  background: var(--primary);
  color: #fff;
}

/* Form fields */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.optional {
  text-transform: none;
  font-weight: 400;
  color: var(--text-3);
  letter-spacing: 0;
}

.form-group input,
.form-group select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: 'Quicksand', sans-serif;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--primary); }
.form-group input::placeholder { color: var(--text-3); }

/* Label action button (e.g. "Manage" next to Category) */
.label-action-btn {
  background: none;
  border: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  font-family: 'Quicksand', sans-serif;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background 0.15s;
  text-transform: none;
  letter-spacing: 0;
}
.label-action-btn:hover { background: #6c63ff18; }

/* Wide modal for categories */
.modal-box-wide { width: 540px; }

/* Add category form row */
.cat-add-form { margin-bottom: 16px; }
.cat-form-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.cat-icon-input {
  width: 52px !important;
  text-align: center;
  font-size: 18px;
  flex-shrink: 0;
}
.cat-form-row input[type="text"]:not(.cat-icon-input) { flex: 1; }
.cat-form-row select { width: 110px; flex-shrink: 0; }
.cat-form-row .btn-primary { flex-shrink: 0; }

/* Tabs */
.cat-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 14px;
}
.cat-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 7px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: 'Quicksand', sans-serif;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}
.cat-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.08); }

/* Category list */
.cat-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.cat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  animation: fadeIn 0.15s ease;
}
.cat-item-icon { font-size: 20px; flex-shrink: 0; }
.cat-item-name { flex: 1; font-size: 14px; font-weight: 600; color: var(--text); }
.cat-item-actions { display: flex; gap: 6px; }

.cat-edit-btn, .cat-delete-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Quicksand', sans-serif;
  cursor: pointer;
  transition: all 0.15s;
}
.cat-edit-btn   { color: var(--primary); }
.cat-edit-btn:hover { background: #6c63ff12; border-color: var(--primary); }
.cat-delete-btn { color: var(--expense); }
.cat-delete-btn:hover { background: #e11d4812; border-color: var(--expense); }

/* Image upload */
.image-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-3);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 13px;
}
.image-upload-area:hover {
  border-color: var(--primary);
  background: #6c63ff08;
  color: var(--primary);
}

.image-preview-img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: 10px;
  border: 1px solid var(--border);
}

.image-remove-btn {
  margin-top: 8px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--expense);
  cursor: pointer;
  font-family: 'Quicksand', sans-serif;
  font-weight: 600;
  transition: background 0.15s;
}
.image-remove-btn:hover { background: #e11d4811; }

/* Receipt thumbnail in transaction list */
.tx-receipt {
  width: 36px; height: 36px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.tx-receipt:hover { transform: scale(1.08); }

/* Full-size image lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 300;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}

.btn-submit {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Quicksand', sans-serif;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s, transform 0.1s;
  letter-spacing: 0.02em;
}
.btn-submit:hover  { background: var(--primary-light); }
.btn-submit:active { transform: scale(0.98); }

/* =============================================
   TOAST
   ============================================= */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #22c55e;
  color: #fff;
  padding: 12px 24px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  z-index: 999;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =============================================
   SCROLLBAR
   ============================================= */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* =============================================
   BOTTOM NAV (mobile only — hidden on desktop)
   ============================================= */
.bottom-nav { display: none; }

/* =============================================
   DESKTOP (>= 768px) — sidebar layout
   ============================================= */
@media (min-width: 768px) {
  .bottom-nav { display: none; }
}

/* =============================================
   MOBILE (< 768px) — bottom nav layout
   ============================================= */
@media (max-width: 767px) {
  /* Hide sidebar entirely */
  .sidebar { display: none; }

  /* Full-width main, no left margin, padding for bottom nav */
  .main {
    margin-left: 0;
    padding: 20px 16px 90px;
    max-width: 100%;
  }

  /* Show bottom nav */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 8px 0 env(safe-area-inset-bottom, 8px);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 4px;
    color: var(--text-3);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    transition: color 0.15s;
  }

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

  /* Page header stacks vertically */
  .page-top {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
  }

  .top-right {
    width: 100%;
    justify-content: space-between;
  }

  /* Hero card stacks */
  .hero-card {
    flex-direction: column;
    gap: 16px;
    padding: 22px 20px;
  }

  .hero-amount { font-size: 32px; }

  .hero-right {
    width: 100%;
    flex-direction: row;
    gap: 10px;
  }

  .hero-stat { flex: 1; padding: 10px 12px; }

  /* Charts stack */
  .charts-grid { grid-template-columns: 1fr; }

  /* Accounts stack */
  .accounts-grid { grid-template-columns: 1fr; }

  /* Form rows stack */
  .form-row { grid-template-columns: 1fr; }

  /* Month nav compact */
  .month-label { min-width: 90px; font-size: 12px; }

  /* Table-like tx items stay compact */
  .tx-item { padding: 12px 14px; }

  /* Modal full-width on small screens */
  .modal-box {
    width: 100%;
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
  }

  .modal {
    align-items: flex-end;
  }
}
