/* ====================================================================
   FlexiFunds — MASTER RESPONSIVE STYLESHEET
   Senior Frontend Engineer Production Build
   Covers: 320px → 4K (2560px+)
   Uses: clamp(), CSS Grid, Flexbox, CSS Custom Properties, rem/em/%/vw
   ====================================================================
   BREAKPOINTS:
   xs  < 480px   (small phones)
   sm  480–767px (phones / phablets)
   md  768–1023px (tablets / iPad)
   lg  1024–1365px (laptops)
   xl  1366–1919px (desktops)
   2xl 1920px+   (TVs / large screens)
   ==================================================================== */

/* ========================= IMPORTS ================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');
@import url('https://fonts.cdnfonts.com/css/sf-pro-display');

/* ========================= DESIGN TOKENS =========================== */
:root {
  /* — Colors (Soft Blue Light Theme) — */
  --clr-bg:            #e0f2fe;
  --clr-card:          rgba(255, 255, 255, 0.90);
  --clr-sidebar:       rgba(240, 249, 255, 0.97);
  --clr-navbar:        rgba(240, 249, 255, 0.90);
  --clr-text:          #0f172a;
  --clr-muted:         #475569;
  --clr-border:        rgba(226, 232, 240, 0.90);
  --clr-primary:       #4f46e5;
  --clr-primary-hover: #4338ca;
  --clr-primary-glow:  rgba(79, 70, 229, 0.16);
  --clr-success:       #10b981;
  --clr-accent:        #ec4899;
  --clr-danger:        #f43f5e;
  --clr-sidebar-active:rgba(79, 70, 229, 0.09);

  /* — Aliases (legacy / cross-file compat) — */
  --primary-color:     var(--clr-primary);
  --accent-color:      var(--clr-accent);
  --text-secondary:    var(--clr-muted);

  /* — Input fields — */
  --clr-input-bg:      #ffffff;
  --clr-input-text:    #0f172a;
  --clr-placeholder:   #94a3b8;

  /* — Shadows / Effects — */
  --shadow-card: 0 4px 24px rgba(31, 38, 135, 0.07);
  --shadow-card-hover: 0 12px 40px rgba(31, 38, 135, 0.12);
  --blur: blur(14px);

  /* — Spacing scale (8px base) — */
  --sp-1: 0.5rem;    /* 8px  */
  --sp-2: 1rem;      /* 16px */
  --sp-3: 1.5rem;    /* 24px */
  --sp-4: 2rem;      /* 32px */
  --sp-5: 3rem;      /* 48px */
  --sp-6: 4rem;      /* 64px */

  /* — Layout — */
  --sidebar-w:     260px;
  --bottom-nav-h:  66px;
  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     16px;
  --radius-xl:     20px;

  /* — Transition — */
  --tr: 0.28s ease;
}

/* Dark theme overrides */
[data-theme="dark"] {
  --clr-bg:            #0a192f;
  --clr-card:          #112240;
  --clr-sidebar:       #0f172a;
  --clr-navbar:        #0f172a;
  --clr-text:          #e2e8f0;
  --clr-muted:         #94a3b8;
  --clr-border:        rgba(255, 255, 255, 0.08);
  --clr-primary:       #64ffda;
  --clr-primary-hover: #52d6b8;
  --clr-primary-glow:  rgba(100, 255, 218, 0.25);
  --clr-sidebar-active:#1e293b;
  --shadow-card:       0 4px 24px rgba(0, 0, 0, 0.40);
  --shadow-card-hover: 0 12px 40px rgba(0, 0, 0, 0.55);
  /* Input fields in dark */
  --clr-input-bg:      #1a2a4a;
  --clr-input-text:    #ffffff;
  --clr-placeholder:   #94a3b8;
  /* Aliases */
  --primary-color:     var(--clr-primary);
  --accent-color:      var(--clr-accent);
  --text-secondary:    var(--clr-muted);
}

