/*
 * AdFlow Layout Fix v5.8.4 — Full Viewport Takeover + Home Page Scroll
 * ─────────────────────────────────────────────────────────────────────────── */

/* ══════════════════════════════════════════════════════
   1. APP ROOT — full viewport, flex column, no overflow
   ══════════════════════════════════════════════════════ */
#adflow-app {
  position: fixed !important;
  top: 0 !important; left: 0 !important;
  right: 0 !important; bottom: 0 !important;
  width: 100vw !important; height: 100vh !important;
  max-width: 100vw !important; min-width: 100vw !important;
  overflow: hidden !important;
  z-index: 999999 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  box-sizing: border-box !important;
  padding: 0 !important; margin: 0 !important;
  background: #05070a !important;
}

/* ══════════════════════════════════════════════════════
   2. GUEST NAV — fixed height, never scrolls away
   ══════════════════════════════════════════════════════ */
#adflow-app .af-nav {
  position: relative !important;   /* inside fixed #adflow-app, so this stays put */
  flex-shrink: 0 !important;
  width: 100% !important;
  height: 64px !important;
  z-index: 200 !important;
  box-sizing: border-box !important;
  overflow: visible !important;
}

/* ══════════════════════════════════════════════════════
   3. GUEST BODY — scrollable area below nav
   ══════════════════════════════════════════════════════ */
#adflow-app .af-app-body {
  flex: 1 1 0% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  -webkit-overflow-scrolling: touch !important;
}

/* ══════════════════════════════════════════════════════
   4. HOME — fills scroll area, sections stack vertically
   ══════════════════════════════════════════════════════ */
#adflow-app .af-home {
  flex: 0 0 auto !important;
  width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: visible !important;
}

/* Background orbs stay behind content */
#adflow-app .af-home-bg {
  position: fixed !important;
  inset: 0 !important;
  z-index: 0 !important;
  pointer-events: none !important;
  overflow: hidden !important;
}

/* All home sections above orbs */
#adflow-app .af-hero,
#adflow-app .af-home-services,
#adflow-app .af-home-how,
#adflow-app .af-home-features,
#adflow-app .af-home-cta {
  position: relative !important;
  z-index: 1 !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* ══════════════════════════════════════════════════════
   5. FOOTER — always visible, inside scroll flow
   ══════════════════════════════════════════════════════ */
#adflow-app .af-app-body > .af-footer {
  flex-shrink: 0 !important;
  margin-top: auto !important;
  width: 100% !important;
}

/* ══════════════════════════════════════════════════════
   6. MOBILE NAV — hamburger menu
   ══════════════════════════════════════════════════════ */
