
/* ==========================================================================
   Snap Pay - responsive fixes
   Load on every layout, after stylesheet.css and snap-custom.css.
   ========================================================================== */

/* --- 1. Page shell ------------------------------------------------------- */

/* 1.1 Sticky header. The theme sets html,body{height:100%}; a sticky child of a
   viewport-tall body stops sticking after one screen of scrolling. */
html { height: auto; }
body { height: auto; min-height: 100vh; }

@media (max-width: 991.98px) {
  /* 1.2 Keep the header bar in the page flow. The theme floats .primary-menu
     over the page; here that element wraps the logo and toggler too. */
  #header .primary-menu.navbar { position: relative; top: auto; left: auto; right: auto; }
  /* The theme's 65vh scroll box and 18px margins were meant for the menu only. */
  #header .primary-menu > .container { max-height: none; overflow: visible; margin-top: 0; margin-bottom: 0; }
  #header #mainNav { max-height: calc(100vh - 96px); max-height: calc(100dvh - 96px); overflow-y: auto; overscroll-behavior: contain; }
  /* Compact logo: the bar becomes about 67px tall instead of about 116px. */
  #header #header-nav .snap-logo { width: 90px; height: 56px; }

  /* 1.3 Hamburger: 44px target, three bars, X when open. */
  #header .navbar-toggler { width: 44px; height: 44px; padding: 0; margin: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgba(0,0,0,.12); border-radius: 10px; transform: none; }
  #header .navbar-toggler .navbar-toggler-icon { position: static; display: block; width: 24px; height: 24px; top: auto; left: auto; opacity: 1; transform: none; border-radius: 0; background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%231f2937' stroke-linecap='round' stroke-width='2.2' d='M4 8h22M4 15h22M4 22h22'/%3e%3c/svg%3e") center / 24px 24px no-repeat; }
  #header .navbar-toggler[aria-expanded="true"] .navbar-toggler-icon { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%231f2937' stroke-linecap='round' stroke-width='2.2' d='M7 7l16 16M23 7L7 23'/%3e%3c/svg%3e"); }

  /* 1.4 Bell and avatar inside the open menu: one full-width row each. */
  #header #mainNav .snap-user { flex-direction: column !important; align-items: stretch !important; margin: .25rem 0 0; padding: .25rem 0 .5rem; border-top: 1px solid #e9ecef; }
  #header #mainNav .snap-user > .nav-item { display: block; height: auto; margin: 0 !important; }
  #header #mainNav .snap-user > .nav-item > .nav-link { display: flex; align-items: center; gap: .6rem; min-height: 48px; height: auto; padding: .5rem 0 !important; }
  #header #mainNav .nav-bell .count { position: static; margin-left: .15rem; }
  #header #mainNav .snap-user .dropdown-menu { position: static; float: none; width: 100%; min-width: 0; max-height: none; overflow: visible; margin: 0; padding: 0 0 .5rem .5rem; box-shadow: none; transform: none; }
  /* The active-link accent bar is only positioned for the desktop layout. */
  #header #mainNav .navbar-nav > li > a::after { content: none; }
}

/* 1.5 Signed-in desktop nav between 992px and 1199px. */
#header .primary-menu ul.navbar-nav > li > a:not(.btn) { white-space: nowrap; }
@media (min-width: 992px) and (max-width: 1199.98px) {
  #header .primary-menu ul.navbar-nav > li > a:not(.btn) { padding-left: .5em; padding-right: .5em; font-size: .8125rem; }
  #header #header-nav .snap-logo { width: 128px; height: 80px; }
}

