/* ============================================
   FundVault — Layout
   Header, sidebar, main content, responsive
   ============================================ */

/* ── App Shell ── */
.app-shell {
  min-height: 100vh;
  padding-top: var(--ticker-height);
  overflow-x: clip;   /* belt-and-suspenders: no horizontal scroll from edge popovers */
}

/* ── Live Ticker Tape ── */
.ticker-tape {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--ticker-height);
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-dark);
  overflow: hidden;
  z-index: 450;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.ticker-track {
  display: inline-flex;
  align-items: center;
  will-change: transform;
  animation: ticker-scroll 120s linear infinite;
}

.ticker-tape:hover .ticker-track {
  animation-play-state: paused;
}

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 var(--sp-5);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  font-size: var(--fs-12);
  cursor: pointer;
  height: var(--ticker-height);
  transition: background var(--transition-fast);
}

.ticker-item:hover { background: var(--bg-hover-dark); }

.ticker-item .tk-name {
  color: #cdd3da;
  font-weight: var(--fw-semibold);
  letter-spacing: 0.02em;
}

.ticker-item .tk-nav {
  color: var(--text-white);
  font-variant-numeric: tabular-nums;
}

.ticker-item .tk-chg {
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
}

.ticker-item .tk-chg.up { color: #2fc96b; }
.ticker-item .tk-chg.down { color: #ff5d6c; }

.ticker-empty {
  color: var(--text-tertiary);
  font-size: var(--fs-12);
  padding: 0 var(--sp-6);
}

/* ── Top Navigation (replaces left sidebar) ── */
.top-nav {
  position: sticky;
  top: var(--ticker-height);
  z-index: var(--z-header);
  background: linear-gradient(180deg, var(--bg-dark-secondary) 0%, var(--bg-dark) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.top-nav-inner {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  height: var(--nav-height);
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 var(--sp-7);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: var(--brand-indent);   /* original logo position */
}

.nav-brand .logo-icon {
  width: 30px;
  height: 30px;
  background: var(--color-up);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-dark);
  font-weight: var(--fw-bold);
  font-size: var(--fs-16);
}

.nav-brand .logo-text {
  font-size: var(--fs-18);
  font-weight: var(--fw-bold);
  color: var(--text-white);
  letter-spacing: -0.03em;
}

.nav-brand .logo-text span { color: var(--color-up); }

.nav-brand .brand-logo {
  height: 30px;
  width: auto;
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.nav-links .nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  color: #aeb6bf;
  font-size: var(--fs-14);
  font-weight: var(--fw-medium);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  user-select: none;
}

.nav-links .nav-item:hover {
  color: var(--text-white);
  background: rgba(255, 255, 255, 0.06);
}

.nav-links .nav-item.active {
  color: var(--text-white);
  background: rgba(255, 255, 255, 0.12);
}

.nav-links .nav-icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; }
.nav-links .nav-icon svg { width: 18px; height: 18px; display: block; stroke-width: 1.75px; }

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-shrink: 0;
}

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: var(--sp-2) var(--sp-3);
  color: var(--text-white);
  background: none;
  border: none;
}
.mobile-menu-btn svg { width: 22px; height: 22px; display: block; }

.header-search {
  position: relative;
  width: 340px;
}

.header-search .search-input {
  height: 40px;
  padding-left: 42px;
  border-radius: var(--radius-full);
  font-size: var(--fs-13);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-white);
}

.header-search .search-input::placeholder { color: #7e8893; }
.header-search .search-input:focus {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: none;
}
.header-search .search-icon {
  left: 16px;
  width: 16px;
  height: 16px;
  color: #7e8893;
  display: block;
}
.header-search .search-input:focus + .search-icon,
.header-search .input-group:focus-within .search-icon { color: #aeb6bf; }

/* ── App Main ── */
.app-main { min-height: calc(100vh - var(--ticker-height) - var(--nav-height)); }

.header-date {
  font-size: var(--fs-13);
  color: #8b939c;
}

.header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chart-1), var(--chart-7));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-white);
  font-weight: var(--fw-semibold);
  font-size: var(--fs-14);
  cursor: pointer;
}

/* ── Page Content ── */
.page-content {
  padding: var(--sp-7);
  max-width: var(--content-max-width);
  margin: 0 auto;
}

/* On these tabs the content's left edge lines up with the brand logo. */
.page-content.dashboard-page,
.page-content.calculator-page,
.page-content.portfolio-page {
  padding-left: calc(var(--sp-7) + var(--brand-indent));
}

.page-title {
  font-size: var(--fs-24);
  font-weight: var(--fw-bold);
  color: var(--text-brand);
  margin-bottom: var(--sp-6);
}

.page-subtitle {
  font-size: var(--fs-14);
  color: var(--text-tertiary);
  margin-top: calc(-1 * var(--sp-4));
  margin-bottom: var(--sp-6);
}