/* ========================= GLOBAL RESET ============================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  scroll-behavior: smooth;
  font-size: 16px;                    /* base = 1rem */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: clamp(0.875rem, 1vw + 0.5rem, 1.0625rem);
  background-color: var(--clr-bg);
  color: var(--clr-text);
  transition: background-color var(--tr), color var(--tr);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}
h1, h2, h3, h4, h5, h6, .brand-logo {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.2;
  font-weight: 700;
}

/* Responsive typography with clamp() */
h1 { font-size: clamp(1.5rem,  3vw + 0.5rem, 2.5rem);  }
h2 { font-size: clamp(1.25rem, 2.5vw + 0.4rem, 2rem);  }
h3 { font-size: clamp(1.1rem,  2vw + 0.3rem, 1.75rem); }
h4 { font-size: clamp(1rem,    1.5vw + 0.3rem, 1.4rem);}
h5 { font-size: clamp(0.9rem,  1vw + 0.3rem, 1.15rem); }
h6 { font-size: clamp(0.85rem, 0.8vw + 0.3rem, 1rem);  }

img, video, canvas, svg, picture {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ========================= SCROLLBAR ============================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--clr-bg); }
::-webkit-scrollbar-thumb { background: var(--clr-border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--clr-primary); }

/* ========================= FOCUS STYLES (Accessibility) ============ */
:focus-visible {
  outline: 2px solid var(--clr-primary);
  outline-offset: 3px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

/* ========================= GLASS CARD ============================= */
.glass-card {
  background: var(--clr-card);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}
.glass-card:hover {
  transform: translateY(-4px) scale(1.005);
  box-shadow: var(--shadow-card-hover);
  border-color: rgba(79, 70, 229, 0.28);
}
[data-theme="dark"] .glass-card:hover {
  border-color: rgba(99, 102, 241, 0.28);
}

/* ========================= APP LAYOUT ============================= */
#app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ========================= SIDEBAR ================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--clr-sidebar);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-right: 1px solid var(--clr-border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  inset-block: 0;
  left: 0;
  z-index: 1050;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.sidebar-header {
  padding: clamp(1rem, 2vw, 1.5rem) clamp(0.75rem, 1.5vw, 1.25rem);
  border-bottom: 1px solid var(--clr-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--clr-sidebar);
  z-index: 1;
}
.brand-title {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-menu {
  list-style: none !important;
  padding: 0.75rem;
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-item { margin-bottom: 2px; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.875rem;
  color: var(--clr-muted);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9rem;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  min-height: 44px;
}
.sidebar-link:hover {
  color: var(--clr-primary);
  background: var(--clr-sidebar-active);
  transform: translateX(6px);
}
.sidebar-link.active {
  color: var(--clr-primary);
  background: var(--clr-sidebar-active);
  border-left: 3px solid var(--clr-primary);
  border-radius: 3px var(--radius-md) var(--radius-md) 3px;
  font-weight: 600;
  transform: translateX(4px);
}
.sidebar-link i {
  font-size: 1.1rem;
  width: 1.375rem;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--clr-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 0.5rem;
}
.sidebar-footer .text-truncate {
  font-size: 0.85rem;
  color: var(--clr-muted) !important;
  min-width: 0;
}

/* ========================= MAIN CONTENT =========================== */
.main-content {
  flex: 1 1 0%;
  margin-left: var(--sidebar-w);
  padding: clamp(1rem, 3vw, 2.5rem) clamp(1rem, 3vw, 2.5rem);
  min-height: 100vh;
  min-width: 0;
  transition: margin-left 0.3s ease;
  overflow-x: hidden;
}

/* ========================= TOP NAVBAR ============================= */
.top-navbar {
  background: var(--clr-navbar);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--clr-border);
  padding: 0.875rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: var(--sp-3);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}
.top-navbar h4 {
  font-size: clamp(0.9rem, 1.5vw, 1.15rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========================= THEME TOGGLE =========================== */
.theme-toggle {
  background: none;
  border: 1px solid var(--clr-border);
  color: var(--clr-text);
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.28s ease;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--clr-sidebar-active);
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}

/* ========================= BUTTONS ================================ */
.btn-primary-gradient {
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  border: none;
  color: #fff !important;
  font-weight: 600;
  padding: 0.625rem 1.375rem;
  border-radius: var(--radius-md);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease, opacity 0.2s ease;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.28);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  min-height: 44px;
  white-space: nowrap;
  cursor: pointer;
  font-size: clamp(0.85rem, 1vw, 0.95rem);
}
.btn-primary-gradient:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.4);
  color: #fff !important;
}
.btn-primary-gradient:active {
  transform: translateY(-1px) scale(0.96);
}
.btn-glass {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: var(--blur);
  border: 1px solid var(--clr-border);
  color: var(--clr-text);
  border-radius: var(--radius-md);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.85rem, 1vw, 0.95rem);
}
.btn-glass:hover {
  background: var(--clr-sidebar-active);
  color: var(--clr-primary);
  border-color: var(--clr-primary);
  transform: translateY(-3px);
}
.btn-glass:active {
  transform: translateY(-1px) scale(0.96);
}
/* Ensure all Bootstrap buttons meet 44px minimum height and transitions */
.btn { 
  min-height: 40px; 
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease; 
}
.btn:hover {
  transform: translateY(-2px);
}
.btn:active {
  transform: translateY(0) scale(0.96) !important;
}
.btn-sm { min-height: 36px; }

