/* ============================================================
   FINZY BUDGET — DESIGN SYSTEM
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* ─── CSS CUSTOM PROPERTIES ─────────────────────────────── */
:root {
  /* Brand Colors */
  --color-primary:        #00C48C;
  --color-primary-dark:   #00A876;
  --color-primary-light:  #E6FAF4;
  --color-primary-glow:   rgba(0, 196, 140, 0.25);

  /* Neutrals */
  --color-black:          #0A0A0A;
  --color-white:          #FFFFFF;
  --color-bg:             #F8F9FA;
  --color-surface:        #FFFFFF;
  --color-border:         #E5E7EB;
  --color-border-light:   #F3F4F6;

  /* Text */
  --color-text-primary:   #0A0A0A;
  --color-text-secondary: #6B7280;
  --color-text-tertiary:  #9CA3AF;
  --color-text-inverted:  #FFFFFF;

  /* Semantic */
  --color-success:        #00C48C;
  --color-success-bg:     #E6FAF4;
  --color-danger:         #EF4444;
  --color-danger-bg:      #FEF2F2;
  --color-warning:        #F59E0B;
  --color-warning-bg:     #FFFBEB;
  --color-info:           #3B82F6;
  --color-info-bg:        #EFF6FF;

  /* Hero card */
  --color-hero-bg:        #111827;
  --color-hero-text:      #FFFFFF;
  --color-hero-sub:       rgba(255,255,255,0.6);

  /* Sidebar */
  --sidebar-bg:           #0A0A0A;
  --sidebar-width:        230px;
  --sidebar-text:         rgba(255,255,255,0.65);
  --sidebar-text-active:  #FFFFFF;
  --sidebar-icon:         rgba(255,255,255,0.4);
  --sidebar-hover-bg:     rgba(255,255,255,0.06);
  --sidebar-active-bg:    rgba(255,255,255,0.12);

  /* Category Colors */
  --cat-alimentation:     #F59E0B;
  --cat-transport:        #3B82F6;
  --cat-logement:         #8B5CF6;
  --cat-sante:            #EF4444;
  --cat-loisirs:          #EC4899;
  --cat-shopping:         #F97316;
  --cat-education:        #06B6D4;
  --cat-revenus:          #00C48C;
  --cat-epargne:          #10B981;
  --cat-autres:           #6B7280;

  /* Spacing Scale */
  --space-1:    4px;
  --space-2:    8px;
  --space-3:    12px;
  --space-4:    16px;
  --space-5:    20px;
  --space-6:    24px;
  --space-8:    32px;
  --space-10:   40px;
  --space-12:   48px;
  --space-16:   64px;

  /* Typography */
  --font-family:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-xs:        11px;
  --font-sm:        13px;
  --font-base:      15px;
  --font-md:        16px;
  --font-lg:        18px;
  --font-xl:        20px;
  --font-2xl:       24px;
  --font-3xl:       30px;
  --font-4xl:       36px;
  --font-5xl:       48px;

  /* Border Radius */
  --radius-sm:    6px;
  --radius-md:    10px;
  --radius-lg:    16px;
  --radius-xl:    20px;
  --radius-2xl:   24px;
  --radius-full:  9999px;

  /* Shadows */
  --shadow-xs:    0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:    0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg:    0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-xl:    0 20px 25px -5px rgba(0,0,0,0.10), 0 10px 10px -5px rgba(0,0,0,0.04);
  --shadow-2xl:   0 25px 50px -12px rgba(0,0,0,0.18);
  --shadow-card:  0 2px 12px rgba(0,0,0,0.06);
  --shadow-green: 0 8px 24px rgba(0,196,140,0.25);

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-base:   250ms ease;
  --transition-slow:   400ms ease;

  /* Z-index */
  --z-sidebar:    100;
  --z-header:     90;
  --z-modal:      200;
  --z-toast:      300;
  --z-tooltip:    400;
}

