/* ==========================================================================
   mobile-fixes.css — global mobile responsiveness layer
   Loaded AFTER style.css so it can override safely.
   Two jobs:
   1) Bootstrap 4 utility-class compatibility shim (the app ships BS 3.3.7
      but many views use BS4 utility names).
   2) Small-screen polish (touch scrolling, modals, spacing, overflow).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. BS4 utility shim
   -------------------------------------------------------------------------- */
.d-flex {
  display: -ms-flexbox !important;
  display: flex !important;
}
.d-inline-flex {
  display: -ms-inline-flexbox !important;
  display: inline-flex !important;
}
@media (min-width: 768px) {
  .d-sm-flex { display: flex !important; }
}
@media (min-width: 992px) {
  .d-md-flex,
  .d-lg-flex { display: flex !important; }
}
.flex-wrap     { -ms-flex-wrap: wrap; flex-wrap: wrap; }
.flex-nowrap   { -ms-flex-wrap: nowrap; flex-wrap: nowrap; }
.flex-fill     { -ms-flex: 1 1 auto; flex: 1 1 auto; }
.flex-column   { -ms-flex-direction: column; flex-direction: column; }

.align-items-center    { -ms-flex-align: center !important; align-items: center !important; }
.align-items-start     { -ms-flex-align: start !important; align-items: flex-start !important; }
.align-items-end       { -ms-flex-align: end !important; align-items: flex-end !important; }

.justify-content-start   { -ms-flex-pack: start !important; justify-content: flex-start !important; }
.justify-content-end     { -ms-flex-pack: end !important; justify-content: flex-end !important; }
.justify-content-center  { -ms-flex-pack: center !important; justify-content: center !important; }
.justify-content-between { -ms-flex-pack: justify !important; justify-content: space-between !important; }
.justify-content-around  { -ms-flex-pack: distribute !important; justify-content: space-around !important; }

.float-left  { float: left !important; }
.float-right { float: right !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

.ml-auto { margin-left: auto !important; }
.mr-auto { margin-right: auto !important; }

/* margins */
.m-0 { margin: 0 !important; }
.m-1 { margin: 0.25rem !important; }
.m-2 { margin: 0.5rem !important; }
.m-3 { margin: 1rem !important; }
.m-4 { margin: 1.5rem !important; }
.m-5 { margin: 3rem !important; }
.mt-0, .my-0 { margin-top: 0 !important; }
.mt-1, .my-1 { margin-top: 0.25rem !important; }
.mt-2, .my-2 { margin-top: 0.5rem !important; }
.mt-3, .my-3 { margin-top: 1rem !important; }
.mt-4, .my-4 { margin-top: 1.5rem !important; }
.mt-5, .my-5 { margin-top: 3rem !important; }
.mb-0, .my-0 { margin-bottom: 0 !important; }
.mb-1, .my-1 { margin-bottom: 0.25rem !important; }
.mb-2, .my-2 { margin-bottom: 0.5rem !important; }
.mb-3, .my-3 { margin-bottom: 1rem !important; }
.mb-4, .my-4 { margin-bottom: 1.5rem !important; }
.mb-5, .my-5 { margin-bottom: 3rem !important; }
.ml-0, .mx-0 { margin-left: 0 !important; }
.ml-1, .mx-1 { margin-left: 0.25rem !important; }
.ml-2, .mx-2 { margin-left: 0.5rem !important; }
.ml-3, .mx-3 { margin-left: 1rem !important; }
.ml-4, .mx-4 { margin-left: 1.5rem !important; }
.ml-5, .mx-5 { margin-left: 3rem !important; }
.mr-0, .mx-0 { margin-right: 0 !important; }
.mr-1, .mx-1 { margin-right: 0.25rem !important; }
.mr-2, .mx-2 { margin-right: 0.5rem !important; }
.mr-3, .mx-3 { margin-right: 1rem !important; }
.mr-4, .mx-4 { margin-right: 1.5rem !important; }
.mr-5, .mx-5 { margin-right: 3rem !important; }

/* padding */
.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 3rem !important; }
.pt-0, .py-0 { padding-top: 0 !important; }
.pt-1, .py-1 { padding-top: 0.25rem !important; }
.pt-2, .py-2 { padding-top: 0.5rem !important; }
.pt-3, .py-3 { padding-top: 1rem !important; }
.pt-4, .py-4 { padding-top: 1.5rem !important; }
.pt-5, .py-5 { padding-top: 3rem !important; }
.pb-0, .py-0 { padding-bottom: 0 !important; }
.pb-1, .py-1 { padding-bottom: 0.25rem !important; }
.pb-2, .py-2 { padding-bottom: 0.5rem !important; }
.pb-3, .py-3 { padding-bottom: 1rem !important; }
.pb-4, .py-4 { padding-bottom: 1.5rem !important; }
.pb-5, .py-5 { padding-bottom: 3rem !important; }
.pl-0, .px-0 { padding-left: 0 !important; }
.pl-1, .px-1 { padding-left: 0.25rem !important; }
.pl-2, .px-2 { padding-left: 0.5rem !important; }
.pl-3, .px-3 { padding-left: 1rem !important; }
.pl-4, .px-4 { padding-left: 1.5rem !important; }
.pl-5, .px-5 { padding-left: 3rem !important; }
.pr-0, .px-0 { padding-right: 0 !important; }
.pr-1, .px-1 { padding-right: 0.25rem !important; }
.pr-2, .px-2 { padding-right: 0.5rem !important; }
.pr-3, .px-3 { padding-right: 1rem !important; }
.pr-4, .px-4 { padding-right: 1.5rem !important; }
.pr-5, .px-5 { padding-right: 3rem !important; }

