/* ==========================================================================
   global-overflow.css  (v14)
   One site-wide rule set that stops text overflow / overlapping text on every
   page (public, customer, admin, manager) on desktop AND phones.
   Loaded automatically by brand_head_tags() in config/branding.php.

   Design rules
   1. Text may WRAP at word boundaries first (overflow-wrap:break-word). It only
      breaks inside a word when a single token is wider than its box.
      (We deliberately do NOT use word-break:break-all / overflow-wrap:anywhere on
       general text - that splits numbers like "$168,237.52" into stacked pieces.)
   2. Known "long token" things (emails, wallet addresses, hashes, URLs, code)
      may break anywhere, because they have no spaces.
   3. Flex / grid children can shrink (min-width:0) so they never push siblings.
   4. Rows made of "label ... value" wrap and keep a gap, so the two never overlap.
   5. Pills, badges, tabs and buttons never wrap mid-label; long ones are clipped
      with an ellipsis instead of spilling over their neighbours.
   6. Tables scroll inside their own box instead of stretching the page.
   Low-specificity :where() is used where a page may legitimately override.
   ========================================================================== */

/* ---- 0. Foundations ---------------------------------------------------- */
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
html,body{max-width:100%;overflow-x:hidden}
img,svg,video,canvas,iframe,embed,object,picture{max-width:100%}
img,video{height:auto}
/* v15.13: universal min-width:0 removed (caused vertical text in narrow flex/grid columns) - scoped version lives in responsive-fix.css */

/* ---- 1. Normal text wraps instead of overflowing ------------------------ */
:where(h1,h2,h3,h4,h5,h6,p,li,dt,dd,label,legend,figcaption,blockquote,summary,
       td,th,caption,small,strong,b,em,span,a,button,.btn,
       .card,.panel,.box,.tile,.alert,.notice,.toast,.hint,.help,.desc,.description,.title,.subtitle,.label,.value,.name,.text){
  overflow-wrap:break-word;
  word-wrap:break-word;
  hyphens:manual;
}
/* wrapped headings / paragraphs need a sane line height or lines collide */
:where(h1,h2,h3,h4,h5,h6){line-height:1.25}
:where(p,li,dd,td,th,label){line-height:1.5}

/* ---- 2. Long unbroken tokens: break anywhere --------------------------- */
a[href^="mailto:"],a[href^="http"],code,kbd,samp,pre,
.hash,.txid,.tx-hash,.address,.addr,.wallet,.wallet-address,.email,.url,.link,.ref,.ref-code,.referral-link,
[class*="address"],[class*="hash"],[class*="wallet-addr"],[class*="txid"],[class*="email"],[class*="url"]{
  overflow-wrap:anywhere;
  word-break:break-word;
}
pre{white-space:pre-wrap;max-width:100%;overflow-x:auto}
/* v15.18.15: .mono / .code hold IDs, prices, amounts and SL/TP, not long tokens. "anywhere" shrinks a table cell's minimum width to ONE character,
   which stacked them letter by letter ("# 1 5", "$81, 596. 0000"). break-word still wraps a value that is wider than its box. */
.mono,.code{overflow-wrap:break-word;word-break:normal}

/* ---- 3. Cards / containers never let content escape -------------------- */
.card,.panel,.box,.tile,.widget,.section,.x-card,.stat-card,.stat,.info-card,.plan-card,.method-card,.modal-content,.modal-box,.x-modal{
  max-width:100%;
  overflow-wrap:break-word;
}

/* ---- 4. "label ... value" rows and header rows: wrap, keep a gap ------- */
.brow,.row-item,.info-row,.detail-row,.kv,.kv-row,.list-row,.summary-row,.stat-row,.data-row,
.card-header,.card-head,.section-header,.section-head,.panel-header,.page-header,.page-head,
.x-head,.top-bar,.toolbar,.filters,.filter-bar,.header-row,.pm,.ct{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:.35rem .75rem;
}
.brow>*,.info-row>*,.detail-row>*,.kv>*,.kv-row>*,.summary-row>*,.stat-row>*,.data-row>*{min-width:0;overflow-wrap:break-word}
.brow .bv,.info-row>:last-child,.detail-row>:last-child,.kv>:last-child,.kv-row>:last-child,.summary-row>:last-child,.stat-row>:last-child{text-align:right;margin-left:auto}
.ct{justify-content:flex-start}                 /* card titles: icon + text, left aligned */