/* ========================= FORM ELEMENTS ========================== */
.form-control,
.form-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  background-color: var(--clr-input-bg);
  border: 1px solid var(--clr-border);
  color: var(--clr-input-text);
  border-radius: var(--radius-md);
  padding: 0.6875rem 1rem;
  font-size: 1rem;          /* always 16px on mobile — prevents iOS zoom */
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease, transform 0.2s ease;
  min-height: 48px;
}

/* Placeholder visibility in both themes */
.form-control::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--clr-placeholder);
  opacity: 1;
}

.form-control:focus,
.form-select:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px var(--clr-primary-glow);
  outline: none;
  background-color: var(--clr-input-bg);
  color: var(--clr-input-text);
  transform: scale(1.005);
}

.form-control:disabled, .form-select:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
.form-label {
  display: block;
  font-size: 0.8375rem;
  font-weight: 600;
  color: var(--clr-text);
  margin-bottom: 0.375rem;
}
.form-select option, select option {
  background-color: var(--clr-bg) !important;
  color: var(--clr-text) !important;
}

/* Input group addons — match theme */
.input-group-text {
  background-color: var(--clr-input-bg) !important;
  border-color: var(--clr-border) !important;
  color: var(--clr-muted) !important;
  transition: background-color var(--tr);
}
/* Grid layout for form groups on wider screens */
.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 1rem;
}

/* ========================= TABLES ================================= */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  width: 100%;
}
.custom-table {
  width: 100%;
  color: var(--clr-text);
  background-color: transparent;
  border-collapse: collapse;
}
.custom-table th {
  border-bottom: 2px solid var(--clr-border);
  color: var(--clr-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.875rem 1rem;
  background-color: transparent;
  white-space: nowrap;
}
.custom-table td {
  border-bottom: 1px solid var(--clr-border);
  padding: 0.875rem 1rem;
  vertical-align: middle;
  background-color: transparent;
}
.custom-table tbody tr { 
  background-color: transparent; 
  transition: background-color 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.custom-table tbody tr:hover { 
  background-color: rgba(79, 70, 229, 0.04); 
  transform: translateX(4px);
}
[data-theme="dark"] .custom-table tbody tr:hover { background-color: rgba(99, 102, 241, 0.08); }
[data-theme="dark"] .table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--clr-text);
  --bs-table-border-color: var(--clr-border);
}

