/**
 * tradingsmart.ai — shared mobile / tablet responsive layer
 * Load AFTER page-specific <style> blocks. Does not change JS or APIs.
 */

/* ── Global: prevent horizontal page scroll ── */
html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}
body {
  overflow-x: clip;
  max-width: 100vw;
}
img, video, svg { max-width: 100%; height: auto; }
table { max-width: 100%; }

/* Utility: wrap long tokens (logs, symbols, URLs) */
.r-wrap-anywhere,
.bh-log-m,
.mono-break {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* ── Legal pages (terms, privacy) ── */
@media (max-width: 768px) {
  header {
    flex-wrap: wrap;
    height: auto !important;
    min-height: 56px;
    padding: 12px 16px !important;
    gap: 10px;
  }
  header .nav-links {
    flex: 1 1 100%;
    margin-left: 0 !important;
    flex-wrap: wrap;
    gap: 12px 20px;
    justify-content: flex-start;
    padding-top: 4px;
    border-top: 1px solid rgba(245, 158, 11, 0.12);
  }
  .hero {
    padding: 40px 16px 32px !important;
  }
  .hero h1 {
    font-size: clamp(22px, 6vw, 32px);
  }
  main {
    padding: 32px 0px 0px !important;
  }
  footer {
    padding: 20px 16px !important;
    font-size: 11px;
  }
}

@media (max-width: 480px) {
  header .logo span { font-size: 14px; }
  .nav-links a { font-size: 12px; }
}

/* ── Unsubscribe card ── */
@media (max-width: 520px) {
  .wrap {
    margin: max(24px, env(safe-area-inset-top)) 16px 24px !important;
    padding: 24px 18px !important;
    max-width: none;
  }
  .wrap h1 { font-size: 18px; }
}

/* ── Marketing index + affiliate-partner (nav / footer / ticker) ── */
@media (max-width: 800px) {
  .disclaimer-strip {
    flex-wrap: wrap;
    padding: 8px 12px;
    font-size: 10px;
    line-height: 1.45;
    gap: 6px;
  }
  .ticker {
    height: 28px;
  }
  .ticker-track {
    font-size: 10px;
    gap: 24px;
  }
}

@media (max-width: 480px) {
  .disclaimer-strip {
    font-size: 9px;
    letter-spacing: 0.35px;
  }
  .affiliate-partner .footer-grid,
  footer .footer-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Marketing footer legal row */
@media (max-width: 640px) {
  .footer-bottom .legal {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 14px;
  }
}

/* ── Checkout ── */
@media (max-width: 640px) {
  .checkout-page .method-tabs,
  .wrap .method-tabs,
  body .method-tabs {
    grid-template-columns: 1fr !important;
    gap: 6px;
  }
  .wrap .summary,
  .wrap .payment {
    padding: 20px 16px !important;
  }
  .wrap .topbar,
  .wrap .s-head-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .wrap .inner { padding: 0; }
}

@media (max-width: 400px) {
  .method-tab {
    font-size: 12px !important;
    padding: 10px 8px !important;
  }
}

/* ── Affiliate dashboard (/affiliate/) ── */
@media (max-width: 600px) {
  .topbar {
    flex-wrap: wrap;
    padding: 10px 12px !important;
    gap: 8px;
  }
  .topbar .tb-user {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar .tb-out {
    margin-left: auto;
  }
  .hero-row {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .hero-link {
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }
  main.wrap,
  .wrap {
    padding: 12px !important;
  }
}

@media (max-width: 480px) {
  .topbar .brand span {
    font-size: 13px;
  }
  .kpis {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ── Admin panel 1 (user activity + coupons) ── */
@media (max-width: 900px) {
  .adminpanel1 .layout,
  body .layout {
    flex-direction: column;
    height: auto !important;
    min-height: calc(100vh - 49px);
    min-height: calc(100dvh - 49px);
  }
  .adminpanel1 .col-users,
  body .col-users {
    width: 100% !important;
    max-width: 100%;
    flex-shrink: 1;
    border-right: 0;
    border-bottom: 1px solid var(--bd-1, #232b38);
    max-height: 45vh;
    max-height: 45dvh;
  }
  .adminpanel1 .col-detail,
  body .col-detail {
    flex: 1;
    min-height: 40vh;
    min-height: 40dvh;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    padding: 10px 12px !important;
    gap: 8px;
  }
  .topbar .title {
    flex: 1 1 100%;
    font-size: 12px;
  }
  .topbar nav {
    flex-wrap: wrap;
    gap: 6px 10px;
    width: 100%;
  }
  .topbar nav a {
    font-size: 10px;
  }
  .topbar .signout,
  .topbar .email {
    font-size: 11px;
  }
  .page {
    padding: 12px !important;
  }
  .panel {
    padding: 12px !important;
  }
}

/* Coupons page grid */
@media (max-width: 800px) {
  .page {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
}

/* ── Admin (/admin/) — small-phone polish ── */
@media (max-width: 540px) {
  .app .topbar .search {
    display: none;
  }
  .app .topbar {
    padding: 8px 10px;
    gap: 8px;
  }
  .view-h {
    flex-wrap: wrap;
    gap: 8px;
  }
  .drawer {
    width: 100% !important;
    max-width: 100% !important;
  }
}

/* ── Free training landings ── */
@media (max-width: 768px) {
  .site-header .nav,
  header.site-header .nav {
    flex-wrap: wrap;
    gap: 10px;
  }
  .site-header .cta-btns {
    width: 100%;
    justify-content: stretch;
  }
  .site-header .cta-btns .nav-cta {
    flex: 1;
    text-align: center;
  }
  .urgency-bar {
    flex-wrap: wrap;
    padding: 8px 12px;
    font-size: 11px;
    line-height: 1.4;
    gap: 6px;
    justify-content: center;
    text-align: center;
  }
  .foot-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 16px !important;
    text-align: left;
  }
  .foot-links {
    flex-wrap: wrap;
    gap: 10px 16px;
  }
}

@media (max-width: 600px) {
  .sticky-cta-mobile,
  .sticky-cta {
    display: block;
  }
}

/* Free AI stock training — extra grids */
@media (max-width: 800px) {
  header.nav .nav-inner {
    padding: 0 16px;
  }
  .features-grid,
  .steps-grid,
  .pricing-row,
  .proof-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── Tables: horizontal scroll on small screens ── */
@media (max-width: 768px) {
  .table-scroll,
  .data-table-wrap,
  table.scroll-x {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .users-table-wrap,
  .detail-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
}

/* ── Modals / drawers safe area ── */
@media (max-width: 640px) {
  .modal {
    width: 100% !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
  }
  .modal-head {
    padding-top: max(env(safe-area-inset-top), 12px) !important;
  }
  .drawer-overlay.show + .drawer,
  .drawer.open {
    max-width: 100vw;
  }
}

/* ── WhatsApp float — avoid covering CTAs ── */
@media (max-width: 640px) {
  .wa-float,
  [class*="whatsapp"] {
    bottom: max(16px, env(safe-area-inset-bottom)) !important;
    right: max(12px, env(safe-area-inset-right)) !important;
  }
  body:has(.sticky-cta-mobile),
  body:has(.sticky-cta) {
    padding-bottom: max(72px, calc(56px + env(safe-area-inset-bottom)));
  }
}