/* ---- 5. Pills, badges, tags, tabs, buttons: one line, clipped not spilled */
.badge,.tag,.pill,.chip,.status,.status-badge,.label-tag,.tier-badge,
[class^="badge-"],[class*=" badge-"],[class^="status-"],[class*=" status-"],[class^="t-"],[class*=" t-"]{
  max-width:100%;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  vertical-align:middle;
}
.btn,button,[type="button"],[type="submit"],a.button{
  max-width:100%;
  text-align:center;
  line-height:1.25;
}
@media(max-width:768px){
  /* long button captions wrap on phones rather than overflow the screen */
  .btn,button,[type="button"],[type="submit"],a.button{white-space:normal}
  /* tab strips scroll sideways instead of stacking text on top of itself */
  .tabs,.tab-nav,.tab-bar,.tab-list,.x-tabs,.nav-tabs,.tab-buttons,.tab-header{
    display:flex;flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;scrollbar-width:none;
  }
  .tabs::-webkit-scrollbar,.tab-nav::-webkit-scrollbar,.tab-bar::-webkit-scrollbar,.tab-list::-webkit-scrollbar,
  .x-tabs::-webkit-scrollbar,.nav-tabs::-webkit-scrollbar,.tab-buttons::-webkit-scrollbar,.tab-header::-webkit-scrollbar{display:none}
  .tabs>*,.tab-nav>*,.tab-bar>*,.tab-list>*,.x-tabs>*,.nav-tabs>*,.tab-buttons>*,.tab-header>*,
  .tab-btn,.tab,.x-tab{flex:0 0 auto;white-space:nowrap}
}

/* ---- 6. Form controls -------------------------------------------------- */
input,select,textarea{max-width:100%;text-overflow:ellipsis}
textarea{overflow-wrap:break-word}
:where(select){white-space:nowrap}              /* a long <option> is clipped, not stacked */
.fg,.form-group,.field{min-width:0}

/* ---- 7. Tables scroll inside themselves -------------------------------- */
table{max-width:100%}
th,td{overflow-wrap:break-word;vertical-align:middle}
.table-wrap,.table-responsive,.x-table-wrap,.tbl-wrap,.table-container{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
@media(max-width:768px){
  table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}
  th,td{white-space:normal}
  td:has(.badge,.status,.tag),td.nowrap,th.nowrap{white-space:nowrap}
}

/* ---- 8. Big numbers / money: never wrap into pieces, shrink instead ---- */
.stat-value,.stat-number,.kpi-value,.metric-value,.big-number{
  /* summary boxes: never cut off with "...", shrink first and wrap only as a last resort */
  max-width:100%;
  white-space:normal;
  overflow:visible;
  text-overflow:clip;
  overflow-wrap:anywhere;
  word-break:normal;
  line-height:1.15;
}
.amount,.balance,.money,.price{
  white-space:nowrap;
  max-width:100%;
  overflow:hidden;
  text-overflow:ellipsis;
  overflow-wrap:normal;
  word-break:normal;
}
@media(max-width:480px){
  .stat-value,.stat-number,.kpi-value,.metric-value,.big-number{font-size:clamp(1.05rem,6vw,1.6rem)}
}

/* ---- 9. Layout containers on small screens ----------------------------- */
@media(max-width:1024px){
  .main-content,.admin-main,.manager-main,main{max-width:100vw}
}
@media(max-width:768px){
  h1{font-size:clamp(1.25rem,5.5vw,1.6rem)}
  h2{font-size:clamp(1.1rem,4.8vw,1.35rem)}
  h3{font-size:clamp(1rem,4.2vw,1.15rem)}
  .brow,.info-row,.detail-row,.kv,.kv-row,.summary-row,.stat-row{align-items:flex-start}
  /* inline two-up flex rows stop pushing each other off-screen */
  [style*="display:flex"]>*,[style*="display: flex"]>*{min-width:0}
  [style*="white-space:nowrap"]:not(.badge):not(.tag):not(.pill){max-width:100%}
  .modal-content,.modal-box,.modal,.x-modal,.pl-box{max-width:calc(100vw - 1.2rem);overflow-wrap:break-word}
}

/* ---- 10. Opt-in helpers ------------------------------------------------ */
.truncate{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
.clamp-2,.clamp-3{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden}
.clamp-2{-webkit-line-clamp:2;line-clamp:2}
.clamp-3{-webkit-line-clamp:3;line-clamp:3}
.break-all{overflow-wrap:anywhere;word-break:break-word}
