
/* =========================================================================
   RESPONSIVE LAYER
   Loaded AFTER the page's main stylesheet. Phones first: most visitors use
   them. Sections: 1 global safety, 2 forms + taps, 3 tables become cards,
   4 shared helpers (chart box, pagination).
   ========================================================================= */

/* ---- 1. Global safety: nothing may push the page wider than the screen ---- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-x: hidden; overflow-x: clip; }
img, video, canvas, iframe, svg { max-width: 100%; }
.chart-box { position: relative; width: 100%; height: 320px; }
.chart-box canvas { display: block; }

/* ---- 2. Forms and tap targets ---- */
@media (max-width: 900px) {
  /* 16px stops iPhones zooming the page when a field is focused */
  input, select, textarea { font-size: 16px !important; }
  .btn { min-height: 44px; }
  .btn.btn-sm, .btn-sm { min-height: 40px; }
}
@media (max-width: 700px) {
  .field-row, .form-row, .two-col { grid-template-columns: 1fr !important; }
  .btn-block { width: 100%; }
  .tbl-toolbar input, .tbl-search { width: 100%; }
  .tbl-pager { justify-content: center; text-align: center; }
  .tbl-pages { justify-content: center; }
}

/* ---- 3. Tables: on phones every row becomes a card (labels are added by responsive.js) ---- */
@media (max-width: 700px) {
  .table-scroll { overflow: visible; }
  .table-scroll .table { min-width: 0; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr {
    background: var(--white, #fff); border: 1px solid var(--line, #E3E9F2); border-radius: 14px;
    padding: 4px 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  }
  .table tr:last-child td { border-bottom: 1px dashed var(--line, #E3E9F2); }
  .table td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 10px 0; border: 0; border-bottom: 1px dashed var(--line, #E3E9F2);
    text-align: right; overflow-wrap: anywhere;
  }
  .table td:last-child, .table tr:last-child td:last-child { border-bottom: 0; }
  .table td[data-label]::before {
    content: attr(data-label); flex: none; max-width: 42%; text-align: left;
    font-size: .76rem; font-weight: 700; letter-spacing: .02em; color: var(--muted, #5C6E85);
  }
  /* rows with no label (loading / empty messages) read as plain text */
  .table td:not([data-label]) { display: block; text-align: left; }
  .table tr:has(td:not([data-label])) { border-style: dashed; box-shadow: none; }
}

/* =========================================================================
   AGENT + CUSTOMER DASHBOARD (shared .dash-* layout)
   ========================================================================= */

/* The menu scrolls when it is taller than the screen (the button + log-out stay reachable) */
.dash-sidebar { overflow-y: auto; overscroll-behavior: contain; }

/* ---- Visit-website pieces (sidebar button, overview card) ---- */
.dash-visit {
  flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 14px; border-radius: 12px; font-weight: 600; font-size: .9rem;
  background: rgba(255, 255, 255, .14); color: #fff; border: 1px solid rgba(255, 255, 255, .22);
  transition: background .15s ease, transform .15s ease;
}
.dash-visit:hover { background: rgba(255, 255, 255, .24); transform: translateY(-1px); }
.dash-visit[hidden] { display: none; }

.store-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px; padding: 18px 22px; border-radius: var(--radius-md, 14px); color: #fff;
  background: linear-gradient(135deg, #171B57 0%, #2A2FA0 100%); box-shadow: 0 10px 26px rgba(23, 27, 87, .22);
}
.store-card[hidden] { display: none; }
.store-card .sc-info { min-width: 0; flex: 1 1 220px; }
.store-card .sc-label { display: block; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.store-card .sc-name { display: block; font-size: 1.15rem; margin: 2px 0 2px; }
.store-card .sc-url { display: block; font-size: .85rem; opacity: .85; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-card .sc-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.store-card .btn-white { background: #fff; color: #1D2178; border: 0; font-weight: 700; }
.store-card .btn-outline-light { background: transparent; color: #fff; border: 1.5px solid rgba(255, 255, 255, .55); }

/* ---- Plan upgrade ---- */
.upg-current {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; padding: 16px 20px;
  border-radius: var(--radius-md, 14px); background: linear-gradient(135deg, #EEF0FF, #F7F9FF); border: 1px solid #DDE1FA;
}
.upg-current .upg-ico { width: 44px; height: 44px; border-radius: 14px; flex: none; display: grid; place-items: center; background: #2A2FA0; color: #fff; }
.upg-current b { display: block; font-size: 1.02rem; }
.upg-current span { color: var(--muted, #5C6E85); font-size: .88rem; }
.upg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; align-items: stretch; }
.upg-card {
  position: relative; display: flex; flex-direction: column; padding: 24px 22px 22px; border-radius: 18px;
  background: var(--white, #fff); border: 1.5px solid var(--line, #E3E9F2); box-shadow: 0 2px 10px rgba(15, 23, 42, .05);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.upg-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(42, 47, 160, .14); border-color: #B9BFF0; }
.upg-card.featured { border-color: #2A2FA0; background: linear-gradient(180deg, #F6F7FF, #fff 38%); }
.upg-badge {
  position: absolute; top: -12px; left: 22px; padding: 4px 12px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase; background: linear-gradient(135deg, #2A2FA0, #5A5FE0); color: #fff;
}
.upg-card h4 { font-size: 1.2rem; margin: 0 0 2px; }
.upg-from { color: var(--muted, #5C6E85); font-size: .84rem; }
.upg-price { margin: 14px 0 2px; font-family: var(--font-display, inherit); font-weight: 800; font-size: 2rem; letter-spacing: -.02em; color: #1D2178; }
.upg-price small { font-size: .8rem; font-weight: 600; color: var(--muted, #5C6E85); letter-spacing: 0; }
.upg-note { font-size: .8rem; color: var(--muted, #5C6E85); margin-bottom: 14px; }
.upg-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.upg-chips span { padding: 4px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; background: #E5F7EC; color: #1C8A4B; }
.upg-feats { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 9px; flex: 1; }
.upg-feats li { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; color: var(--ink-70, #3B4A5E); }
.upg-feats svg { flex: none; margin-top: 2px; color: #1C8A4B; }
.upg-card .btn { width: 100%; }

/* ---- Overview chart wrapper ---- */
.chart-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }

/* =========================================================================
   TABLET + PHONE (up to 900px): the sidebar becomes a slide-in drawer
   ========================================================================= */
@media (max-width: 900px) {
  .dash-sidebar {
    position: fixed; top: 0; left: 0; width: min(82vw, 300px); height: 100vh; height: 100dvh;
    transform: translateX(-105%); box-shadow: none; transition: transform .28s ease, box-shadow .28s ease;
  }
  .dash-sidebar.open { transform: translateX(0); box-shadow: 0 0 44px rgba(0, 0, 0, .38); }
  .dash-sidebar { overflow-y: auto; overscroll-behavior: contain; gap: 18px; padding: 20px 16px; -webkit-overflow-scrolling: touch; }
  .dash-sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; flex: none; }
  .dash-content { padding: 20px 16px 64px; }
  .dash-topbar { padding: 10px 14px; gap: 10px; }
  .dash-topbar > div:first-child { min-width: 0; gap: 10px !important; }
  .dash-topbar h1 { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dash-topbar-right { gap: 8px; flex: none; }
  /* The balance does not belong in the phone header (it is on the overview cards); the site link lives in the menu + overview */
  .wallet-chip, #visit-site-btn { display: none !important; }
  .avatar { width: 34px; height: 34px; font-size: .82rem; }

  .stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 22px; }
  .stat-card { padding: 14px; }
  .stat-card .label { font-size: .76rem; margin-bottom: 6px; }
  .stat-card .value { font-size: 1.15rem; overflow-wrap: anywhere; }
  .dash-grid { grid-template-columns: 1fr; gap: 18px; }
  .panel { padding: 18px 16px; }
  .panel h3 { font-size: 1rem; }
  .chart-box { height: 260px; }
  .upg-grid { grid-template-columns: 1fr; }
  .store-card { padding: 16px; }
  .store-card .sc-actions { width: 100%; }
  .store-card .sc-actions .btn { flex: 1; justify-content: center; }
}
@media (max-width: 700px) {
  .chart-box { height: 230px; }
  .chart-period-toggle { width: 100%; }
  .chart-period-toggle button { flex: 1; padding: 8px 4px; }
  .chart-head > h3 { flex: 1 1 100%; }
  .upg-price { font-size: 1.75rem; }
  .qb-bundle-grid, .network-pill-select { gap: 8px; }
}
@media (max-width: 360px) {
  .stat-cards { grid-template-columns: 1fr; }
  .dash-content { padding: 16px 12px 60px; }
}

/* =========================================================================
   PHONE TWEAKS for the public pages and the settings forms
   ========================================================================= */
@media (max-width: 700px) {
  .section { padding: 56px 0; }
  .section-tight { padding: 40px 0; }
  .auth-card { padding: 28px 20px; }
  .repeater-row { grid-template-columns: 1fr auto; }
  .repeater-row > :nth-child(2) { grid-column: 1 / 2; grid-row: 2; }
  .repeater-row > :nth-child(3) { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
  .settings-section { padding: 16px 14px 4px; }
  .settings-section-head { flex-wrap: wrap; }
  .content-block-body { padding: 14px; }
}
@media (max-width: 480px) {
  .hero-copy h1 { font-size: 1.95rem; }
  .section-head h2 { font-size: 1.5rem; }
}
