/*
  Bootstrap 3 → 5 Compatibility Layer
  Maps old BS3 classes to BS5 equivalents
  Remove this file once all PHP templates are fully migrated
*/

/* ========== CRITICAL: Kill any body gap ========== */
html { margin: 0 !important; padding: 0 !important; }
body { margin: 0 !important; padding: 0 !important; margin-top: 0 !important; padding-top: 0 !important; }
body > *:first-child { margin-top: 0 !important; }
.zt-topbar { margin: 0 !important; padding-top: 0 !important; padding-bottom: 0 !important; height: 36px; line-height: 36px; }
nav.navbar:first-of-type, nav.zt-nav { margin-top: 0 !important; border-top: 0 !important; }

/* ========== Grid: BS3 col-xs-* → BS5 col-* ========== */
/* BS5 removed col-xs-*, using col-* instead. Only apply on mobile. */
@media (max-width: 575.98px) {
  .col-xs-1  { flex: 0 0 auto; width: 8.333333%; }
  .col-xs-2  { flex: 0 0 auto; width: 16.666667%; }
  .col-xs-3  { flex: 0 0 auto; width: 25%; }
  .col-xs-4  { flex: 0 0 auto; width: 33.333333%; }
  .col-xs-5  { flex: 0 0 auto; width: 41.666667%; }
  .col-xs-6  { flex: 0 0 auto; width: 50%; }
  .col-xs-7  { flex: 0 0 auto; width: 58.333333%; }
  .col-xs-8  { flex: 0 0 auto; width: 66.666667%; }
  .col-xs-9  { flex: 0 0 auto; width: 75%; }
  .col-xs-10 { flex: 0 0 auto; width: 83.333333%; }
  .col-xs-11 { flex: 0 0 auto; width: 91.666667%; }
  .col-xs-12 { flex: 0 0 auto; width: 100%; }
}

/* ========== Offsets: BS3 col-*-offset-* → BS5 offset-* ========== */
.col-sm-offset-1  { margin-left: 8.333333%; }
.col-sm-offset-2  { margin-left: 16.666667%; }
.col-sm-offset-3  { margin-left: 25%; }
.col-sm-offset-4  { margin-left: 33.333333%; }
.col-md-offset-1  { margin-left: 8.333333%; }
.col-md-offset-2  { margin-left: 16.666667%; }
.col-md-offset-3  { margin-left: 25%; }
.col-md-offset-4  { margin-left: 33.333333%; }

