/* ============================================================
   DASHBOARD STYLES
   ============================================================ */

/* --- APP SHELL --- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* --- SIDEBAR --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-inline-end: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  height: 100vh;
  z-index: 50;
  transition: transform var(--transition);
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 0 12px rgba(124,58,237,0.4);
}

.sidebar-logo-text {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.sidebar-logo-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-latin);
}

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

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: var(--space-sm) var(--space-sm) 4px;
  margin-top: var(--space-sm);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--space-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-glass-light);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(124,58,237,0.08));
  color: var(--primary-light);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

[dir="ltr"] .nav-item.active::before {
  border-radius: 3px 0 0 3px;
}

.nav-icon {
  font-size: 1.1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-inline-start: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}
.sidebar-user:hover { background: var(--bg-card); }

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

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-username {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-plan {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.sidebar-plan.pro { color: var(--accent); }

/* --- MAIN CONTENT --- */
.main-content {
  margin-inline-start: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- TOP HEADER --- */
.top-header {
  height: var(--header-height);
  background: rgba(10, 10, 20, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.page-title-area h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.page-breadcrumb {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Logout button – clear & visible */
.logout-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 77, 109, 0.3);
  background: rgba(255, 77, 109, 0.07);
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.logout-btn:hover {
  background: rgba(255, 77, 109, 0.18);
  border-color: var(--danger);
  transform: translateY(-1px);
}

.logout-btn svg {
  flex-shrink: 0;
}

.hamburger {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: none;
}

/* --- PAGE CONTENT --- */
.page-content {
  flex: 1;
  padding: var(--space-xl);
  max-width: 1400px;
  width: 100%;
}

/* --- OVERVIEW STATS --- */
.overview-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--card-accent, var(--primary));
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.stat-change {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.stat-change.up { background: var(--success-bg); color: var(--success); }
.stat-change.down { background: var(--danger-bg); color: var(--danger); }

.stat-amount {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-latin);
  margin-bottom: 2px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* --- CHARTS ROW --- */
.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  align-items: start;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  overflow: hidden;
}

/* Fix canvas height inside chart cards */
.chart-card canvas {
  display: block;
  width: 100% !important;
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.chart-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.chart-filter {
  display: flex;
  gap: 4px;
  background: var(--bg-surface);
  border-radius: var(--radius-full);
  padding: 3px;
}

.chart-filter-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.chart-filter-btn.active {
  background: var(--primary);
  color: #fff;
}

/* Legend */
.chart-legend {
  display: flex;
  gap: var(--space-lg);
  margin-top: var(--space-md);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Donut chart legend */
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: var(--space-md);
}

.donut-legend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
}

.donut-legend-left {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.donut-legend-bar {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.donut-legend-value {
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-latin);
}

/* --- RECENT TRANSACTIONS --- */
.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}

.section-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.transaction-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  transition: var(--transition);
  cursor: pointer;
}
.transaction-item:hover { background: var(--bg-card-hover); }

.tx-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.tx-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.tx-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.tx-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 6px;
  align-items: center;
}

.tx-amount {
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-latin);
}

/* --- SAVINGS WIDGET --- */
.savings-card {
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(245,200,66,0.06));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.savings-goal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.savings-progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* --- ADD TRANSACTION FORM --- */
.quick-add {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.type-toggle {
  display: flex;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
  margin-bottom: var(--space-md);
}

.type-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition);
  font-family: inherit;
}

.type-btn.income.active {
  background: var(--success-bg);
  color: var(--success);
}

.type-btn.expense.active {
  background: var(--danger-bg);
  color: var(--danger);
}

/* --- DEBT CARDS --- */
.debt-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: var(--transition);
}

.debt-card:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.debt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.debt-person {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.debt-direction {
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.debt-owed-by-me { background: var(--danger-bg); color: var(--danger); }
.debt-owed-to-me { background: var(--success-bg); color: var(--success); }

.debt-amounts {
  display: flex;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.debt-amount-item { flex: 1; }
.debt-amount-label { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 2px; }
.debt-amount-value { font-size: 1.1rem; font-weight: 700; font-family: var(--font-latin); }

/* --- SUBSCRIPTION LOCK --- */
.feature-locked {
  position: relative;
  filter: blur(4px);
  pointer-events: none;
  user-select: none;
}

.lock-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 20, 0.7);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  z-index: 10;
  text-align: center;
  padding: var(--space-lg);
  pointer-events: all;
  filter: none;
}

.lock-icon { font-size: 2.5rem; }

/* --- SUBSCRIPTION PAGE --- */
.subscription-page {
  padding: var(--space-xl);
  max-width: 900px;
  margin: 0 auto;
}

.current-plan-card {
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(245,200,66,0.05));
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.plan-status {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* --- MOBILE SIDEBAR OVERLAY --- */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 49;
  display: none;
}

@media (max-width: 1024px) {
  .overview-cards { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(100%);
  }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .sidebar-overlay.visible { display: block; }

  .main-content { margin-inline-start: 0; }

  .top-header { padding: 0 var(--space-md); }

  .hamburger { display: flex; }

  .overview-cards { grid-template-columns: 1fr 1fr; }

  .page-content { padding: var(--space-md); }
}

@media (max-width: 480px) {
  .overview-cards { grid-template-columns: 1fr; }
  .stat-amount { font-size: 1.4rem; }
  .logout-btn span { display: none; }
  .logout-btn { padding: 7px 10px; }
}