/* ========================= DARK THEME PATCHES ==================== */
[data-theme="dark"] .bg-opacity-10.bg-success { background-color: rgba(16,185,129,.15) !important; }
[data-theme="dark"] .bg-opacity-10.bg-danger  { background-color: rgba(239,68,68,.15)  !important; }
[data-theme="dark"] .badge.text-success        { color: #34d399 !important; }
[data-theme="dark"] .badge.text-danger         { color: #f87171 !important; }
[data-theme="dark"] .bg-secondary-subtle       { background-color: rgba(75,85,99,.3) !important; }
[data-theme="dark"] .text-secondary            { color: #94a3b8 !important; }
[data-theme="dark"] .text-success              { color: #34d399 !important; }
[data-theme="dark"] .text-danger               { color: #f87171 !important; }

/* ========================= DASHBOARD CARDS ======================= */
/* Responsive auto-fit grid for metric cards */
.metric-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 1rem;
}
.metric-card { position: relative; overflow: hidden; }
.metric-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
}
.metric-card.income::after  { background: var(--clr-success); }
.metric-card.expense::after { background: var(--clr-danger); }
.metric-card.balance::after { background: var(--clr-primary); }
.metric-card.savings::after { background: var(--clr-accent); }
.metric-card h3 {
  font-size: clamp(1.1rem, 2vw + 0.3rem, 1.75rem);
  font-weight: 700;
}

/* ========================= SAVINGS GOALS GRID ==================== */
.goals-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.goals-grid > div {
  width: 100%;
}

/* ========================= ANIMATIONS ============================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); filter: blur(5px); }
  to   { opacity: 1; transform: translateY(0); filter: blur(0); }
}
.fade-in-up { animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* Savings target progress loading animation */
@keyframes progressLoad {
  from { width: 0%; }
}
.progress-bar {
  animation: progressLoad 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Dashboard staggered load helpers */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }

/* ========================= LANDING PAGE ========================== */
.landing-hero {
  background: radial-gradient(circle at 10% 20%, rgba(99,102,241,0.06) 0%, transparent 45%),
              radial-gradient(circle at 90% 80%, rgba(236,72,153,0.06)  0%, transparent 45%);
  padding: clamp(3.5rem, 8vw, 6.5rem) 0;
}
.hero-title {
  font-size: clamp(1.75rem, 5vw + 0.5rem, 4rem);
  font-weight: 800;
  line-height: 1.12;
}
.hero-subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
}

/* ========================= OVERLAY ================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1040;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.show { display: block; }

/* ========================= MOBILE HEADER BAR ===================== */
.mobile-header-bar {
  display: none;
  background: var(--clr-navbar);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--clr-border);
  padding: 0.625rem 1rem;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 1030;
  min-height: 56px;
  width: 100%;
}

/* ========================= BOTTOM NAV =========================== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1060;
  background: var(--clr-sidebar);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--clr-border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
}
.bottom-nav-items {
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: var(--bottom-nav-h);
  list-style: none !important;
  padding: 0 0.25rem;
  margin: 0;
}
.bottom-nav-item { flex: 1; display: flex; }
.bottom-nav-item a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--clr-muted);
  text-decoration: none;
  font-size: clamp(0.55rem, 1.5vw, 0.65rem);
  font-weight: 500;
  padding: 0.375rem 0.25rem;
  border-radius: var(--radius-sm);
  transition: color 0.2s ease;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item a i { font-size: 1.3rem; line-height: 1; }
.bottom-nav-item a.active { color: var(--clr-primary); }
.bottom-nav-item a.active::before {
  content: '';
  position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 3px;
  background: var(--clr-primary);
  border-radius: 0 0 4px 4px;
}
.bottom-nav-item a:hover { color: var(--clr-primary); }

/* ========================= UTILITIES ============================ */
.border-color { border-color: var(--clr-border) !important; }


/* ======================================================================
   ████████████████████████████████████████████████████████████████████
   RESPONSIVE MEDIA QUERIES
   Mobile-first philosophy: smallest → largest
   ████████████████████████████████████████████████████████████████████
   ====================================================================== */

/* ─────────────────────────────────────────────────────────────────────
   📺  TV / 4K  — 1920px and above
   ───────────────────────────────────────────────────────────────────── */
@media (min-width: 1920px) {
  :root { --sidebar-w: 310px; }

  body { font-size: 1.0625rem; }

  .main-content { padding: 3rem 4rem; }
  .top-navbar   { padding: 1.25rem 3rem; border-radius: var(--radius-xl); }
  .glass-card   { border-radius: var(--radius-xl); }

  .sidebar-link { padding: 0.875rem 1.25rem; font-size: 1rem; }
  .sidebar-header { padding: 1.625rem 1.5rem; }

  .hero-title { font-size: clamp(4rem, 6vw, 6rem); }
  .metric-card h3 { font-size: 2rem; }
  .custom-table th, .custom-table td { padding: 1.125rem 1.25rem; }
}

/* 4K Ultra-wide (2560px+) */
@media (min-width: 2560px) {
  :root { --sidebar-w: 340px; }
  body { font-size: 1.125rem; }
  .main-content { padding: 3.5rem 5rem; }
  .sidebar-link { font-size: 1.05rem; padding: 1rem 1.375rem; }
  .hero-title { font-size: clamp(5rem, 7vw, 7rem); }
  .glass-card { border-radius: 1.5rem; }
}

/* ─────────────────────────────────────────────────────────────────────
   🖥️  Large Desktop / Widescreen  — 1600px–1919px
   ───────────────────────────────────────────────────────────────────── */
@media (min-width: 1600px) and (max-width: 1919px) {
  :root { --sidebar-w: 280px; }
  .main-content { padding: 2.5rem 3.5rem; }
}

/* ─────────────────────────────────────────────────────────────────────
   💻  Desktop  — 1366px–1599px
   ───────────────────────────────────────────────────────────────────── */
@media (min-width: 1366px) and (max-width: 1599px) {
  :root { --sidebar-w: 268px; }
  .main-content { padding: 2.25rem 2.75rem; }
}

/* ─────────────────────────────────────────────────────────────────────
   💻  Laptop  — 1024px–1365px
   ───────────────────────────────────────────────────────────────────── */
@media (min-width: 1024px) and (max-width: 1365px) {
  :root { --sidebar-w: 240px; }
  .main-content { padding: 1.75rem 2rem; }
  .top-navbar { padding: 0.875rem 1.5rem; }
  .sidebar-link { font-size: 0.875rem; padding: 0.625rem 0.875rem; }
  .sidebar-header { padding: 1.125rem 1rem; }
  .brand-title { font-size: 1.05rem; }
}

/* ─────────────────────────────────────────────────────────────────────
   📱  Tablet / iPad  — 768px–1023px
   Covers: iPad Mini (768px), iPad Air (820px), iPad Pro 11" (~1024px)
   ───────────────────────────────────────────────────────────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
  /* ── Layout ── */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.18);
    z-index: 1050;
  }
  .sidebar.show { transform: translateX(0); }

  .main-content {
    margin-left: 0;
    padding: 1.25rem 1.5rem;
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 1.25rem);
  }

  /* ── Navigation ── */
  .top-navbar        { display: none; }
  .mobile-header-bar { display: flex; }
  .bottom-nav        { display: block; }

  /* ── Cards ── */
  .glass-card { border-radius: var(--radius-md); }
  .glass-card.p-4 { padding: 1.25rem !important; }

  /* ── Tables ── */
  .custom-table th,
  .custom-table td { padding: 0.75rem 0.875rem; font-size: 0.875rem; }

  /* ── Dashboard: 2-col metric cards on tablet ── */
  .metric-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* ── Typography ── */
  .hero-title { font-size: clamp(1.75rem, 5vw, 2.75rem); }
  .landing-hero { padding: 4rem 0 3rem; }
  .landing-hero .col-lg-6:first-child { text-align: center; }
  .landing-hero .d-flex.gap-3 { justify-content: center; flex-wrap: wrap; }
}

