/* ==========================================================================
   GTCL (ecpgtcl) client theme — responsive layer for the portal.
   Client-owned: loaded after site.css from index.html; master never edits it
   (see docs/clients/clients-and-branches.md, "client-theme.css").

   The shell in views/layout.html was built for wide desktops: a 118px header,
   a 68px live ticker below it and a hard-coded 184px content offset. These
   rules size all three per breakpoint, keep the header on one row and make
   the heaviest pages usable on tablets and phones. Many targets carry inline
   styles, hence the !important declarations.

   Header height (H) per breakpoint      Content offset = H + ticker (66)
     >= 1200px   118px                   184px
     992-1199    96px                    162px
     768-991     80px                    146px
     < 768       60px                    126px
   ========================================================================== */

/* -- Shell: header row ------------------------------------------------------ */
#navbar-container {
  display: flex;
  align-items: center;
  height: 118px;
  padding-left: 12px;
  padding-right: 12px;
}

#navbar-container > .menu-toggler {
  flex: 0 0 auto;
  margin: 0 8px 0 0;
}

#navbarHeader {
  flex: 1 1 auto;
  min-width: 0;
  width: auto !important;
  height: 100% !important;
  float: none !important;
  margin: 0;
}

#navbarHeader > .row {
  display: flex;
  align-items: center;
  height: 100%;
  margin: 0;
}

#navbarHeader > .row > [class*="col-"] {
  float: none;
  width: auto;
  padding: 0;
}

#navbarHeader > .row > [class*="col-"]:first-child {
  flex: 0 0 auto;
}

#navbarHeader > .row > .longTitle {
  flex: 1 1 auto;
  min-width: 0;
  display: block !important;
  padding: 0 12px;
}

#navbarHeader .navbar-brand {
  float: none;
  display: block;
  padding: 0 !important;
  margin: 0 !important;
}

#navbarHeader .navbar-brand img {
  display: block;
  width: 90px;
  height: 90px;
  border-radius: 6px;
}

#rightNav {
  flex: 0 0 auto;
  float: none !important;
  padding-top: 0 !important;
}

/* The ticker now follows the header row instead of a fixed 118px margin. */
#navbar .marquee-container {
  margin-top: 0;
}

#main-container {
  padding-top: 184px !important;
}

/* -- Shell: smaller desktops / laptops ------------------------------------- */
@media (max-width: 1199px) {
  #navbar-container {
    height: 96px;
  }

  #navbarHeader .navbar-brand img {
    width: 72px;
    height: 72px;
  }

  #navbarHeader .longTitle h1 {
    font-size: 24px !important;
    margin-top: 0 !important;
  }

  #navbarHeader .longTitle span {
    font-size: 14px !important;
  }

  #navbarHeader .longTitle h1 + span + br + div {
    font-size: 22px !important;
    line-height: 1.2;
  }

  #main-container {
    padding-top: 162px !important;
  }
}

/* -- Shell: tablets (sidebar becomes the off-canvas menu) ------------------- */
@media (max-width: 991px) {
  #navbar-container {
    height: 80px;
  }

  #navbarHeader .navbar-brand img {
    width: 58px;
    height: 58px;
  }

  #navbarHeader .longTitle h1 {
    font-size: 18px !important;
  }

  #navbarHeader .longTitle span {
    font-size: 12px !important;
  }

  #navbarHeader .longTitle h1 + span + br + div {
    font-size: 17px !important;
  }

  #main-container {
    padding-top: 146px !important;
  }
}