/* ========== Navbar: BS3 → BS5 ========== */
.navbar-default { background-color: var(--zt-white, #fff); border: none; }
.navbar-static-top { position: relative; }
.navbar-header { display: flex; align-items: center; }
.navbar-toggle { display: none; }
@media (max-width: 767px) {
  .navbar-toggle { display: block; padding: 9px 10px; margin: 8px 0; background: transparent; border: 1px solid var(--zt-gray-300, #cbd5e1); border-radius: var(--zt-radius, 8px); cursor: pointer; }
  .navbar-toggle .icon-bar { display: block; width: 22px; height: 2px; background: var(--zt-gray-700, #334155); border-radius: 1px; margin: 4px 0; }
  .navbar-collapse.collapse { display: none !important; }
  .navbar-collapse.collapse.in { display: block !important; }
  .navbar-nav { flex-direction: column; width: 100%; }
  .navbar-nav > li { width: 100%; }
  .navbar-right { float: none !important; }
}

/* ========== Visibility: BS3 hidden-xs/visible-xs → BS5 ========== */
@media (max-width: 575.98px) {
  .hidden-xs { display: none !important; }
}
@media (min-width: 576px) {
  .visible-xs { display: none !important; }
}
@media (max-width: 767.98px) {
  .hidden-sm { display: none !important; }
}
@media (min-width: 768px) and (max-width: 991.98px) {
  .hidden-md { display: none !important; }
}

/* ========== Pull: BS3 pull-left/right → BS5 float ========== */
.pull-left  { float: left !important; }
.pull-right { float: right !important; }

/* ========== Panels → Accordion compat ========== */
.panel { background: var(--zt-white, #fff); border: 1px solid var(--zt-gray-200, #e2e8f0); border-radius: var(--zt-radius-lg, 12px); margin-bottom: 10px; }
.panel-group { margin-bottom: 20px; }
.panel-heading { padding: 18px 24px; cursor: pointer; }
.panel-body { padding: 20px 24px; }
.panel-collapse { overflow: hidden; }
.panel-default > .panel-heading { background: var(--zt-gray-50, #f8fafc); }

/* ========== Labels/Badges ========== */
.label { display: inline-block; padding: 4px 8px; font-size: 75%; font-weight: 700; border-radius: 4px; }
.label-default { background: var(--zt-gray-400, #94a3b8); color: var(--zt-white, #fff); }
.label-primary { background: var(--zt-blue, #3b82f6); color: var(--zt-white, #fff); }
.label-success { background: var(--zt-green, #22c55e); color: var(--zt-white, #fff); }
.label-danger  { background: var(--zt-red, #ec3d3d); color: var(--zt-white, #fff); }

/* ========== Wells → Cards ========== */
.well { background: var(--zt-gray-50, #f8fafc); border: 1px solid var(--zt-gray-200, #e2e8f0); border-radius: var(--zt-radius-lg, 12px); padding: 20px; margin-bottom: 20px; }

/* ========== Thumbnails ========== */
.thumbnail { border: none; padding: 0; background: transparent; border-radius: var(--zt-radius, 8px); }

/* ========== Jumbotron ========== */
.jumbotron { padding: 48px 24px; margin-bottom: 0; background: var(--zt-gray-50, #f8fafc); border-radius: var(--zt-radius-xl, 16px); }

/* ========== Table responsive ========== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ========== Glyphicons (keep for FAQ arrows) ========== */
@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('../fonts/glyphicons-halflings-regular.eot');
  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
       url('../fonts/glyphicons-halflings-regular.woff') format('woff'),
       url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'),
       url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
  font-display: swap;
}
.glyphicon { position: relative; top: 1px; display: inline-block; font-family: 'Glyphicons Halflings'; font-style: normal; font-weight: 400; line-height: 1; -webkit-font-smoothing: antialiased; }
.glyphicon-chevron-down::before { content: "\e114"; }
.glyphicon-chevron-right::before { content: "\e080"; }

/* ========== Navbar icon-bar fix for BS5 ========== */
.navbar-toggle .icon-bar {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--zt-gray-700, #334155);
  border-radius: 1px;
  margin: 4px 0;
}

/* ========== Auto-class for zt-text-102 (hamburger button) ========== */
.zt-text-102 {
  margin-top: 15px;
  border-color: var(--zt-gray-300, #cbd5e1);
}

/* ========== CRITICAL: Navbar collapse visible on desktop ========== */
@media (min-width: 768px) {
  .navbar-collapse.collapse {
    display: flex !important;
    flex-basis: auto;
    align-items: center;
  }
  .navbar-collapse .navbar-nav {
    display: flex;
    flex-direction: row;
    margin-left: auto;
  }
  .navbar-collapse .navbar-nav > li {
    position: static;
  }
  .navbar-collapse .navbar-nav > li > a {
    padding: 20px 14px;
  }
  .navbar-right {
    margin-left: auto !important;
    float: none !important;
  }
}

/* Mobile: collapse behavior */
@media (max-width: 767px) {
  .navbar-collapse.collapse:not(.show) {
    display: none !important;
  }
  .navbar-collapse.collapse.show,
  .navbar-collapse.collapsing {
    display: block !important;
  }
}

/* ========== Caret fix (BS5 removed .caret) ========== */
.caret {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 4px;
  vertical-align: middle;
  border-top: 4px solid;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
}

/* ========== Dropdown menu positioning for mega menu ========== */
@media (min-width: 768px) {
  .navbar-nav .dropdown-menu.zt-mega {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    margin-top: 0;
    z-index: 1000;
    background: #fff;
  }
  /* The dropdown li must be static so mega spans full nav width */
  .navbar-nav > li.dropdown[style*="position: static"] {
    position: static !important;
  }
  .navbar-nav li.dropdown:hover > .dropdown-menu {
    display: block;
  }
}

/* ========== BS5 Row fix for hero sections ========== */
.zt-hero .row {
  align-items: stretch;
}
.zt-hero .col-sm-7,
.zt-hero .col-sm-5 {
  position: relative;
}

/* ========== BS5 container-fluid padding ========== */
.container-fluid {
  padding-left: 5%;
  padding-right: 5%;
}

/* ========== BS5 row negative margin fix ========== */
.row {
  --bs-gutter-x: 30px;
}
.row > * {
  padding-right: calc(var(--bs-gutter-x) * .5);
  padding-left: calc(var(--bs-gutter-x) * .5);
}

/* ========== Fix col-sm at 768px (BS3 breakpoint) - BS5 handles this ========== */

/* ========== Row flex - BS5 handles this natively ========== */

/* ========== col-lg grid - BS5 handles this, removed duplicate ========== */

/* ========== col-md grid - BS5 handles this, removed duplicate ========== */

/* ========== Default col = full width on mobile only ========== */
@media (max-width: 767px) {
  [class*="col-sm-"],
  [class*="col-md-"],
  [class*="col-lg-"] {
    width: 100%;
  }
}
[class*="col-"] {
  position: relative;
  min-height: 1px;
}

/* ========== col-sm-offset - BS5 uses offset-sm-* but keep BS3 compat ========== */

/* ========== hidden-sm for BS5 ========== */
@media (min-width: 768px) and (max-width: 991.98px) {
  .hidden-sm { display: none !important; }
}

/* ========== Container max-width matching BS3 behavior ========== */
.container {
  max-width: 1200px;
  width: 100%;
  padding-right: 15px;
  padding-left: 15px;
  margin-right: auto;
  margin-left: auto;
}
@media (min-width: 768px) { .container { max-width: 750px; } }
@media (min-width: 992px) { .container { max-width: 970px; } }
@media (min-width: 1200px) { .container { max-width: 1170px; } }

/* ========== Ensure hero container stretches full height ========== */
.zt-hero > .container,
.zt-hero > .container > .row {
  min-height: inherit;
}

/* ========== Navbar vertical alignment fix ========== */
@media (min-width: 768px) {
  .navbar-nav {
    display: flex;
    align-items: center;
  }
  .navbar-nav > li {
    display: flex;
    align-items: center;
  }
}

/* ========== Remove BS5 dropdown-toggle default arrow if caret exists ========== */
/* BS5 adds ::after arrow on .dropdown-toggle, we keep it since we removed <b class="caret"> */

/* ========== Remove top gap above topbar ========== */
body {
  margin: 0 !important;
  padding: 0 !important;
}
html, body {
  margin-top: 0 !important;
  padding-top: 0 !important;
}
.zt-topbar {
  margin-top: 0 !important;
  margin-bottom: 0;
}
.zt-topbar:first-child,
body > .zt-topbar,
body > div:first-child {
  margin-top: 0 !important;
}
.navbar {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

/* ========== col-lg-offset (BS3) ========== */
@media (min-width: 992px) {
  .col-lg-offset-1  { margin-left: 8.333333%; }
  .col-lg-offset-2  { margin-left: 16.666667%; }
  .col-lg-offset-3  { margin-left: 25%; }
  .col-lg-offset-4  { margin-left: 33.333333%; }
}

/* ========== col-md-offset (BS3) ========== */
@media (min-width: 768px) {
  .col-md-offset-1  { margin-left: 8.333333%; }
  .col-md-offset-2  { margin-left: 16.666667%; }
  .col-md-offset-3  { margin-left: 25%; }
  .col-md-offset-4  { margin-left: 33.333333%; }
}

/* ========== col-sm-offset (BS3) ========== */
@media (min-width: 576px) {
  .col-sm-offset-1  { margin-left: 8.333333%; }
  .col-sm-offset-2  { margin-left: 16.666667%; }
  .col-sm-offset-3  { margin-left: 25%; }
  .col-sm-offset-4  { margin-left: 33.333333%; }
}

/* ========== text-center (ensure it works) ========== */
.text-center { text-align: center !important; }

/* ========== Center last orphan card in 2-column grid ========== */
.row {
  justify-content: center;
}