/* iPad landscape: restore sidebar */
@media (min-width: 1024px) and (max-width: 1024px) and (orientation: landscape) {
  .sidebar { transform: translateX(0) !important; }
  .main-content {
    margin-left: var(--sidebar-w) !important;
    padding-bottom: 2rem !important;
  }
  .top-navbar { display: flex !important; }
  .mobile-header-bar { display: none !important; }
  .bottom-nav { display: none !important; }
}

/* ─────────────────────────────────────────────────────────────────────
   📱  Large Phones / Phablets  — 480px–767px
   ───────────────────────────────────────────────────────────────────── */
@media (min-width: 480px) and (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: 6px 0 28px rgba(0,0,0,.24);
  }
  .sidebar.show { transform: translateX(0); }

  .main-content {
    margin-left: 0;
    padding: 1rem 1.25rem;
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 1rem);
  }
  .top-navbar        { display: none; }
  .mobile-header-bar { display: flex; }
  .bottom-nav        { display: block; }

  .glass-card { border-radius: var(--radius-md); }
  .glass-card.p-4 { padding: 1.125rem !important; }

  /* metric cards: 2 per row */
  .metric-cards-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card h3 { font-size: 1.375rem; }

  .custom-table th,
  .custom-table td { padding: 0.625rem 0.75rem; font-size: 0.8125rem; white-space: nowrap; }

  .hero-title { font-size: clamp(1.6rem, 5vw, 2.25rem); text-align: center; }
  .landing-hero .col-lg-6:first-child { text-align: center; }
  .landing-hero .d-flex.gap-3 { justify-content: center; flex-wrap: wrap; }
}