/* ── Grid Layouts ── */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-5);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-5);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-5);
}

.grid-2-1 {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--sp-6);
}

.grid-1-1 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--sp-6);
}

/* ── Overlay ── */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: var(--z-overlay);
  display: none;
}

.overlay.show {
  display: block;
}

/* ── Mobile Responsive ── */
@media (max-width: 1200px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Tighten the nav before the mobile collapse so it never overflows / pushes
   the account control off-screen on medium (laptop) widths. */
@media (max-width: 1240px) {
  .top-nav-inner { gap: var(--sp-2); padding: 0 var(--sp-5); }
  .nav-links { gap: 0; }
  .nav-links .nav-item { padding: var(--sp-2) var(--sp-3); font-size: var(--fs-13); }
  .nav-right { gap: var(--sp-3); }
  .header-search { width: 160px; }
}

@media (max-width: 1024px) {
  .grid-2-1 {
    grid-template-columns: 1fr;
  }
  .header-search { width: 170px; }
  .header-date { display: none; }
}

/* Collapse the horizontal nav into a dropdown menu */
@media (max-width: 980px) {
  .mobile-menu-btn { display: flex; order: -1; }
  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-1);
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border-dark);
    padding: var(--sp-3);
    box-shadow: var(--shadow-popup);
    display: none;
  }
  .top-nav.nav-open .nav-links { display: flex; }
  .nav-links .nav-item { padding: var(--sp-4); }
  /* When the menu is open, lift the nav ABOVE the backdrop overlay so taps
     land on the menu items (not the overlay, which would just close it). */
  .top-nav.nav-open { z-index: calc(var(--z-overlay) + 1); }
}

@media (max-width: 768px) {
  /* Drop the desktop "logo / content" indent on mobile — it was pushing the
     logo away from the menu button and over-padding the page content. */
  :root { --brand-indent: 0px; }
  .nav-brand { margin-left: 0; }

  .page-content {
    padding: var(--sp-5);
  }
  /* These pages add the brand-indent on desktop; keep them flush on mobile. */
  .page-content.dashboard-page,
  .page-content.calculator-page,
  .page-content.portfolio-page {
    padding-left: var(--sp-5);
  }
  .grid-4,
  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-2,
  .grid-1-1 {
    grid-template-columns: minmax(0, 1fr);
  }
  .header-search { width: 160px; }
  .top-nav-inner { padding: 0 var(--sp-5); gap: var(--sp-3); }
}

@media (max-width: 480px) {
  .grid-4,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .header-search { display: none; }
  .page-content {
    padding: var(--sp-4);
  }
  .page-content.dashboard-page,
  .page-content.calculator-page,
  .page-content.portfolio-page {
    padding-left: var(--sp-4);
  }
}

/* ── Site footer ── */
.site-footer { border-top: 1px solid var(--border-light); background: var(--bg-white); margin-top: var(--sp-8); }
.site-footer-inner { max-width: var(--content-max-width); margin: 0 auto; padding: var(--sp-6) var(--sp-7) var(--sp-4); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-5); flex-wrap: wrap; }
.sf-brand { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.sf-wordmark { font-size: var(--fs-16); font-weight: var(--fw-bold); color: var(--text-brand); letter-spacing: var(--ls-tight); }
.sf-copy { font-size: var(--fs-12); color: var(--text-tertiary); }
.sf-links { display: flex; gap: var(--sp-5); flex-wrap: wrap; }
.sf-links a { font-size: var(--fs-13); color: var(--text-secondary); text-decoration: none; }
.sf-links a:hover { color: var(--text-link); }
.sf-disclaimer { max-width: var(--content-max-width); margin: 0 auto; padding: 0 var(--sp-7) var(--sp-6); font-size: var(--fs-11); color: var(--text-tertiary); line-height: 1.55; }

/* ── In-content ad slot ── */
.ad-slot {
  margin: var(--sp-6) 0 var(--sp-2);
  padding: var(--sp-3);
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  background: var(--bg-white, #fff);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ad-slot .ad-label {
  font-size: var(--fs-10, 10px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.ad-slot ins.adsbygoogle { display: block; width: 100%; }

/* ── Legal / privacy page ── */
.legal-card { max-width: 820px; }
.legal-card h3 { font-size: var(--fs-16); font-weight: var(--fw-bold); color: var(--text-brand); margin: var(--sp-6) 0 var(--sp-3); }
.legal-card p { font-size: var(--fs-14); color: var(--text-secondary); line-height: 1.65; margin-bottom: var(--sp-3); }
.legal-card ul { margin: 0 0 var(--sp-4) var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); }
.legal-card li { font-size: var(--fs-14); color: var(--text-secondary); line-height: 1.6; }
.legal-card a { color: var(--text-link); }