/* -- Shell: phones ---------------------------------------------------------- */
@media (max-width: 767px) {
  #navbar-container {
    height: 60px;
    padding-left: 6px;
    padding-right: 4px;
  }

  #navbarHeader .navbar-brand img {
    width: 42px;
    height: 42px;
    border-radius: 4px;
  }

  #navbarHeader > .row > .longTitle {
    padding: 0 8px;
    text-align: left;
  }

  #navbarHeader .longTitle h1 {
    font-size: 13px !important;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* "A Company of Petrobangla" — dropped on phones to keep one compact row. */
  #navbarHeader .longTitle span,
  #navbarHeader .longTitle br {
    display: none;
  }

  #navbarHeader .longTitle h1 + span + br + div {
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* User menu: icon only on phones (Profile / Change Password / Logout still
     open from it). */
  #rightNav .user-info,
  #rightNav .fa-caret-down {
    display: none;
  }

  #rightNav .ace-nav > li > a {
    padding: 0 8px;
  }

  #rightNav .ace-nav > li > a > .ace-icon.fa-user {
    font-size: 22px;
    margin: 0 !important;
  }

  #main-container {
    padding-top: 126px !important;
  }

  .page-content {
    padding-top: 8px;
    padding-bottom: 16px;
  }

  /* Toolbar buttons (New / Search / Save ...) wrap instead of overflowing. */
  .breadcrumbs {
    height: auto;
    min-height: 41px;
  }

  #masterbuttoncontainer {
    white-space: normal;
  }
}

/* -- Content: no sideways page scroll on tablets / phones -------------------
   Root cause: site.css's ".form-horizontal .col-xs-1, .col-sm-1, ..." list
   gives every column 5px padding (only the first selector is scoped), so a
   row nested in a column overflows by 12 - 5 = 7px — once per nesting level
   (the dashboard nests three deep). Below 992px, rows and form-groups inside
   a column use -5px gutters to match, so every level lines up; the overflow
   clip is a safety net for anything else. */
@media (max-width: 991px) {
  #main-container .main-content {
    overflow-x: hidden;
  }

  .page-content {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .page-content [class*="col-"] .row,
  .page-content [class*="col-"] .form-horizontal .form-group {
    margin-left: -5px;
    margin-right: -5px;
  }
}

/* -- Content: wide widgets scroll inside their own box ---------------------- */
.page-content .table-responsive,
.page-content .bootstrap-table .fixed-table-body {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.page-content img {
  max-width: 100%;
}

/* Remote CP Live Data diagrams (views/PIMS/cpSystemLiveData.html) keep a
   1000px minimum and scroll sideways inside their own black board. */

/* -- List + form pages (User Info, User Permission, Upload Report): the
      page-level "list 3/12 | form 9/12" row stacks on phones. ------------- */
@media (max-width: 767px) {
  .container-page > .row > .col-xs-3.col-sm-3.col-lg-3,
  .container-page > .row > .col-xs-9.col-sm-9.col-lg-9 {
    width: 100%;
  }

  .container-page > .row > .col-xs-3.col-sm-3.col-lg-3 {
    margin-bottom: 10px;
  }
}

/* -- CP System Info: each block is "empty third | content third | empty third";
      below 992px the content third takes the full row. --------------------- */
@media (max-width: 991px) {
  #page-cpsysteminfo .row > .col-xs-4:not(.center) {
    display: none;
  }

  #page-cpsysteminfo .row > .col-xs-4.center {
    width: 100%;
  }
}

/* -- CP System Map: stack the option panels under the map on small screens - */
@media (max-width: 991px) {
  #page-cpsystemmap .panel-body[style*="970px"] {
    display: flex;
    flex-direction: column;
    height: auto !important;
  }

  #page-cpsystemmap #map {
    order: -1;
    width: 100% !important;
    height: 70vh !important;
    min-height: 360px;
    margin-bottom: 10px;
  }

  #page-cpsystemmap .panel-body[style*="970px"] > .panel {
    width: 100% !important;
    float: none !important;
    margin-bottom: 8px;
  }
}

@media (min-width: 600px) and (max-width: 991px) {
  /* Two option panels per row on tablets. */
  #page-cpsystemmap .panel-body[style*="970px"] {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
  }

  #page-cpsystemmap #map {
    flex: 0 0 100%;
  }

  #page-cpsystemmap .panel-body[style*="970px"] > .panel {
    width: calc(50% - 5px) !important;
  }
}