/* ─────────────────────────────────────────────────────────────────────
   📱  Small Phones  — 320px–479px
   ───────────────────────────────────────────────────────────────────── */
@media (max-width: 479px) {
  :root { --sidebar-w: 285px; --bottom-nav-h: 62px; }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: 5px 0 24px rgba(0,0,0,.28);
  }
  .sidebar.show { transform: translateX(0); }

  .main-content {
    margin-left: 0;
    padding: 0.75rem;
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 0.75rem);
  }
  .top-navbar        { display: none; }
  .mobile-header-bar { display: flex; padding: 0.5rem 0.875rem; }
  .bottom-nav        { display: block; }

  .glass-card { border-radius: var(--radius-sm); }
  .glass-card.p-4 { padding: 0.875rem !important; }
  .glass-card.p-5 { padding: 1rem !important; }

  /* stack metric cards 1 per row on very small phones */
  .metric-cards-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .metric-card h3 { font-size: 1.2rem; }

  .custom-table th,
  .custom-table td { padding: 0.5rem 0.625rem; font-size: 0.8rem; white-space: nowrap; }

  /* Forms */
  .form-control, .form-select,
  input, textarea, select { font-size: 16px !important; }  /* prevent iOS zoom */
  .btn-primary-gradient, .btn-glass { padding: 0.625rem 1rem; font-size: 0.875rem; }

  /* Hero */
  .hero-title { font-size: clamp(1.4rem, 7vw, 2rem); text-align: center; }
  .landing-hero { padding: 3rem 0 2rem; }
  .landing-hero .col-lg-6:first-child { text-align: center; }
  .landing-hero .d-flex.gap-3 { justify-content: center; flex-wrap: wrap; gap: 0.625rem !important; }

  /* Sidebar footer */
  .sidebar-footer { padding: 0.875rem 1rem; }
  .bottom-nav-item a { font-size: 0.575rem; }
  .bottom-nav-item a i { font-size: 1.2rem; }

  /* Goals grid: 1 col on small phones */
  .goals-grid { grid-template-columns: 1fr; }
}

/* Extra small (< 360px — old Androids, Galaxy A01) */
@media (max-width: 359px) {
  :root { --sidebar-w: 270px; --bottom-nav-h: 58px; }
  .main-content { padding: 0.5rem; }
  .metric-cards-grid { grid-template-columns: 1fr; }
  .bottom-nav-item a { font-size: 0.5rem; padding: 0.25rem; }
  .hero-title { font-size: clamp(1.25rem, 8vw, 1.6rem); }
}