/* ─── RESET & BASE ───────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-base);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img, video { max-width: 100%; height: auto; display: block; }
a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
h1,h2,h3,h4,h5,h6 { font-weight: 700; line-height: 1.2; }

/* ─── CUSTOM SCROLLBAR ───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-tertiary); }

/* Sidebar scrollbar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }

/* ─── APP LAYOUT ─────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  background: var(--color-bg);
  overflow-x: hidden;
}

.page-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-8);
}

/* ─── SIDEBAR ────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-5);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: var(--font-lg);
  color: var(--color-white);
  flex-shrink: 0;
  letter-spacing: -0.5px;
}

.logo-text {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--color-white);
  line-height: 1;
}

.logo-text small {
  display: block;
  font-size: var(--font-xs);
  font-weight: 400;
  color: var(--sidebar-text);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.25);
  padding: var(--space-4) var(--space-3) var(--space-2);
  margin-top: var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: var(--font-sm);
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
}

.nav-item:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-active);
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--color-primary);
  border-radius: 0 3px 3px 0;
}

.nav-item svg, .nav-item .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.7;
  flex-shrink: 0;
  transition: opacity var(--transition-fast);
}

.nav-item.active svg, .nav-item.active .nav-icon { opacity: 1; }
.nav-item:hover svg, .nav-item:hover .nav-icon { opacity: 1; }

.sidebar-bottom {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.premium-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: 11px var(--space-4);
  background: var(--color-primary);
  color: var(--color-white);
  border-radius: var(--radius-full);
  font-size: var(--font-sm);
  font-weight: 600;
  transition: all var(--transition-fast);
  margin-bottom: var(--space-4);
}

.premium-btn:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-green);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-1);
}

.user-avatar {
  width: 34px;
  height: 34px;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-sm);
  font-weight: 700;
  color: var(--color-white);
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 11px;
  color: var(--sidebar-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.logout-btn:hover {
  color: var(--color-danger);
  background: rgba(239,68,68,0.1);
}

/* ─── PAGE HEADER ────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.page-label {
  font-size: var(--font-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-1);
}

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

.page-date {
  font-size: var(--font-sm);
  color: var(--color-text-secondary);
  text-align: right;
}

/* ─── GRID UTILITIES ─────────────────────────────────────── */
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); gap: var(--space-5); }
.grid-3 { grid-template-columns: repeat(3, 1fr); gap: var(--space-5); }
.grid-4 { grid-template-columns: repeat(4, 1fr); gap: var(--space-5); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); }
.gap-6 { gap: var(--space-6); }
.flex-1 { flex: 1; }
.w-full { width: 100%; }

/* Text utilities */
.text-xs     { font-size: var(--font-xs); }
.text-sm     { font-size: var(--font-sm); }
.text-base   { font-size: var(--font-base); }
.text-lg     { font-size: var(--font-lg); }
.text-xl     { font-size: var(--font-xl); }
.text-2xl    { font-size: var(--font-2xl); }
.text-3xl    { font-size: var(--font-3xl); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold   { font-weight: 700; }
.font-black  { font-weight: 900; }
.text-secondary { color: var(--color-text-secondary); }
.text-primary-color { color: var(--color-primary); }
.text-danger  { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.uppercase   { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.05em; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Spacing utilities */
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-auto { margin-top: auto; }

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  :root { --sidebar-width: 200px; }
  .page-container { padding: var(--space-6); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--transition-base); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .page-container { padding: var(--space-4); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
  .page-title { font-size: var(--font-2xl); }
}

/* ============================================================
   COMPREHENSIVE RESPONSIVE — MOBILE-FIRST ENHANCEMENTS
   ============================================================ */

/* ─── MOBILE HAMBURGER BUTTON ────────────────────────────── */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1001;
  width: 44px;
  height: 44px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--color-text-primary);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
}

.mobile-menu-btn:hover {
  background: var(--color-bg);
  box-shadow: var(--shadow-lg);
}

/* ─── SIDEBAR OVERLAY (mobile backdrop) ──────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

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

/* ─── TABLET BREAKPOINT (768px – 900px) ──────────────────── */
@media (max-width: 900px) {
  .mobile-menu-btn {
    display: flex;
  }

  .sidebar {
    position: fixed;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: var(--sidebar-width);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
    width: 100%;
  }

  .page-container {
    padding: var(--space-6) !important;
  }

  .page-header {
    padding-top: 52px;
  }
}

/* ─── MOBILE BREAKPOINT (≤768px) ─────────────────────────── */
@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }

  .sidebar {
    position: fixed;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
    width: 100%;
  }

  .page-container {
    padding: var(--space-4) !important;
  }

  .page-header {
    flex-direction: column;
    gap: var(--space-3);
    align-items: flex-start;
    padding-top: 60px;
  }

  .page-date {
    text-align: left;
  }

  /* Grids → single column */
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr !important;
  }

  /* Hero card */
  .hero-card-body {
    padding: var(--space-5);
  }

  .hero-amount {
    font-size: 30px;
    letter-spacing: -1px;
  }

  .card-hero {
    flex-direction: column;
  }

  .hero-stats {
    flex-direction: column;
    gap: var(--space-3);
  }

  /* Forms — touch-friendly sizes */
  .form-control,
  .form-select,
  select.form-control {
    min-height: 48px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  /* Modals → full screen on mobile */
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0 !important;
    margin: 0;
  }

  .modal-overlay {
    align-items: stretch;
    padding: 0;
  }

  .modal-body {
    flex: 1;
    overflow-y: auto;
  }

  /* Stat cards */
  .stat-card {
    padding: var(--space-3) var(--space-4);
  }

  .stat-value {
    font-size: var(--font-xl);
  }

  /* Transaction rows */
  .tx-row {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  /* Account cards */
  .acc-card {
    padding: var(--space-4);
  }

  .acc-actions {
    flex-wrap: wrap;
  }

  .acc-action-btn {
    flex: 1;
    min-width: 80px;
  }

  /* Recurring */
  .rec-layout {
    grid-template-columns: 1fr !important;
  }

  .rec-item {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .rec-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* Budget items */
  .budget-item-header {
    flex-direction: column;
    gap: var(--space-2);
    align-items: flex-start;
  }

  /* Buttons — touch-friendly */
  .btn {
    min-height: 44px;
  }

  .btn-sm {
    min-height: 36px;
  }

  /* Table scroll */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Dashboard hero */
  .dashboard-hero {
    grid-template-columns: 1fr !important;
  }

  /* Toast on mobile */
  .toast-container {
    left: var(--space-3);
    right: var(--space-3);
    max-width: 100%;
  }

  /* Auth pages */
  .auth-layout {
    flex-direction: column;
  }
}

/* ─── SMALL MOBILE BREAKPOINT (≤480px) ───────────────────── */
@media (max-width: 480px) {
  .page-title {
    font-size: var(--font-xl) !important;
  }

  .page-label {
    font-size: 10px;
  }

  .stat-card {
    padding: var(--space-3);
  }

  .card-header {
    padding: var(--space-3) var(--space-4);
  }

  .card-body {
    padding: var(--space-3) var(--space-4);
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--space-4);
  }

  /* Goal cards */
  .goal-card {
    padding: var(--space-3);
  }

  .goal-actions {
    flex-direction: column;
  }

  .goal-actions .btn {
    width: 100%;
  }

  /* Pricing on mobile */
  .pricing-amount {
    font-size: 36px;
  }

  /* Hero card extra small */
  .hero-amount {
    font-size: 26px;
  }

  .hero-actions-row {
    flex-direction: column;
    gap: var(--space-2);
  }

  .hero-actions-row .btn-hero {
    width: 100%;
    justify-content: center;
  }

  /* Sidebar bottom user area */
  .user-email {
    display: none;
  }

  /* Settings sections */
  .settings-section {
    padding: var(--space-4);
  }
}