.af-nav-mobile-btn {
  display: none;
  background: none;
  border: none;
  color: var(--afh-paper, #f0f0f5);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.af-nav-mobile-btn:hover { background: rgba(255,255,255,0.06); }

.af-nav-mobile-menu {
  display: none;
  flex-direction: column;
  background: rgba(12,13,20,0.98);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 12px 16px 20px;
  gap: 4px;
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  z-index: 199;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.af-nav-mobile-menu.af-nav-mobile-open {
  display: flex !important;
}
.af-nav-mobile-link {
  display: block;
  padding: 12px 16px;
  color: var(--af-text2, #9a9bb0);
  font-size: 15px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.af-nav-mobile-link:hover,
.af-nav-mobile-link.active {
  background: rgba(255,122,26,0.1);
  color: var(--afh-paper, #f0f0f5);
}
.af-nav-mobile-actions {
  display: flex;
  gap: 10px;
  padding: 12px 16px 4px;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 8px;
}
.af-nav-mobile-actions .af-btn-primary-sm {
  flex: 1;
  justify-content: center;
}
.af-nm-login {
  flex: 1;
  text-align: center;
  padding: 8px 16px !important;
}

/* ══════════════════════════════════════════════════════
   7. HERO STATS — compact horizontal row on mobile (no 2×2 grid)
   ══════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .af-hero-stats {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0 !important;
    max-width: 100% !important;
    padding: 0 8px !important;
    margin: 0 auto !important;
  }
  .af-hero-stat {
    flex: 1 1 0% !important;
    min-width: 0 !important;
    padding: 8px 4px !important;
    text-align: left !important;
  }
  .af-hero-stat-sep {
    display: block !important;
    width: 1px !important;
    height: 28px !important;
    background: rgba(255,255,255,0.15) !important;
    flex-shrink: 0 !important;
  }
  .af-stat-num {
    font-size: 18px !important;
    font-weight: 800 !important;
    white-space: nowrap !important;
  }
  .af-stat-lbl {
    font-size: 10px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}

/* ══════════════════════════════════════════════════════
   8. HOW IT WORKS — vertical stack on mobile
   ══════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  .af-how-steps {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0 !important;
  }
  .af-how-step {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  .af-how-arrow {
    transform: rotate(90deg) !important;
    align-self: center !important;
    margin: 4px 0 !important;
  }
}

/* ══════════════════════════════════════════════════════
   8b. HOW IT WORKS — clean 2×2 grid on tablet
       Prevents 3+1 wrapping at mid-widths (700–960px)
   ══════════════════════════════════════════════════════ */
@media (min-width: 701px) and (max-width: 960px) {
  .af-how-steps {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 20px !important;
    align-items: start !important;
    flex-wrap: unset !important;
  }
  .af-how-step {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }
  /* Hide arrows in grid mode — step numbers provide the sequence */
  .af-how-arrow {
    display: none !important;
  }
}

/* ══════════════════════════════════════════════════════
   9. FEATURES GRID — 2-col on mobile
   ══════════════════════════════════════════════════════ */
.af-home-features {
  position: relative;
  z-index: 1;
  padding: 80px 24px;
}
.af-home-features-inner {
  max-width: 1100px;
  margin: 0 auto;
}
.af-features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 48px;
}
.af-feature-card {
  background: var(--af-surface2, #161820);
  border: 1px solid var(--af-border, #2a2d3e);
  border-radius: 16px;
  padding: 28px 24px;
  transition: border-color 0.2s, transform 0.2s;
}
.af-feature-card:hover {
  border-color: var(--af-primary, #6c7fff);
  transform: translateY(-4px);
}
.af-feature-icon {
  font-size: 32px;
  margin-bottom: 14px;
}
.af-feature-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--af-text, #f0f0f5);
  margin: 0 0 8px;
}
.af-feature-card p {
  font-size: 13px;
  color: var(--af-text2, #9a9bb0);
  line-height: 1.6;
  margin: 0;
}
@media (max-width: 980px) {
  /* At 980px (desktop-mode phone / tablet): switch to 2-col grids */
  .af-features-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .af-how-steps-grid { grid-template-columns: 1fr 1fr !important; }
  .af-testimonials-grid { grid-template-columns: 1fr 1fr !important; }
  /* Compact how-it-works cards for 2-col layout */
  .af-how-steps-grid .af-how-step { padding: 18px 14px !important; }
  .af-how-steps-grid .af-how-icon { font-size: 22px !important; margin-bottom: 6px !important; }
  .af-how-steps-grid .af-how-num  { margin-bottom: 6px !important; }
  .af-how-steps-grid .af-how-step h3 { font-size: 13px !important; }
  .af-how-steps-grid .af-how-step p  { font-size: 12px !important; line-height: 1.5 !important; }
  /* Compact "Why Choose Us" feature cards for 2-col layout */
  .af-feature-card { padding: 18px 14px !important; }
  .af-feature-icon { font-size: 22px !important; margin-bottom: 6px !important; }
  .af-feature-card h3 { font-size: 13px !important; margin: 0 0 6px !important; }
  .af-feature-card p  { font-size: 12px !important; line-height: 1.5 !important; }
}
@media (max-width: 960px) {
  .af-features-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .af-how-steps-grid { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 900px) {
  .af-features-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .af-how-steps-grid { grid-template-columns: 1fr 1fr !important; }
  .af-testimonials-grid { grid-template-columns: 1fr !important; }
  /* Services preview — 1 col on tablet */
  .af-services-preview-grid { grid-template-columns: 1fr !important; max-width: 480px !important; margin: 20px auto 0 !important; }
}
@media (max-width: 500px) {
  .af-features-grid { grid-template-columns: 1fr !important; }
  .af-home-features { padding: 60px 16px !important; }
  .af-hero-title { font-size: 30px !important; }
  .af-hero { padding: 48px 20px 40px !important; }
  .af-hero-pill { font-size: 11px !important; padding: 5px 11px !important; }
}

/* ══════════════════════════════════════════════════════
   10. CTA SECTION — centred inner content
   ══════════════════════════════════════════════════════ */
.af-home-cta-inner {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}
.af-home-cta-inner h2 { margin-bottom: 12px; }
.af-home-cta-inner p { margin-bottom: 32px; }

/* ══════════════════════════════════════════════════════
   11. LOGGED-IN SHELL — unchanged sidebar/main layout
   ══════════════════════════════════════════════════════ */
#adflow-app .af-shell {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: stretch !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 100% !important;
  box-sizing: border-box !important;
}
#adflow-app .af-sidebar {
  position: relative !important;
  top: auto !important; left: auto !important; bottom: auto !important;
  height: 100% !important;
  flex-shrink: 0 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  width: 200px !important;
  min-width: 200px !important;
  max-width: 200px !important;
  box-sizing: border-box !important;
}
#adflow-app .af-main {
  flex: 1 1 0% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  height: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  align-self: stretch !important;
  box-sizing: border-box !important;
}
#adflow-app .af-topbar {
  flex-shrink: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  padding: 0 24px !important;
  align-self: stretch !important;
}
#adflow-app .af-body {
  flex: 1 1 0% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  min-height: 0 !important;
  padding-bottom: 80px !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  -webkit-overflow-scrolling: touch !important;
}
#adflow-app .af-page {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 24px 24px 80px !important;
  box-sizing: border-box !important;
}

/* ══════════════════════════════════════════════════════
   12. RESPONSIVE — show hamburger on mobile/tablet
   ══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .af-nav-mobile-btn { display: flex !important; }
  .af-nav-center, .af-nav-right { display: none !important; }
  .af-nav-inner {
    grid-template-columns: 1fr auto !important;
  }
  /* Hero left-align on tablet */
  .af-hero { padding: 72px 24px 56px !important; }
  .af-hero-actions { justify-content: flex-start !important; margin-bottom: 28px !important; }
  .af-hero-stats  { justify-content: flex-start !important; }
  .af-hero-pills  { gap: 8px !important; }
  .af-hero-pill   { font-size: 12px !important; padding: 6px 13px !important; }

  /* Mobile sidebar (logged-in) */
  #adflow-app .af-sidebar {
    position: fixed !important;
    top: 0 !important; left: 0 !important; bottom: 0 !important;
    height: 100vh !important;
    width: 220px !important;
    z-index: 1000 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.25s ease !important;
  }
  #adflow-app .af-sidebar.af-sb-open {
    transform: translateX(0) !important;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5) !important;
  }
  #adflow-app .af-main { margin-left: 0 !important; width: 100% !important; }
  .af-menu-btn { display: flex !important; }
  #adflow-app .af-page { padding: 16px 12px 80px !important; }
  #adflow-app .af-topbar { padding: 0 12px !important; }
}

