/*
 * Responsive layer of every page (loaded last by include/headhtml.php):
 * phones, tablets, small and big computers. Nothing goes past the screen
 * edge, labels wrap instead of being cut, and a table too wide for the
 * screen is shown as one card per row (js/mx-responsive.js adds the
 * class "mx-cards" and the column name of each cell).
 */

/* ---------- everywhere ---------- */
/* Phone browsers must not enlarge some texts on their own (layout kept). */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
img,svg,video,canvas,iframe{max-width:100%}
.form-control,select,textarea,input{max-width:100%}
pre{white-space:pre-wrap;word-break:break-word}
.card-header{flex-wrap:wrap;gap:6px}
.upf-acts,.ugl-acts,.ugl-bar{flex-wrap:wrap}

/* ---------- tables shown as cards (small screens) ---------- */
table.mx-cards,table.mx-cards>tbody,table.mx-cards>tbody>tr,table.mx-cards>tbody>tr>td,table.mx-cards>tr,table.mx-cards>tr>td{display:block;width:auto!important}
table.mx-cards{min-width:0!important;max-width:100%!important;border:0!important;background:none!important;box-shadow:none!important}
table.mx-cards>thead,table.mx-cards>tbody>tr:has(>th),table.mx-cards>tr:has(>th),table.mx-cards>tfoot>tr:has(>th){display:none!important}
table.mx-cards>tbody>tr,table.mx-cards>tr{position:relative;margin:0 0 9px;padding:6px 11px;border:1px solid rgba(127,127,127,.25)!important;border-radius:11px;
  background:rgba(127,127,127,.06)!important;box-shadow:0 1px 4px rgba(0,0,0,.08)}
table.mx-cards>tbody>tr>td,table.mx-cards>tr>td{display:block!important;min-height:30px;line-height:20px;
  padding:5px 0!important;border:0!important;border-bottom:1px dashed rgba(127,127,127,.16)!important;text-align:end!important;
  white-space:normal!important;word-break:break-word;overflow:visible!important;max-width:none!important;position:static!important;background:none!important}
table.mx-cards>tbody>tr>td:last-child,table.mx-cards>tr>td:last-child{border-bottom:0!important}
table.mx-cards>tbody>tr>td:empty,table.mx-cards>tr>td:empty{display:none!important}
table.mx-cards>tbody>tr>td::after,table.mx-cards>tr>td::after{content:"";display:table;clear:both}
/* column name on the left, the value (all its parts together) on the right */
table.mx-cards>tbody>tr>td::before,table.mx-cards>tr>td::before{content:attr(data-label);float:left;max-width:46%;margin-right:12px;text-align:start;
  font-size:10.5px;font-weight:700;letter-spacing:.3px;text-transform:uppercase;opacity:.6;white-space:normal}
table.mx-cards>tbody>tr>td[data-label=""]::before,table.mx-cards>tr>td[data-label=""]::before{display:none}
table.mx-cards>tbody>tr>td[data-label=""],table.mx-cards>tr>td[data-label=""]{text-align:start!important}
table.mx-cards>tbody>tr>td>*,table.mx-cards>tr>td>*{max-width:100%;vertical-align:middle}
table.mx-cards>tbody>tr>td[colspan],table.mx-cards>tr>td[colspan]{text-align:center!important}
table.mx-cards tfoot,table.mx-cards tfoot tr,table.mx-cards tfoot td{display:block}
/* the box that scrolled the wide table has nothing to scroll any more */
.mx-cards-wrap{overflow:visible!important;max-height:none!important;border:0!important;background:none!important}
.lang-ar table.mx-cards>tbody>tr>td,.lang-ar table.mx-cards>tr>td{text-align:start!important}
.lang-ar table.mx-cards>tbody>tr>td::before,.lang-ar table.mx-cards>tr>td::before{float:right;margin-right:0;margin-left:12px;text-align:end}

/* Labels of tiles / figures wrap instead of being cut (all sizes). */
[class*="-kpi"] small,[class*="-kpi"] em,[class*="-stat"] small,[class*="-stat"] em,[class*="-stat-body"] span,.mx-tile small,.mx-res-row span,
.ugl-stat small{white-space:normal!important;overflow:visible!important;text-overflow:clip!important;word-break:break-word}
.ugl-stat,.ugl-stat > span{min-width:0}

/* Sidebar: a long name goes on two lines instead of ending with "...". */
#sidenav.mx-side a,#sidenav.mx-side .dropdown-btn{display:flex!important;align-items:center;white-space:normal!important;overflow:visible!important;
  text-overflow:clip!important;line-height:18px}