/* ─── LANDSCAPE PHONE ────────────────────────────────────── */
@media (max-height: 500px) and (orientation: landscape) {
  .modal {
    height: 100vh;
    max-height: 100vh;
  }

  .page-header {
    padding-top: 52px;
  }
}

/* ─── PRINT ──────────────────────────────────────────────── */
@media print {
  .sidebar,
  .mobile-menu-btn,
  .sidebar-overlay,
  .toast-container {
    display: none !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .page-container {
    padding: 0 !important;
  }
}

/* ─── GLOBAL UX POLISH ───────────────────────────────────── */

/* Smooth transitions on interactive elements globally */
a, button, .btn, .nav-item, .card, .badge, select, input, textarea {
  transition-property: color, background-color, border-color, box-shadow, opacity, transform;
  transition-timing-function: ease;
  transition-duration: 150ms;
}

/* Sidebar nav items — smooth active indicator */
.nav-item {
  border-radius: var(--radius-md);
  transition: all 180ms ease;
}

/* Card subtle lift on hover */
.card:not(.card-hero):not(.card-hover) {
  transition: box-shadow 200ms ease, border-color 200ms ease;
}
.card:not(.card-hero):not(.card-hover):hover {
  box-shadow: 0 4px 20px rgba(0,0,0,0.09);
}

/* Form inputs — focus glow transition */
.form-control {
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

/* Stat cards — number pop animation on data load */
.stat-value {
  transition: color 300ms ease;
}

/* Modal smooth entrance */
.modal {
  transition: transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 200ms ease;
}

/* Smooth page-enter animation */
.page-enter {
  animation: fadeInUp 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Table row hover — faster feel */
.tx-row {
  transition: background 120ms ease;
}

/* Toast — remove animation smoother */
.toast {
  transition: max-height 300ms ease, opacity 300ms ease, transform 300ms ease;
}

/* Badge — subtle hover */
.badge {
  transition: opacity 150ms ease, transform 150ms ease;
}

/* Nav item slide — subtle spring */
.sidebar .nav-item:hover,
.sidebar .nav-item.active {
  transition: all 180ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