@media (max-width: 480px) {
  #adflow-app .af-page { padding: 12px 8px 80px !important; }
  #adflow-app .af-topbar { padding: 0 8px !important; }
  .af-hero { padding: 60px 16px 48px !important; }
  .af-home-services, .af-home-how { padding: 60px 16px !important; }
}

/* ══════════════════════════════════════════════════════
   13. DASHBOARD CONTENT — full width cards
   ══════════════════════════════════════════════════════ */
.af-dash-chart-card,
.af-camp-cards,
.af-campaigns-panel,
.af-dash-kpi-grid,
.af-body,
.af-page,
.af-services-grid,
.af-services-grid-v2,
.af-sheet-cards,
.af-kpi-row-v2 {
  max-width: none !important;
}
@media (min-width: 769px) {
  .af-dash-kpi-grid { grid-template-columns: repeat(4, 1fr) !important; }
}

/* ══════════════════════════════════════════════════════
   14. OVERLAYS / MODALS / FAB
   ══════════════════════════════════════════════════════ */
.af-sheet-overlay, .af-overlay {
  position: fixed !important; inset: 0 !important; z-index: 5000 !important;
}
/* .af-overlay vertically centers its modal box with align-items:center. When
   the modal content is taller than the viewport (e.g. the Register form on a
   short/mobile screen), that combined with overflow-y:auto hits a well-known
   flexbox limitation: the browser lets you scroll down into the bottom
   overflow but never up into the top overflow, so the close button — the
   first element in the modal — becomes permanently unreachable. Centering
   the modal box with margin:auto instead of the container's align-items
   keeps the same centered look when content fits on-screen, and degrades to
   a normal top-anchored, fully scrollable view (close button reachable) when
   it doesn't. */
.af-overlay {
  align-items: flex-start !important;
}
.af-auth-modal,
.af-overlay > .af-modal {
  margin: auto !important;
}
.af-sb-overlay {
  position: fixed !important; inset: 0 !important; z-index: 999 !important;
}
.af-avatar-dropdown {
  right: 0 !important; position: absolute !important;
}
.af-fab-wrap {
  position: fixed !important;
  bottom: 28px !important; right: 28px !important;
  z-index: 9999 !important; pointer-events: none !important;
}
.af-fab-btn { pointer-events: all !important; }