#sidenav.mx-side a > i:first-child,#sidenav.mx-side .dropdown-btn > i:first-child{flex:0 0 22px}
#sidenav.mx-side .dropdown-container a > i:first-child,#sidenav.mx-side .dropdown-container .dropdown-btn > i:first-child{flex:0 0 18px}
#sidenav.mx-side .dropdown-btn .fa-caret-down{float:none!important;margin:0 0 0 auto!important;padding-left:6px!important}
#sidenav .mx-sw a,#sidenav .mx-seg a{display:flex!important}
#sidenav .mx-sw a{display:block!important}
#sidenav .mx-foot b,#sidenav .mx-router-txt b,#sidenav .mx-router-txt small{white-space:normal!important;overflow:visible!important;text-overflow:clip!important;word-break:break-word}

/* A table too wide: its text wraps first (js/mx-responsive.js). */
table.mx-fit{min-width:0!important}
table.mx-fit th,table.mx-fit td{white-space:normal!important;word-break:normal!important;overflow-wrap:normal!important}

/* ---------- tablets and small computers ---------- */
@media (max-width:1100px){
  [class*="-kpis"]{grid-template-columns:repeat(auto-fill,minmax(150px,1fr))!important}
  .ugl-stats{grid-template-columns:repeat(auto-fill,minmax(120px,1fr))!important}
}

/* ---------- phones ---------- */
@media (max-width:640px){
  /* Top bar: menu, timer, router, zoom, logout fit on one line. */
  #navbar{display:flex!important;align-items:center}
  #navbar .navbar-left{flex:0 0 auto;width:auto!important;display:flex}
  #navbar #cpage,#navbar #brand{display:none!important}
  /* Floated right before: the same order as on a computer (timer, router, zoom, logout). */
  #navbar .navbar-right{display:flex;flex-direction:row-reverse;align-items:center;justify-content:flex-start;gap:2px;float:none!important;flex:1 1 auto;min-width:0;flex-wrap:nowrap}
  #navbar .navbar-right > *{float:none!important;flex:0 0 auto;margin-top:0!important;margin-bottom:0!important}
  #navbar #logout{font-size:0!important;padding:0 10px!important}
  #navbar #logout i{font-size:16px!important;margin:0!important}
  #navbar .navbar-right a[title="Idle Timeout"] span{width:auto!important;padding:0 2px!important;font-size:11px}
  #navbar .navbar-right select.ses{max-width:96px;min-width:0;text-overflow:ellipsis;padding:3px 2px!important}
  #navbar .mxz{margin:0 2px!important;height:26px}
  #navbar .mxz button{width:22px;height:24px}
  #navbar .mxz .mxz-v{min-width:34px!important;font-size:9.5px!important;line-height:24px;height:24px}
  #navbar{height:auto;min-height:50px}
  #navbar .navbar-left,#navbar .navbar-right{height:50px;align-items:center}

  /* Labels of tiles / figures wrap instead of being cut. */
  [class*="-kpi"] span,.mx-tile b,.ugl-stat b{white-space:normal!important;overflow:visible!important;text-overflow:clip!important;word-break:break-word}
  [class*="-kpis"]{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .ugl-stats{grid-template-columns:repeat(auto-fill,minmax(96px,1fr))!important}
  .ugl-stat{min-width:0}
  .ugl-stat > span{min-width:0}

  /* Page headers: title, then the buttons on their own line, all visible. */
  .upf-top .card-header{flex-direction:column;align-items:stretch}
  .upf-acts{justify-content:flex-start}
  .upf-acts .upf-btn{flex:1 1 auto}
  .upf-ttl small{white-space:normal}

  /* Search rows with buttons (Ventes, Forfaits, lists). */
  .vt-find,.ff-find{flex-wrap:wrap}
  .vt-find label,.ff-find label{flex:1 1 100%}
  .vt-find > a,.vt-find > button,.ff-find > a,.ff-find > button{flex:1 1 auto}
  .ugl-search{flex:1 1 100%;min-width:0}
  .ugl-bar > select,.ugl-bar select.form-control{flex:1 1 140px;width:auto;min-width:0}
  .ugl-bar > .upf-btn,.ugl-bar > button,.ugl-bar > a{flex:1 1 auto}
  .ugn-seg{flex-wrap:wrap}
  /* Tab rows of the pages and windows: all tabs visible, on two lines if needed. */
  [class$="-tabs"],[class*="-tabs "]{flex-wrap:wrap!important;overflow-x:visible!important}
  [class$="-tabs"] > button,[class$="-tabs"] > a{flex:1 1 auto;justify-content:center}

  /* Old Mikhmon pages: rows and columns one under the other. */
  .row > [class*="col-"]{width:100%!important;max-width:100%!important;flex:0 0 100%!important}
  .card{margin:6px 2px}
  .table-responsive,.overflow{max-width:100%}
  .btn{white-space:normal}

  /* Windows of the pages use the whole screen. */
  .ndv-dlg,.rup-dlg,.mxa-dlg,.modal-window>div{max-height:94dvh}
  .ndv-modal,.rup-modal,.mxa-modal{padding:8px}
}

/* ---------- very small phones ---------- */
@media (max-width:380px){
  #navbar .navbar-right a[title="Idle Timeout"]{display:none!important}
  [class*="-kpis"]{gap:6px!important}
  .main-container{padding:6px 2px 16px}
}