/* ─────────────────────────────────────────────────────────────────────
   📐  ORIENTATION — Phones in landscape
   ───────────────────────────────────────────────────────────────────── */
@media (max-width: 767px) and (orientation: landscape) {
  :root { --bottom-nav-h: 54px; }
  .landing-hero { padding: 2.5rem 0 2rem; }
  .main-content { padding-top: 0.75rem; }
  .sidebar-link { padding: 0.5rem 0.875rem; }
}

/* ─────────────────────────────────────────────────────────────────────
   👆  TOUCH DEVICES — Remove hover side-effects, enlarge tap targets
   ───────────────────────────────────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  .sidebar-link       { min-height: 48px; }
  .theme-toggle       { width: 44px; height: 44px; min-width: 44px; }
  .btn                { min-height: 48px; }
  .btn-sm             { min-height: 40px; }

  /* Remove hover state transforms — they cause sticky states on touch */
  .glass-card:hover           { transform: none; box-shadow: var(--shadow-card); border-color: var(--clr-border); }
  .sidebar-link:hover         { transform: none; }
  .btn-primary-gradient:hover { transform: none; box-shadow: 0 4px 14px rgba(79,70,229,.28); }
  .btn-glass:hover            { transform: none; }
}

/* ─────────────────────────────────────────────────────────────────────
   🖨️  PRINT
   ───────────────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .mobile-header-bar, .top-navbar,
  .bottom-nav, .sidebar-overlay, .btn,
  .theme-toggle, nav { display: none !important; }
  .main-content {
    margin-left: 0 !important;
    padding: 1rem !important;
    width: 100% !important;
  }
  .glass-card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    background: white !important;
    backdrop-filter: none !important;
  }
  body, html { background: white !important; color: black !important; }
}

/* =====================================================================
   ADMIN SUB-BOARDS STYLING (User Board vs Admin Board)
   ===================================================================== */
.admin-tab-nav {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--clr-border);
  gap: 4px;
  margin-bottom: var(--sp-3);
  width: fit-content;
}

[data-theme="light"] .admin-tab-nav {
  background: rgba(0, 0, 0, 0.03);
}

.admin-tab-btn {
  background: transparent;
  border: none;
  color: var(--clr-muted);
  padding: 8px 16px;
  border-radius: calc(var(--radius-md) - 2px);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--tr);
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-tab-btn:hover {
  color: var(--clr-text);
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .admin-tab-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.admin-tab-btn.active {
  color: #fff !important;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

/* ========================= BUTTON LOADING STATES ==================== */      
.btn-spinner .spinner-border {
  margin-right: 0.5rem;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

/* ========================= PASSWORD STRENGTH INDICATOR ==================== */
.password-strength-container {
  margin-top: 0.75rem;
}

.password-strength-bar-wrapper {
  height: 6px;
  background: var(--clr-border);
  border-radius: 100px;
  overflow: hidden;
}

.password-strength-bar {
  height: 100%;
  width: 0;
  transition: all 0.3s ease;
  border-radius: 100px;
}

.password-strength-bar.weak { width: 25%; background: #ef4444; }
.password-strength-bar.moderate { width: 50%; background: #f59e0b; }
.password-strength-bar.strong { width: 75%; background: #10b981; }
.password-strength-bar.very-strong { width: 100%; background: #059669; }

.password-strength-text {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.password-strength-text.weak { color: #ef4444; }
.password-strength-text.moderate { color: #f59e0b; }
.password-strength-text.strong { color: #10b981; }
.password-strength-text.very-strong { color: #059669; }

.password-requirements {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: rgba(var(--clr-card), 0.6);
  border-radius: 0.75rem;
  border: 1px solid var(--clr-border);
}

.password-requirement {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
  font-size: 0.85rem;
  color: var(--clr-muted);
  transition: all 0.2s ease;
}

.password-requirement i { font-size: 1rem; }

.password-requirement.valid { color: var(--clr-success); }
.password-requirement.invalid { color: var(--clr-muted); }
