/* ==========================================================================
   responsive-fix.css (v15.13) - ONE shared responsive layer for the whole
   platform: public pages, customer area, admin panel and manager portal.
   It is appended LAST to <head> of every HTML page by config/bootstrap.php
   (app_html_filter), so no individual page needs editing.
   ========================================================================== */

/* 1. Page scrolling: html/body must never trap vertical scroll ------------- */
html{height:auto;min-height:100%;overflow-x:hidden;overflow-y:auto;-webkit-text-size-adjust:100%}
body{height:auto;min-height:100%;max-width:100%;overflow-x:clip;overflow-y:visible;position:relative}
@supports not (overflow:clip){body{overflow-x:hidden}}
img,svg,video,canvas,iframe,embed,object,picture{max-width:100%}
img,video{height:auto}

/* 2. Text must never be squeezed into a one-letter column -------------------
   (the old universal "min-width:0" is gone; only things that SHOULD shrink do) */
input,select,textarea,pre,code,img,svg,canvas,video,iframe,table,.table-wrap,.table-responsive,.tbl-wrap,.table-container,
.chart-box,.chart-wrap,[class*="chart"],.w-addr,.wallet-addr,.address,.addr{min-width:0}
h1,h2,h3,h4,h5,h6,p,li,label,td,th,dd,dt,span,a,button,.btn{writing-mode:horizontal-tb;text-orientation:mixed}
h1,h2,h3,h4,h5,h6,p,li,dd,dt,label{overflow-wrap:break-word;word-break:normal}
/* flex children that hold text keep a readable minimum width */
.card>*,.panel>*,.stat-card>*,.trader-card>*,.lb-card>*,.info-card>*{max-width:100%}

/* 3. Containers fit the screen ------------------------------------------------ */
.container,.page,.wrap,.wrapper,.main-content,.main,.admin-main,.mgr-main,.content,.page-content,.x-main{max-width:100%}
@media(max-width:1024px){
  .main-content,.admin-main,.mgr-main,.x-main{margin-left:0!important;width:100%!important;max-width:100%!important}
  .admin-wrapper,.container{flex-wrap:nowrap}
}