/* 1.6 Back-to-top sits on top of bottom-right actions on phones. */
@media (max-width: 575.98px) { #back-to-top { display: none !important; } }

/* --- 2. No sideways scrolling -------------------------------------------- */

/* 2.1 .row.g-5 inside a default .container is 12px wider than a phone screen. */
@media (max-width: 575.98px) { .row.g-5, .row.gx-5 { --bs-gutter-x: 1.5rem; } }

/* 2.2 Home hero: the decorative circle moves to the overlay, which can clip it,
   so the hero itself can stay overflow:visible for the currency dropdowns.
   Needs class "hero-wrap--home" on the home page hero section. */
.hero-wrap--home::after { content: none; }
.hero-wrap--home .hero-overlay { overflow: hidden; }
.hero-wrap--home .hero-overlay::after { content: ""; position: absolute; right: -140px; top: -140px; width: 420px; height: 420px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.14), transparent 65%); pointer-events: none; }

/* 2.3 A form used as a card. The theme sets form{display:inline}. */
form.gp-card { display: block; }

/* 2.4 Provider tiles on the wallet pay-out page. */
label.prov-tile { min-width: 0; }
@media (max-width: 359.98px) { label.prov-tile { padding-left: .4rem; padding-right: .4rem; } .prov-tile .prov-name { font-size: .75rem; } }

/* --- 3. Account pages: sidebar becomes a chip strip below 992px ---------- */
@media (max-width: 991.98px) {
  #content aside.col-lg-3 > .text-center { display: none; }
  #content aside.col-lg-3 { display: flex; gap: .5rem; overflow-x: auto; margin-bottom: 1rem !important; padding-bottom: .25rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  #content aside.col-lg-3::-webkit-scrollbar { display: none; }
  #content aside.col-lg-3 > .bg-white { flex: 0 0 auto; margin: 0 !important; padding: 0 !important; background: transparent !important; box-shadow: none !important; }
  #content aside.col-lg-3 > .bg-white > .d-flex { display: none !important; }
  #content aside.col-lg-3 .list-group { flex-direction: row; gap: .5rem; }
  /* Rounded rectangles, not pills (UI standards); active fill is green-dark for contrast. */
  #content aside.col-lg-3 .list-group-item { width: auto; white-space: nowrap; display: inline-flex; align-items: center; min-height: 44px; padding: .5rem .9rem; border: 1px solid #e5e0d8 !important; border-radius: 10px !important; background: #fff; font-size: .875rem; }
  #content aside.col-lg-3 .list-group-item.active { background: #1f8f46; color: #fff; border-color: transparent !important; }
}

