/*
 * PocketTracker — Redesigned Theme & Layout Fixes
 * - Single-scroll container (main .app-content)
 * - Sticky sidebar footer for subscription card (no overflow)
 * - Premium tokens, refined components, accessible modals
 */

/* =========================
   1. DESIGN TOKENS
   ========================= */
:root{
  /* backgrounds */
  --bg-900: #05030A;        /* deep */
  --bg-800: #0A0A12;
  --bg-700: #0E1220;

  /* accents */
  --accent-1: #8B5CF6;      /* indigo */
  --accent-2: #06B6D4;      /* teal */
  --accent-3: #10B981;      /* emerald */
  --gold: #FBBF24;

  /* text */
  --text-primary: #E6F0FA;
  --text-muted: #94A3B8;

  /* glass */
  --glass-alpha: 0.04;

  /* sizing */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;

  /* shadows */
  --shadow-soft: 0 6px 18px rgba(2,6,23,0.45);
  --shadow-deep: 0 16px 42px rgba(3,7,20,0.75);

  /* motion */
  --ease-fast: cubic-bezier(.2,.9,.25,1);
  --dur-sm: 160ms;
  --dur-md: 260ms;
}

/* =========================
   2. GLOBAL LAYOUT & SCROLL FIX
   ========================= */
/* Force single scrollable region:
   - document-level overflow hidden (no page-level scrollbars)
   - .app-content is the only scrollable container
*/
html, body, #app {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;            /* <-- important: prevents double scrollbars */
  background: linear-gradient(180deg, var(--bg-700), var(--bg-800));
  color: var(--text-primary);
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

/* Main app layout */
#app { display: flex; min-height: 100vh; }

/* Sidebar layout is fixed width; main scrolls */
aside.sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  box-sizing: border-box;
  position: relative;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border-right: 1px solid rgba(255,255,255,0.02);
}

/* This is the single scrolling area for the app */
.app-content {
  flex: 1;
  height: 100vh;                 /* full viewport height */
  overflow-y: auto;              /* <-- the ONLY scroll container */
  -webkit-overflow-scrolling: touch;
  padding: 28px;
  box-sizing: border-box;
}

/* ensure modals overlay above everything */
#modalsRoot {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}
#modalsRoot > * { pointer-events: auto; }

/* =========================
   3. SCROLLBAR STYLING
   ========================= */
/* main content scrollbar (subtle, thin) */
.app-content::-webkit-scrollbar { width: 10px; }
.app-content::-webkit-scrollbar-track { background: transparent; }
.app-content::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.04));
  border-radius: 999px; border: 2px solid transparent; background-clip: padding-box;
}
.app-content::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.06)); }

/* sidebar nav scrollbar (thin & left-side) */
aside.sidebar nav { overflow-y: auto; max-height: calc(100vh - 220px); }
aside.sidebar nav::-webkit-scrollbar { width: 6px; }
aside.sidebar nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.04); border-radius:999px }

/* =========================
   4. GLASS & CARD SYSTEM
   ========================= */
/* subtle glass cards */
.glass {
  background: linear-gradient(180deg, rgba(255,255,255,var(--glass-alpha)), rgba(255,255,255,0.015));
  border-radius: var(--r-md);
  border: 1px solid rgba(255,255,255,0.03);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px) saturate(120%);
  color: var(--text-primary);
}

/* primary card variant */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-deep);
}

/* contrast card for KPI / charts */
.card-contrast {
  background: linear-gradient(180deg, rgba(255,255,255,0.012), rgba(255,255,255,0.008));
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: 0 10px 30px rgba(2,6,23,0.6);
}

/* small muted text helper */
.muted { color: var(--text-muted); font-size: 13px; }

