/* ==========================================================================
   CashFlow PWA — Main CSS Design System & Variables
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Primary Brand Palette */
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.35);

  /* Semantic Financial Colors */
  --income: #10b981;
  --income-bg: rgba(16, 185, 129, 0.12);
  --income-border: rgba(16, 185, 129, 0.3);
  --income-glow: rgba(16, 185, 129, 0.25);

  --expense: #f43f5e;
  --expense-bg: rgba(244, 63, 94, 0.12);
  --expense-border: rgba(244, 63, 94, 0.3);
  --expense-glow: rgba(244, 63, 94, 0.25);

  --payable: #f59e0b;
  --payable-bg: rgba(245, 158, 11, 0.12);
  --payable-border: rgba(245, 158, 11, 0.3);
  --payable-glow: rgba(245, 158, 11, 0.25);

  --receivable: #0ea5e9;
  --receivable-bg: rgba(14, 165, 233, 0.12);
  --receivable-border: rgba(14, 165, 233, 0.3);
  --receivable-glow: rgba(14, 165, 233, 0.25);

  --savings: #14b8a6;
  --savings-bg: rgba(20, 184, 166, 0.12);
  --savings-border: rgba(20, 184, 166, 0.3);
  --savings-glow: rgba(20, 184, 166, 0.25);

  /* Status Colors */
  --status-paid: #10b981;
  --status-partial: #f59e0b;
  --status-pending: #94a3b8;
  --status-overdue: #ef4444;

  /* Surfaces & Backgrounds (Dark Mode First) */
  --bg-app: #090d16;
  --bg-surface-1: #0f172a;
  --bg-surface-2: #1e293b;
  --bg-surface-3: #273549;
  --bg-glass: rgba(15, 23, 42, 0.78);
  --bg-glass-card: rgba(30, 41, 59, 0.65);
  --bg-glass-input: rgba(15, 23, 42, 0.6);

  /* Text & Typography */
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --text-inverse: #090d16;

  /* Borders & Dividers */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-active: rgba(99, 102, 241, 0.5);

  /* Shadows & Glassmorphism */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 25px var(--primary-glow);
  --backdrop-blur: blur(16px);

  /* Spacing */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout Dimensions */
  --sidebar-width: 260px;
  --header-height: 64px;
  --bottom-nav-height: 68px;
}

/* ==========================================================================
   Reset & Base Elements
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* Utility: remove from layout flow entirely (used for tab panes, overlays, etc.) */
.hidden {
  display: none !important;
}

html, body {
  width: 100%;
  min-height: 100%;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  position: relative;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(14, 165, 233, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(16, 185, 129, 0.04) 0%, transparent 60%);
  background-attachment: fixed;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ==========================================================================
   Typography Helpers
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.text-gradient {
  background: linear-gradient(135deg, #fff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-primary-gradient {
  background: linear-gradient(135deg, #a5b4fc 0%, #6366f1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.text-income { color: var(--income); }
.text-expense { color: var(--expense); }
.text-payable { color: var(--payable); }
.text-receivable { color: var(--receivable); }
.text-savings { color: var(--savings); }
.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.font-mono { font-family: var(--font-mono); }

/* ==========================================================================
   Layout Architecture (Desktop Sidebar + Mobile Shell)
   ========================================================================== */

.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

/* Desktop Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface-1);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  backdrop-filter: var(--backdrop-blur);
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.app-logo-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.app-brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.app-brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.sidebar-nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-subtle);
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 12px 10px 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  transition: all var(--transition-fast);
  position: relative;
}

.nav-link:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.nav-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0.04) 100%);
  border-left: 3px solid var(--primary);
  font-weight: 600;
}

.nav-link .icon {
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
}

.nav-badge {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
}

/* Sidebar Footer (Status & Settings) */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cloud-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--income);
  box-shadow: 0 0 8px var(--income-glow);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

/* Main App Shell */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  width: calc(100% - var(--sidebar-width));
}

/* Top App Header */
.app-header {
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: var(--backdrop-blur);
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mobile-menu-btn {
  display: none;
  font-size: 1.4rem;
  padding: 6px;
  border-radius: var(--radius-xs);
}

.page-headline {
  font-size: 1.15rem;
  font-weight: 700;
}

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

/* Content Container */
.content-body {
  flex: 1;
  padding: 24px;
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
}

/* Bottom Navigation Bar (Mobile) */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: var(--backdrop-blur);
  border-top: 1px solid var(--border-subtle);
  z-index: 100;
  padding: 0 10px;
  justify-content: space-around;
  align-items: center;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.mobile-nav-item .icon {
  font-size: 1.35rem;
}

.mobile-nav-item.active {
  color: var(--primary-light);
  transform: translateY(-2px);
}

/* Floating Action Button (FAB) */
.fab-btn {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 16px);
  right: 20px;
  width: 54px;
  height: 54px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: 0 8px 24px var(--primary-glow), var(--shadow-md);
  z-index: 95;
  transition: all var(--transition-bounce);
}

.fab-btn:hover {
  transform: scale(1.08) rotate(90deg);
}

.fab-btn:active {
  transform: scale(0.95);
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.animate-fade-in {
  animation: fadeIn 0.3s ease-out forwards;
}

.animate-slide-up {
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