/* --- 4. Tables on phones -------------------------------------------------- */
@media (max-width: 767.98px) {
  /* 4.1 Generic: add class "table-stack" and data-label="Column name" on each td. */
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: .75rem 1rem; border-bottom: 1px solid #e7ecf2; }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack td { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .2rem 0 !important; border: 0 !important; text-align: right; font-size: .9375rem; }
  .table-stack td::before { content: attr(data-label); flex: 0 0 auto; text-align: left; font-size: .75rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #64748b; }
  .table-stack td:not([data-label])::before, .table-stack td[data-label=""]::before { content: none; }
  .table-stack td code, .table-stack td .mx-mono { display: inline-block; max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
  .table-stack td[colspan] { justify-content: center; text-align: center; }
  /* Added: a row's title cell (no label, reads as the card heading) and its buttons cell. */
  .table-stack td.ts-head { display: block; text-align: left; font-weight: 600; }
  .table-stack td.ts-head .small, .table-stack td.ts-head div { font-weight: 400; }
  .table-stack td.ts-actions { justify-content: flex-end; flex-wrap: wrap; gap: .5rem; padding-top: .5rem !important; }

  /* 4.2 Payment rows as compact cards: add class "table-cards" and the cell
     classes c-amount, c-status, c-party, c-date, c-ref, c-fee, c-hide. */
  .table-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .table-cards, .table-cards tbody { display: block; width: 100%; }
  .table-cards tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "amount status" "party date" "ref fee"; gap: 2px 12px; align-items: baseline; padding: .75rem 1rem; border-bottom: 1px solid #e7ecf2; }
  .table-cards td { display: block; padding: 0 !important; border: 0 !important; min-width: 0; }
  .table-cards .c-amount { grid-area: amount; font-size: 1.0625rem; font-weight: 700; color: #15212e; }
  .table-cards .c-status { grid-area: status; justify-self: end; }
  .table-cards .c-party { grid-area: party; font-size: .9375rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .table-cards .c-party > * { display: inline; font-weight: 500 !important; }
  .table-cards .c-date { grid-area: date; justify-self: end; font-size: .8125rem; color: #64748b; white-space: nowrap; }
  .table-cards .c-ref { grid-area: ref; font-size: .8125rem; }
  .table-cards .c-ref code { display: inline-block; max-width: 13ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
  .table-cards .c-fee { grid-area: fee; justify-self: end; font-size: .8125rem; color: #64748b; white-space: nowrap; }
  .table-cards .c-fee::before { content: "Fee "; }
  .table-cards .c-hide { display: none; }
  .table-cards td[colspan] { grid-column: 1 / -1; text-align: center; }
  /* Added: a failure reason under the status gets its own full-width line at the bottom of the
     card instead of squeezing the amount (the status cell's children join the grid). */
  .table-cards tr { grid-template-areas: "amount status" "party date" "ref fee" "note note"; }
  .table-cards .c-amount { white-space: nowrap; }
  .table-cards td.c-status { display: contents; }
  .table-cards .c-status > .mx-st, .table-cards .c-status > .badge { grid-area: status; justify-self: end; }
  .table-cards .c-status > div { grid-area: note; max-width: none !important; margin-top: .25rem !important; }
}

/* --- 5. Merchant portal --------------------------------------------------- */
.mx-hero p .mx-mono { display: inline-block; white-space: nowrap; }
.mx-page .row > .col-6 > .card { height: 100%; }
@media (max-width: 767.98px) {
  /* Tabs: icon over label for every tab, still one scrolling row. */
  .mx-page nav.mx-tabs { scroll-snap-type: x proximity; }
  .mx-page nav.mx-tabs a { flex: 0 0 auto; flex-direction: column; justify-content: center; gap: 3px; min-width: 70px; min-height: 52px; padding: 6px 8px; font-size: 12px; scroll-snap-align: center; }
  .mx-page nav.mx-tabs a span { display: inline; }
  .mx-page nav.mx-tabs a i { font-size: 15px; }
  /* Fade at the right edge says the tab bar scrolls. */
  .mx-tabs { -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }
  .mx-tabs.at-end { -webkit-mask-image: none; mask-image: none; }
}
@media (max-width: 575.98px) {
  /* One field per row in merchant forms. */
  .mx-page form .row > [class^="col-"], .mx-page form .row > [class*=" col-"] { flex: 0 0 100%; width: 100%; max-width: 100%; }
  /* A submit button followed by help text: button full width, text below it. */
  .mx-page form > .btn { display: block; width: 100%; }
  .mx-page form > .btn + .form-text { display: block; margin: .5rem 0 0 !important; }
}

/* --- 6. Forms and actions on phones --------------------------------------- */
@media (max-width: 575.98px) {
  /* 16px text stops iOS zooming the page on focus; 48px is a comfortable tap height. */
  .form-control, .form-select { font-size: 1rem; min-height: 48px; }
  .card-footer.d-flex { flex-direction: column-reverse; align-items: stretch; }
  .card-footer.d-flex > .btn { width: 100%; }

  /* TT-1 (Phase 5): hit areas of at least 44px on phones. */
  .btn, .btn-sm { min-height: 44px; }
  .btn-sm { display: inline-flex; align-items: center; justify-content: center; }
  footer .list-unstyled li { margin-bottom: 0 !important; }
  footer .list-unstyled a { display: inline-block; padding: .6rem 0; min-height: 44px; }
  footer a[target="_blank"] { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; margin-left: 0 !important; }
  .card-header a.small, .mx-card-hd a, .card-header .btn-link { display: inline-flex; align-items: center; min-height: 44px; }
  .form-check { min-height: 44px; display: flex; align-items: center; gap: .5rem; padding-left: 0; }
  .form-check .form-check-input { float: none; margin: 0; width: 1.25em; height: 1.25em; flex: 0 0 auto; }
  .form-switch .form-check-input { width: 2.25em; }
  .table code a, td > a:not(.btn) { display: inline-block; padding: .35rem 0; }

  /* TT-2: nothing under 12px. */
  .badge, .table thead th, .mx-page .table thead th, small, .small { font-size: max(.75rem, 1em * .875); }
  .form-text { font-size: .8125rem; }
  .input-group-sm > .form-control, .input-group-sm > .form-select, .input-group-sm > .input-group-text, .input-group-sm > .btn { font-size: 1rem; min-height: 48px; }
}
@media (max-width: 991.98px) {
  /* Menu rows in the open phone menu: 44px each. */
  #header #mainNav .navbar-nav > li > a:not(.btn) { min-height: 44px; display: flex; align-items: center; }
  #header #mainNav > .btn { min-height: 44px; display: inline-flex; align-items: center; margin-top: .5rem; margin-bottom: .5rem; }
}

/* Full-width primary buttons on phones (Save changes, Save profile, New request). */
@media (max-width: 575.98px) { .btn-block-xs { display: block; width: 100%; } }

/* Status as a coloured word (UI standards), for account pages. */
.st-word { font-weight: 600; } .st-ok { color: #1f8f46; } .st-wait { color: #8a5600; } .st-bad { color: #c2271f; }

/* --- 7. Page-specific -------------------------------------------------------- */
/* Request funds: option title and description on separate lines. */
.rq-mode .m label .t, .rq-mode .m label .d { display: block; }
.rq-mode .m label .d { margin-top: .25rem; }
/* Request funds: flag inline in the "Who receives" heading, country name capitalised. */
h6 .rq-flag { display: inline-block; vertical-align: -3px; }
h6 #recip_country_name { text-transform: none; }
/* Wallet heroes: the global p{color} rule turns the subtitle dark on green. */
.gp-hero p { color: #fff; }
@media (max-width: 575.98px) {
  /* Send / Request switch: two equal halves. */
  .snap-sr-tabs > .d-flex > .nav { width: 100%; display: flex; }
  .snap-sr-tabs > .d-flex > .nav > .nav-item { flex: 1 1 0; text-align: center; }
  /* /send breakdown: one row per figure, label left and value right. */
  .send-summary { flex-direction: column; gap: .35rem !important; }
  .send-summary > span { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; text-align: left !important; }
  .send-summary > span > br { display: none; }
}
/* Transactions list. */
@media (max-width: 575.98px) {
  .transaction-item { padding-left: 1rem !important; padding-right: 1rem !important; }
  .transaction-item .text-4 { font-size: 1rem; }
  .transaction-item .text-muted.text-2 { font-size: .8125rem; overflow-wrap: anywhere; }
  /* Transactions toolbar: range and statement on one row, statement as a 44px icon button. */
  .tx-toolbar #customRange { flex: 1 1 100%; order: 3; flex-wrap: wrap; }
  .tx-toolbar > .dropdown > .btn { min-height: 44px; }
  .tx-toolbar > .dropdown.ms-auto > .btn { min-width: 44px; }
  .transaction-item .tx-receipt { display: inline-flex; align-items: center; min-height: 44px; }
}

/* Wallet sub-nav: one sideways-scrolling row on phones instead of three or four wrapped rows. */
@media (max-width: 767.98px) {
  .sc-subnav { flex-wrap: nowrap !important; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .sc-subnav::-webkit-scrollbar { display: none; }
  .sc-subnav > .btn { flex: 0 0 auto; white-space: nowrap; min-height: 44px; display: inline-flex; align-items: center; }
}
/* Long submit labels ("Proceed to Card Checkout") break evenly instead of leaving one word. */
#submitLabel { display: inline-block; max-width: 100%; vertical-align: middle; text-wrap: balance; }