/* horizontal-form label alignment used 700+ times across views */
.col-form-label {
  padding-top: 7px;
  margin-bottom: 0;
  text-align: right;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   2. Mobile / small-screen polish
   -------------------------------------------------------------------------- */

/* never let a stray wide element widen the page */
body {
  overflow-x: hidden;
}

/* smooth touch scrolling inside scrollable table wrappers */
.table-responsive {
  -webkit-overflow-scrolling: touch;
  overflow-x: auto;
  border: 0;
}

/* images / embeds never overflow their container */
img,
iframe,
embed,
video {
  max-width: 100%;
  height: auto;
}

/* select2 widgets must not overflow narrow columns */
.select2-container {
  max-width: 100%;
}

@media (max-width: 767px) {
  /* right-aligned form labels become left-aligned stacked labels */
  .col-form-label {
    text-align: left;
  }

  /* tighter page gutters */
  .content-wrapper > .content {
    padding-left: 10px;
    padding-right: 10px;
  }

  .breadcrumb {
    padding: 6px 10px;
    font-size: 12px;
    margin-bottom: 10px;
  }

  /* buttons may wrap instead of stretching rows */
  .btn {
    white-space: normal;
  }

  /* near-fullscreen modals with scrollable body */
  .modal-dialog {
    margin: 10px auto;
    width: auto;
  }
  .modal-body {
    max-height: calc(100vh - 190px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-footer {
    padding: 10px;
  }
  .modal-footer .btn + .btn {
    margin-left: 5px;
  }

  /* AdminLTE header/footer compaction */
  .main-header .logo {
    font-size: 16px;
  }
  .main-footer {
    font-size: 12px;
  }

  /* generic layout-offset bugs (e.g. .footer { margin-left:150px } in gui_pos.css) */
  .footer {
    margin-left: 0 !important;
  }

  /* keep action-button groups from overflowing card footers */
  .panel-footer,
  .card-footer {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* very narrow phones */
@media (max-width: 400px) {
  h1, .h1 { font-size: 20px; }
  h2, .h2 { font-size: 18px; }
  h3, .h3 { font-size: 16px; }
}

/* --------------------------------------------------------------------------
   3. DataTables Responsive extension helpers
      (extension JS/CSS provide collapsing columns; these just tidy them)
   -------------------------------------------------------------------------- */
table.dataTable.dtr-inline.collapsed > tbody > tr > td:first-child,
table.dataTable.dtr-inline.collapsed > tbody > tr > th:first-child {
  position: relative;
}
table.dataTable.dtr-inline.collapsed > tbody > tr.child ul.dtr-details {
  padding-left: 1em;
  font-size: 13px;
}
table.dataTable.dtr-inline.collapsed > tbody > tr.child ul.dtr-details li {
  border-bottom: 1px dotted #efefef;
  padding: 3px 0;
}
/* --------------------------------------------------------------------------
   4. Top-navbar quick-action buttons (Invoice / Customer Receive /
      Supplier Payment / Purchase).
      Two overlap mechanisms exist:
      a) navbar children wrapping to a 2nd line that hangs below the bar
         over the sidebar/page band -> fixed by making the WHOLE navbar a
         single-row flex container that can only scroll, never wrap;
      b) on <=767px the sidebar opens as an overlay drawer UNDER the header
         (z 810 vs 1030), so the buttons stay painted on top of the green
         drawer -> they are hidden while .sidebar-open.
   -------------------------------------------------------------------------- */

/* a) one-row navbar at every width (no overflow properties here — they
      would clip the drop-down menus that render below the bar) */
.main-header .navbar.navbar-static-top {
  display: -ms-flexbox;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
}
.main-header .navbar .sidebar-toggle,
.main-header .navbar .navbar-custom-menu {
  flex-shrink: 0;
}
.main-header .navbar .top-fixed-link {
  flex-shrink: 1;
  min-width: 0; /* lets it shrink; internal scroll comes from style.css */
}
.main-header .navbar .navbar-custom-menu {
  float: none;
  margin-left: auto; /* replaces float:right in flex context */
}
.main-header .navbar .nav > li {
  white-space: nowrap;
}

/* b) phone drawer: clear the header strip while the sidebar is open */
@media (max-width: 767px) {
  .sidebar-open .main-header .navbar {
    background: transparent;
    border-color: transparent;
  }
  .sidebar-open .main-header .navbar > a:not(.sidebar-toggle),
  .sidebar-open .main-header .navbar .top-fixed-link,
  .sidebar-open .main-header .navbar .navbar-custom-menu {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
  .sidebar-open .main-header .navbar .sidebar-toggle {
    position: relative;
    z-index: 1045; /* keeps the close (hamburger) tap target above the drawer */
    color: #fff;
  }
}

/* quick-action pills: never shrink/wrap */
.main-header .navbar .top-fixed-link {
  flex-wrap: nowrap;
}
.main-header .navbar .top-fixed-link a.btn {
  flex: 0 0 auto;
}

/* BELOW 1400px: compact mode so EVERYTHING fits beside the expanded sidebar
   and nothing gets scrolled out of view (phones included):
   - quick-actions become icon-only pills and may NOT shrink (no clipping)
   - right-side CTAs (Open AI / POS) lose their text labels too            */
@media (max-width: 1399px) {
  .main-header .navbar .top-fixed-link {
    flex-shrink: 0; /* was shrinkable -> right-most buttons disappeared */
  }
  .main-header .navbar .top-fixed-link a.btn {
    font-size: 0 !important;
    padding: 8px 11px !important;
  }
  .main-header .navbar .top-fixed-link a.btn > i,
  .main-header .navbar .top-fixed-link a.btn > span {
    font-size: 15px !important;
    margin: 0 !important;
  }
  .main-header .navbar .navbar-custom-menu .pos-btn {
    font-size: 0 !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    gap: 0 !important;
  }
  .main-header .navbar .navbar-custom-menu .pos-btn > i,
  .main-header .navbar .navbar-custom-menu .pos-btn > span {
    font-size: 15px !important;
  }

  /* breathing room between the right-side items (Ask AI | POS | bell | gear) */
  .main-header .navbar .navbar-custom-menu .nav > li {
    margin-left: 8px;
  }
  .main-header .navbar .navbar-custom-menu .nav > li:first-child {
    margin-left: 0;
  }
}

/* ultra-narrow devices (<480px): re-enable the internal scroll fallback so
   nothing overflows the viewport unreachable (settings gear must stay
   tappable); everything is already icon-only here */
@media (max-width: 479px) {
  .main-header .navbar .top-fixed-link {
    flex-shrink: 1;
    min-width: 0;
  }
}

/* phones keep the scroll fallback for very narrow devices (<420px) */
@media (max-width: 767px) {
  .main-header .navbar .top-fixed-link {
    padding-left: 4px;
  }
}