/* pill */
.pill {
  display: inline-flex; gap: 8px; align-items:center; padding: 6px 10px;
  border-radius: 999px; background: rgba(255,255,255,0.02); color: var(--text-primary);
  font-size: 13px; font-weight:600; transition: transform var(--dur-sm) var(--ease-fast), background var(--dur-sm);
}
.pill:hover { transform: translateY(-3px); background: rgba(255,255,255,0.04); }
.pill.active { background: linear-gradient(90deg,var(--accent-1),var(--accent-2)); color: #fff; }

/* nice button: gradient + subtle lift */
.nice-btn {
  display:inline-block; padding:10px 14px; border-radius: 12px; color:#fff; font-weight:700;
  background: linear-gradient(90deg,var(--accent-1),var(--accent-2));
  box-shadow: 0 10px 30px rgba(11,8,27,0.6);
  transition: transform var(--dur-sm) var(--ease-fast), box-shadow var(--dur-sm);
}
.nice-btn:hover { transform: translateY(-4px); box-shadow: 0 18px 48px rgba(11,8,27,0.7); }

/* input styles (fancy, accessible focus) */
.input {
  width:100%; padding:11px 14px; border-radius: 10px;
  background: rgba(255,255,255,0.015); border: 1px solid rgba(255,255,255,0.03);
  color: var(--text-primary); box-sizing: border-box;
}
.input:focus {
  outline: none;
  box-shadow: 0 8px 26px rgba(11,13,30,0.45), 0 0 0 4px rgba(139,92,246,0.08);
  border-color: rgba(139,92,246,0.85);
}

/* floating label variant utility (example) */
.field {
  position: relative;
}
.field label {
  position: absolute; left: 14px; top: 10px; font-size: 12px; color: var(--text-muted); pointer-events:none; transition: all 0.18s;
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  transform: translateY(-22px); font-size: 11px; opacity: 0.95;
}

/* =========================
   5. SIDEBAR FOOTER & SUBSCRIPTION FIX
   ========================= */
/* make footer sticky inside sidebar and keep card contained */
.sidebar-footer {
  margin-top: 12px;
  position: sticky;
  bottom: 20px;           /* keeps it pinned inside sidebar without overflow */
  display: block;
  z-index: 5;
  box-sizing: border-box;
  width: 100%;
}

/* subscription card: constrained and responsive */
.subscription-card {
  display:flex; flex-direction: column; gap:8px;
  padding: 14px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.04);
  box-shadow: 0 8px 28px rgba(2,6,23,0.48);
  max-width: calc(100% - 8px);
  overflow: hidden;
}
.subscription-card .price {
  font-weight: 800; color: var(--gold); font-size: 18px;
}
.subscription-card .manage-cta {
  margin-top: 8px;
  width:100%;
}

/* ensure subscription doesn't overflow on smaller widths */
@media (max-width: 920px){
  .subscription-card { transform: translateY(0); max-width:100%; border-radius:10px; }
  aside.sidebar { width: 68px; } /* optional: collapsed sidebar style for very small screens */
}

/* =========================
   6. BILL / INCOME LISTING (premium card rows)
   ========================= */
.list-row {
  display:flex; justify-content: space-between; align-items:center;
  gap:14px; padding:14px; border-radius:12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.01), rgba(255,255,255,0.008));
  border: 1px solid rgba(255,255,255,0.02);
  transition: transform var(--dur-sm) var(--ease-fast), box-shadow var(--dur-sm);
}
.list-row:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 48px rgba(3,7,20,0.6);
}
.list-row .meta { display:flex; flex-direction:column; gap:4px; }
.list-row .amount { font-weight:800; font-size:1.05rem; color:var(--text-primary); text-align:right; min-width:120px; }

/* tag badge */
.badge {
  background: rgba(255,255,255,0.02); padding:6px 10px; border-radius:999px; font-size:12px; color:var(--text-muted);
}

/* =========================
   7. ACTION CARD / DROP ZONE
   ========================= */
.action-card {
  padding: 20px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.01), rgba(255,255,255,0.008));
  border: 1px dashed rgba(255,255,255,0.03);
  text-align:center; transition: transform var(--dur-sm) var(--ease-fast), background var(--dur-sm);
}
.action-card:hover { transform: translateY(-6px); background: linear-gradient(180deg, rgba(139,92,246,0.06), rgba(6,182,212,0.03)); }

/* drop-zone */
.drop-zone {
  border-radius: 12px; padding: 28px; text-align:center;
  border: 1px dashed rgba(255,255,255,0.06);
}
.drop-zone.drag-over { border-color: var(--accent-1); background: rgba(139,92,246,0.04); }

/* =========================
   8. MODALS & TOASTS
   ========================= */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(2,6,23,0.6); display:flex; align-items:center; justify-content:center; z-index:9999;
}
.modal {
  width: min(920px, 96%); max-height: 85vh; overflow:auto;
  border-radius: 16px; padding: 18px; box-shadow: var(--shadow-deep);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.03);
}
.modal .modal-header { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.modal .close {
  background: transparent; border: none; color: var(--text-muted); font-size:18px; cursor:pointer;
}
.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 12000;
  background: linear-gradient(90deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01));
  padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-soft);
}

/* accessibility: reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce){
  .nice-btn, .list-row, .pill, .action-card { transition: none !important; transform:none !important; }
}

/* =========================
   9. RESPONSIVENESS
   ========================= */
@media (max-width: 1024px){
  aside.sidebar { width: 80px; padding: 14px; }
  .app-content { padding: 20px; }
  .list-row .amount { min-width: 96px; font-size: 0.98rem; }
}