/* 4. Multi-column blocks collapse to readable columns on small screens ------ */
@media(max-width:900px){
  .balance-strip,.stats-grid,.metric-grid,.x-stats,.stats-row,.cards-grid,.form-grid,.form-row,.grid-3,.grid-4,.g3,.g4,
  .provider-layout,.perf-layout,.lb-grid,.settings-grid,.two-col,.three-col,.split{
    grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr))!important}
  .provider-layout,.perf-layout,.two-col,.split,.g2,.grid-2{grid-template-columns:1fr!important}
  [style*="grid-template-columns:1fr 1fr 1fr"],[style*="grid-template-columns: 1fr 1fr 1fr"],[style*="grid-template-columns:repeat(3"],[style*="grid-template-columns:repeat(4"],[style*="grid-template-columns:2fr 1fr"],[style*="grid-template-columns:1fr 2fr"]{
    grid-template-columns:repeat(auto-fit,minmax(min(100%,200px),1fr))!important}
}
@media(max-width:600px){
  .balance-strip,.stats-grid,.metric-grid,.x-stats,.stats-row,.cards-grid,.form-grid,.form-row,.lb-grid{grid-template-columns:1fr 1fr!important}
  /* v15.18.28: settings forms are ONE column on phones (two columns cut the fields off at the right edge) */
  .settings-grid{grid-template-columns:minmax(0,1fr)!important}
  .settings-grid>*{min-width:0}
  .traders-grid{grid-template-columns:1fr!important}   /* trader cards need the full width on phones */
  .trader-card-stats{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  [style*="grid-template-columns"]{grid-template-columns:1fr!important}
  .page,.main-content,.admin-main,.mgr-main{padding-left:.8rem!important;padding-right:.8rem!important}
}
@media(max-width:380px){.balance-strip,.stats-grid,.metric-grid,.x-stats,.stats-row,.cards-grid,.form-grid,.lb-grid{grid-template-columns:1fr!important}}
@media(max-width:900px){
  [style*="display:flex"],.flex-row,.row{flex-wrap:wrap}
  [style*="min-width:"]{min-width:0!important}
  [style*="width:"][style*="px"]:not(img):not(svg):not(canvas):not(i){max-width:100%}
}

/* 5. Tables scroll inside their own box; cells keep a readable width --------- */
.table-wrap,.table-responsive,.tbl-wrap,.table-container,.x-table-wrap,.card-body:has(>table),.tbl,.table-scroll{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
@media(max-width:900px){
  table{max-width:100%}
  table:not(.no-scroll){display:block;overflow-x:auto;-webkit-overflow-scrolling:touch}
  th,td{min-width:78px;max-width:340px;word-break:normal;overflow-wrap:break-word;vertical-align:middle}
  th:first-child,td:first-child{min-width:60px}
  td .badge,td .status,td .tag,td .btn,td button,td a.btn{white-space:nowrap}
}

/* 6. Pop-ups: scroll inside the screen, never cut off ------------------------ */
.modal-overlay,.modal-backdrop,.moverlay,.modal-bg,.pl-back{overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain}
.modal,.modal-box,.modal-content,.modal-panel,.x-modal{max-width:calc(100vw - 1.2rem);max-height:calc(100vh - 1.5rem);max-height:calc(100dvh - 1.5rem);overflow-y:auto;-webkit-overflow-scrolling:touch}
@media(max-width:600px){
  .modal-overlay,.modal-backdrop,.moverlay,.modal-bg{align-items:flex-start!important;padding:.6rem!important}
  .modal,.modal-box,.modal-content,.modal-panel,.x-modal{width:100%!important;margin:auto}
  .modal-footer,.modal-actions{flex-wrap:wrap}
  .modal-footer>*,.modal-actions>*{flex:1 1 140px}
}

/* 7. Forms & buttons ----------------------------------------------------------- */
input,select,textarea{max-width:100%}
@media(max-width:768px){input,select,textarea{font-size:16px}
  .btn-group,.actions,.btn-row,.action-row,.form-actions{display:flex;flex-wrap:wrap;gap:.5rem}
  .btn,button{min-height:40px}}

/* 8. Tab strips / sub navigation: scroll sideways instead of stacking ---------- */
@media(max-width:900px){
  .tabs,.tab-nav,.tab-bar,.tab-list,.section-tabs,.subnav-container,.ct-tabs,.nav-tabs,.tab-buttons{display:flex;flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;scrollbar-width:none}
  .tabs>*,.tab-nav>*,.tab-bar>*,.tab-list>*,.section-tabs>*,.subnav-container>*,.ct-tabs>*,.nav-tabs>*,.tab-buttons>*,.tab-btn,.tab,.section-tab{flex:0 0 auto;white-space:nowrap}
}

/* 9. Announcement banner (config/platform_guard.php) ---------------------------- */
.pg-ann{display:flex;gap:.7rem;align-items:flex-start;margin:0 0 1rem;padding:.85rem 1rem;border-radius:12px;border:1px solid var(--pg-c,#0A84FF);background:rgba(10,132,255,.1);color:inherit;line-height:1.5;font-size:.92rem;overflow-wrap:break-word;word-break:normal}
.pg-ann i{color:var(--pg-c,#0A84FF);margin-top:.15rem}.pg-ann div{flex:1 1 auto}

/* 10. Mandatory deposit security notice ------------------------------------------ */
.pg-dep-gate{position:fixed;inset:0;z-index:2147483000;background:rgba(0,0,0,.82);display:flex;align-items:flex-start;justify-content:center;padding:1rem;overflow-y:auto;-webkit-overflow-scrolling:touch}
.pg-dep-gate[hidden]{display:none!important}
.pg-dep-box{margin:auto;width:100%;max-width:520px;background:var(--bg-card,#1c1c1e);color:var(--text-primary,var(--text-main,#fff));border:1px solid var(--danger,#FF9F0A);border-radius:16px;padding:1.4rem;box-shadow:0 20px 60px rgba(0,0,0,.6);font-family:inherit}
.pg-dep-box h3{display:flex;gap:.6rem;align-items:center;margin:0 0 .8rem;font-size:1.1rem;color:var(--orange,#FF9F0A)}
.pg-dep-box .pg-dep-txt{line-height:1.6;font-size:.95rem;overflow-wrap:break-word}
.pg-dep-box label{display:flex;gap:.6rem;align-items:flex-start;margin:1rem 0;font-size:.9rem;cursor:pointer}
.pg-dep-box input[type=checkbox]{width:20px;height:20px;flex:0 0 auto;margin-top:.1rem}
.pg-dep-btns{display:flex;gap:.6rem;flex-wrap:wrap}
.pg-dep-btns button,.pg-dep-btns a{flex:1 1 140px;padding:.75rem;border-radius:10px;border:0;font-weight:600;font-size:.95rem;cursor:pointer;text-align:center;text-decoration:none;font-family:inherit}
.pg-dep-btns .ok{background:var(--secondary,#30D158);color:#fff}.pg-dep-btns .ok[disabled]{opacity:.45;cursor:not-allowed}
.pg-dep-btns .no{background:var(--bg-elevated,#2c2c2e);color:inherit;border:1px solid var(--border,#38383a)}
body.pg-dep-locked{overflow:hidden!important}

/* ===== v15.13.6 mobile fixes ================================================= */
/* A. Sideways scroll: if anything is wider than the phone, the page can be swiped left/right instead of being cut off */
@media(max-width:900px){
  html,body{overflow-x:auto!important;-webkit-overflow-scrolling:touch}
  .detail-layout,.hero-grid,.profit-row,.main-grid,.two-col,.grid-2,.grid-3,.grid-4{grid-template-columns:minmax(0,1fr)!important}
  .hero-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .detail-layout>*,.hero-grid>*,.profit-row>*,.main-grid>*,.two-col>*,.grid-2>*,.grid-3>*,.grid-4>*{min-width:0}
  .card,.panel,.hero-card{max-width:100%}
  .card:has(table),.panel:has(table),.card:has(.table-wrap){overflow-x:auto;-webkit-overflow-scrolling:touch}
  .main-content,.admin-main,.mgr-main,.page{max-width:100vw;overflow-x:auto}
  pre,.code-block{overflow-x:auto}
}
/* B. Pop-ups on phones: the overlay scrolls, the box is never taller than needed, last button always reachable */
@media(max-width:900px){
  .moverlay,.modal-overlay,.modal-backdrop,.modal-bg,.pl-back,.overlay.open,[class*="modal"][class*="overlay"],[class*="modal"][class*="backdrop"]{
    overflow-y:auto!important;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;
    align-items:flex-start!important;justify-content:center;
    padding:.6rem .6rem calc(5rem + env(safe-area-inset-bottom,0px))!important}
  .moverlay>.modal,.modal-overlay>.modal,.modal-backdrop>.modal,.modal-bg>.modal,.moverlay>*,.modal-overlay>*,.modal-backdrop>*{
    max-height:none!important;overflow:visible!important;margin:auto!important;width:100%;max-width:min(560px,100%)}
}

/* 5. v15.17 Toast / pop-up messages on phones: shown at the BOTTOM, centred, ABOVE the fixed bottom nav bar and the chat button
   (nav ~65px, chat button top ~139px), above the safe-area inset, always fully inside the screen and never wider than the screen. ---- */
@media(max-width:1024px){
  #toast,.toast{position:fixed!important;top:auto!important;right:auto!important;left:50%!important;
    bottom:calc(9.5rem + env(safe-area-inset-bottom,0px))!important;
    transform:translateX(-50%) translateY(24px)!important;width:max-content!important;min-width:0!important;
    max-width:calc(100vw - 2rem)!important;box-sizing:border-box;white-space:normal!important;overflow-wrap:anywhere;
    text-align:center;justify-content:center;z-index:2147483000!important;pointer-events:none!important;
    box-shadow:0 12px 40px rgba(0,0,0,.45)}
  #toast.show,.toast.show,#toast.visible,.toast.visible,#toast.active,.toast.active{transform:translateX(-50%) translateY(0)!important}
}
@media(max-width:768px){
  /* the page can always scroll far enough: content ends above the fixed bottom nav + safe area (no extra gap on desktop) */
  .main-content,.page,.page-content{padding-bottom:calc(90px + env(safe-area-inset-bottom,0px))!important}
  .mob-bottom-nav{height:auto!important;min-height:62px;padding-bottom:env(safe-area-inset-bottom,0px);box-sizing:border-box}
  /* in-page success / error banners and sticky action bars stay clear of the nav */
  .flash-msg,.alert,.msg-box{scroll-margin-bottom:100px}
}

/* v15.17 DESKTOP FIX: on desktop the main area sits next to the fixed sidebar. It must shrink to the space that is left
   (viewport minus the sidebar margin) instead of being 100% wide + the sidebar margin, which pushed the header
   (search, bell, user menu) off the right edge. Mobile keeps its own rules above. */
@media (min-width:1025px){
  html,body{overflow-x:hidden}
  .main-content,.admin-main,.mgr-main,.x-main{min-width:0!important;max-width:none!important;width:auto!important;box-sizing:border-box;overflow-x:clip}
  .header{gap:1rem;flex-wrap:nowrap}
  .header-left{min-width:0;flex:1 1 auto}
  .header-left h2{overflow-wrap:anywhere}
  .header-right{flex:0 0 auto;min-width:0}
  .header-right .search-box input{width:clamp(150px,16vw,300px)}
  .user-profile{flex-shrink:0}
}

/* ---- v15.18.4: pop-ups scroll by TOUCH anywhere on phones / tablets (site-wide) - replaces the v15.18.2 rules ----
   WHY v15.18.2 DID NOT HOLD: it made the pop-up PANEL a scroll area (overflow:auto + overscroll-behavior:contain). On a real phone the
   fractional layout makes that panel ~1px taller than its box, so it becomes a 1px scroller: a finger on the form scrolls that 1px,
   "contain" refuses to hand the swipe up, and nothing moves. Only a finger on the strip OUTSIDE the panel (the overlay itself) scrolled.
   NOW: the OVERLAY is the one and only scroll area (exactly like the side menu). The panel and the header / body / footer inside it
   are plain content - never a scroll container, never "contain". Inner lists that are meant to scroll keep working and hand the
   swipe on when they reach their end. assets/js/mobile-fix.js adds a safety net for any pop-up whose markup is different. */
@media(max-width:1024px){
  :is(.modal-overlay,.moverlay,.modal-backdrop,.modal-bg,.pl-back,#requestManagerModal,#wd-otp-overlay,#otp-overlay,#__annOv,[data-pop]){
    overflow-x:hidden!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch;
    overscroll-behavior-y:contain!important;touch-action:auto!important;
    align-items:flex-start!important;justify-content:center}
  :is(.modal-overlay,.moverlay,.modal-backdrop,.modal-bg,.pl-back,#requestManagerModal,#wd-otp-overlay,#otp-overlay,#__annOv,[data-pop])>*{overflow:visible!important;overflow:clip!important}
  :is(.modal-overlay,.moverlay,.modal-backdrop,.modal-bg,.pl-back,#requestManagerModal,#wd-otp-overlay,#otp-overlay,#__annOv,[data-pop])>*,
  :is(.modal-overlay,.moverlay,.modal-backdrop,.modal-bg,.pl-back,#requestManagerModal,#wd-otp-overlay,#otp-overlay,#__annOv,[data-pop])>*>*:not(textarea):not(select):not(input):not(pre):not(table):not(.table-wrap):not(.table-scroll):not(.x-scroll){
    max-height:none!important;overscroll-behavior:auto!important;touch-action:auto!important;-webkit-overflow-scrolling:auto}
  :is(.modal-overlay,.moverlay,.modal-backdrop,.modal-bg,.pl-back,#requestManagerModal,#wd-otp-overlay,#otp-overlay,#__annOv,[data-pop])>*>*:not(textarea):not(select):not(input):not(pre):not(table):not(.table-wrap):not(.table-scroll):not(.x-scroll){overflow:visible!important}
  :is(.modal-overlay,.moverlay,.modal-backdrop,.modal-bg,.pl-back,#requestManagerModal,#wd-otp-overlay,#otp-overlay,#__annOv,[data-pop])>*{margin-top:auto!important;margin-bottom:auto!important}
  /* a panel that is itself called .modal must not inherit the "leave room for the bottom bar" offset meant for full-screen overlays (it shifted relative-positioned panels up 64px, hiding their header) */
  :is(.modal-overlay,.moverlay,.modal-backdrop,.modal-bg,.pl-back,#requestManagerModal,#wd-otp-overlay,#otp-overlay,#__annOv,[data-pop])>.modal{bottom:auto!important;top:auto!important}
  /* anything deeper that scrolls on purpose must pass the swipe on at its ends */
  :is(.modal-overlay,.moverlay,.modal-backdrop,.modal-bg,.pl-back,#requestManagerModal,#wd-otp-overlay,#otp-overlay,#__annOv,[data-pop]) *{overscroll-behavior-y:auto}
}

/* ===== v15.18.15 - tables never stack text letter by letter (desktop AND phones, customer / admin / manager) =====
   Cause: cells were allowed to break inside a word (overflow-wrap:anywhere on .mono and on link / e-mail / hash classes), so the browser
   squeezed a column to one character and the text ran vertically. Now: no mid-word breaks in cells, headers stay on one line, short values
   (IDs, prices, amounts, dates, badges, buttons) stay on one line, and a table that is wider than its box scrolls sideways inside it. */
table th,table td{overflow-wrap:normal!important;word-break:normal!important;hyphens:none}
table th{white-space:nowrap}
table :is(.mono,.num,.nowrap,.amount,.balance,.money,.price,.badge,.status,.tag,time,.btn,.action-btn,.btn-sm){white-space:nowrap;overflow-wrap:normal!important;word-break:normal!important}
table td:has(>.mono),table td.mono{white-space:nowrap}
/* long tokens (wallet, hash, e-mail, link) still wrap, but never below a readable width */
table :is(a[href^="mailto:"],a[href^="http"],.hash,.txid,.tx-hash,.address,.addr,.wallet,.wallet-address,.email,.url,.ref-code,.referral-link,[class*="address"],[class*="txid"],[class*="wallet-addr"]){display:inline-block;min-width:7rem;max-width:100%;vertical-align:top}
/* dense tables: less side padding so more columns fit before the table has to scroll */
table.data-table th,table.data-table td{padding-left:1rem;padding-right:1rem}
/* a box that holds a table scrolls sideways instead of clipping or squeezing it */
:is(div,section):has(>table){max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}


/* ===== v15.18.30 - NO MORE "LETTER BY LETTER" TEXT IN ROWS (site-wide: customer, admin, manager) =====
   Cause: rule 4 above zeroes every inline min-width on phones, so a flex row such as  [icon] [title + text] [badges] [button]
   squeezed the title/text block to a sliver (one word or one letter per line). Now a block that holds text keeps a readable minimum
   width; if the row is too narrow the block moves to its OWN full-width line and the badges / buttons wrap underneath it. */
@media(max-width:900px){
  /* flex children that are meant to grow (inline flex:1 / flex-grow) keep a readable basis and drop to their own line when needed */
  [style*="display:flex"]>[style*="flex:1"],[style*="display:flex"]>[style*="flex: 1"],[style*="display:flex"]>[style*="flex-grow"]{
    flex:1 1 min(100%,11rem)!important;min-width:min(100%,9rem)!important}
  /* any block of text (title / paragraph / small) inside a flex row: never narrower than ~9rem */
  [style*="display:flex"]>:is(div,span,section,article):has(>:is(strong,b,h1,h2,h3,h4,h5,h6,p,small)),
  :is(.flex,.d-flex,.flex-row,.row,.card-head,.card-header,.panel-head,.panel-header,.item-row,.list-item,.info-row,.x-head)>:is(div,span):has(>:is(strong,b,h1,h2,h3,h4,h5,h6,p,small)){
    min-width:min(100%,9rem)!important}
  :is(.flex,.d-flex,.flex-row,.card-head,.card-header,.panel-head,.panel-header,.item-row,.list-item,.info-row){flex-wrap:wrap}
  /* titles and descriptions break between words, never inside a word / letter */
  :is(h1,h2,h3,h4,h5,h6,p,strong,small,label,li){word-break:normal;overflow-wrap:break-word;hyphens:none}
}

/* v15.18.31 - avatars / round icons / rank badges never shrink in a flex row (they were squeezed into thin gold slivers on phones).
   !important + attribute-free selectors so it also beats the older "min-width:0" mobile rules. */
:is(.user-avatar,.avatar,.profile-avatar,.trader-avatar,.lb-avatar,.rank-badge,.stat-card-icon,.nav-avatar,[class*="-avatar"]):not(img){flex-shrink:0!important;flex-grow:0}
:is(.user-avatar,.avatar,.profile-avatar,.trader-avatar,.lb-avatar,.stat-card-icon,[class*="-avatar"]):not(img):not([style*="width"]){min-width:2rem}

/* v15.18.32 - rows written as "display: flex" (with a space) wrap on phones exactly like "display:flex" rows, so no amount / button is pushed off the right edge */
@media(max-width:900px){[style*="display: flex"]{flex-wrap:wrap}}
