/**
 * School Base Software — Global mobile / tablet responsive layer
 * Desktop (≥992px) intentionally unchanged.
 */

/* -------------------------------------------------------------------------- */
/* 1) Kill BootstrapMade dark full-screen menu overlay                        */
/* -------------------------------------------------------------------------- */
#navbar.navbar-mobile,
.navbar.navbar-mobile,
#header .navbar.navbar-mobile {
  position: static !important;
  top: auto !important;
  right: auto !important;
  left: auto !important;
  bottom: auto !important;
  background: transparent !important;
  overflow: visible !important;
  z-index: auto !important;
  transition: none !important;
}

#navbar.navbar-mobile > ul,
.navbar.navbar-mobile > ul {
  position: absolute !important;
  top: 100% !important;
  right: 0 !important;
  bottom: auto !important;
  left: 0 !important;
  background: #fff !important;
  padding: 0 !important;
}

/* -------------------------------------------------------------------------- */
/* 2) Mobile / tablet only                                                    */
/* -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    overflow-x: hidden;
    max-width: 100vw;
    padding-top: 0 !important;
  }

  /* Sticky header = in document flow → do NOT also keep desktop spacer gaps */
  #header.fixed-top {
    position: sticky !important;
    top: 0;
    z-index: 1030;
  }

  #header {
    padding: 0 !important;
  }

  #header .header-top {
    padding: 6px 0 !important;
  }

  #header .header-top .container {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  #header .soc {
    font-size: 12px !important;
    line-height: 1.3 !important;
    word-break: break-word;
    padding: 0 4px;
  }

  #header .logo,
  #header .logo a,
  #header .logo a span {
    font-size: clamp(15px, 4.6vw, 20px) !important;
    line-height: 1.2 !important;
    word-break: break-word;
  }

  .soft-year {
    float: none !important;
    display: inline-block !important;
    font-size: 15px !important;
    margin: 4px 0 2px !important;
  }

  #header > .container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 4px 10px !important;
    min-height: 42px;
  }

  /* Kill huge desktop spacers used to clear fixed header.
   * Pages redefine `.mt-5 { margin-top: 5rem !important }` AFTER this file —
   * final override lives in layouts/sbs_mobile_gapfix.blade.php (footer). */
  html body .mt-5,
  html body .my-5,
  html body .pt-5,
  html body .py-5,
  html body .row.mt-5,
  html body #main .mt-5,
  html body #main .row.mt-5,
  html body section .mt-5,
  html body .contact .mt-5,
  html body .contact .row.mt-5 {
    margin-top: 0.4rem !important;
  }

  html body .pt-5,
  html body .py-5,
  html body #main .pt-5,
  html body #main .py-5 {
    padding-top: 0.4rem !important;
  }

  html body .mb-5,
  html body #main .mb-5 {
    margin-bottom: 0.75rem !important;
  }

  /* Template section { padding: 60px 0 } / page padding-top: 200px */
  html body section,
  html body #main > section,
  html body #main section,
  html body section.contact,
  html body section.portfolio,
  html body section#contact,
  html body section#portfolio {
    padding-top: 8px !important;
    padding-bottom: 12px !important;
    margin-top: 0 !important;
    overflow: visible !important;
  }

  html body #main {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }

  body {
    overflow-x: hidden !important;
    overflow-y: auto !important;
  }

  /* Menu */
  #header .navbar,
  .navbar {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    position: relative;
  }

  #header .mobile-nav-toggle,
  .mobile-nav-toggle {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 28px !important;
    cursor: pointer;
    color: #111 !important;
    line-height: 1;
    z-index: 1040;
    padding: 4px;
  }

  #header .navbar > ul,
  .navbar > ul {
    display: none;
    position: absolute !important;
    left: 0 !important;
    right: 0 !important;
    top: 100% !important;
    width: 100% !important;
    max-height: min(70vh, 520px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff !important;
    flex-direction: column;
    align-items: stretch;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 1045;
    list-style: none;
    margin: 0;
    padding: 0;
  }

  #header .navbar.navbar-mobile-open > ul,
  #header .navbar.navbar-mobile > ul,
  .navbar.navbar-mobile-open > ul,
  .navbar.navbar-mobile > ul {
    display: flex !important;
  }

  #header .navbar a,
  #header .navbar a:focus,
  .navbar a,
  .navbar a:focus {
    padding: 12px 16px !important;
    width: 100%;
    justify-content: space-between;
    white-space: normal !important;
    border-bottom: 1px solid #eee;
    font-size: 13px;
  }

  #header .navbar .dropdown > ul,
  .navbar .dropdown > ul {
    position: static !important;
    display: none;
    width: 100%;
    box-shadow: none !important;
    max-height: none;
  }

  #header .navbar .dropdown:hover > ul,
  .navbar .dropdown:hover > ul {
    display: none;
  }

  #header .navbar .dropdown.dropdown-open > ul,
  .navbar .dropdown.dropdown-open > ul {
    display: block !important;
  }

  /* Main content — full width, tight padding */
  #main {
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-top: 0 !important;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  /*
   * Panel HOME pages (student/admin/staff/school/society/class/…)
   * Blades use padding-top: 150–200px for old fixed header — causes huge
   * white gap under hamburger when header is sticky. Desktop untouched.
   */
  #main[class*="-home-main"],
  #main.student-home-main,
  #main.admin-home-main,
  #main.staff-home-main,
  #main.school-home-main,
  #main.society-home-main,
  #main.class-home-main,
  #main.admin-user-home-main {
    padding: 20px 12px 28px !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Older home pages: inline section { padding-top: 200px !important } */
  #main > section,
  #main section.portfolio,
  #main section#portfolio,
  section.portfolio {
    padding-top: 16px !important;
    padding-bottom: 16px !important;
  }

  #main .container,
  #main .container-fluid,
  section .container,
  section .container-fluid {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  /* Stack columns full-bleed on mobile */
  #main .row > [class*="col-"],
  section .row > [class*="col-"] {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    padding-left: 8px;
    padding-right: 8px;
  }

  /* White form cards: full width, auto height (pages often set fixed height) */
  .php-email-form,
  .php-caste-form,
  .php-staff-form,
  .php-staff-list,
  #main .card,
  .contact .php-email-form,
  .contact .php-caste-form,
  .contact .php-staff-form,
  .contact .php-staff-list {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    box-sizing: border-box;
  }

  .php-email-form,
  .php-caste-form,
  .php-staff-form,
  .php-staff-list,
  .contact .php-email-form,
  .contact .php-caste-form,
  .contact .php-staff-form,
  .contact .php-staff-list {
    padding: 12px !important;
  }

  .card-body {
    padding: 12px !important;
  }

  /* Hero / home logo */
  .img-fluid {
    max-width: 100% !important;
    height: auto !important;
    border-width: 4px !important;
    border-radius: 12px !important;
  }

  #main img,
  section img {
    max-width: 100%;
    height: auto;
  }

  /* Forms */
  .form-control,
  .form-select,
  select.form-control,
  input.form-control,
  textarea.form-control,
  .form-group input,
  .form-group select,
  .form-group textarea {
    max-width: 100% !important;
    width: 100%;
    box-sizing: border-box;
  }

  label {
    word-break: break-word;
  }

  .btn {
    max-width: 100%;
    white-space: normal;
  }

  .d-flex.gap-2,
  .btn-group {
    flex-wrap: wrap;
  }

  /*
   * TABLES — keep real table layout (not card/block).
   * Many blades wrongly put .table-responsive ON the <table>.
   * Bootstrap then sets display:block → looks like a narrow scrolling card.
   * Scroll only on a wrapper; table itself stays display:table, width 100%.
   */
  table.table,
  table.table-bordered,
  table.table-responsive,
  table.table.table-responsive,
  table.table-bordered.table-responsive,
  .table {
    display: table !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    table-layout: auto;
    margin-bottom: 0.75rem;
  }

  table.table th,
  table.table td,
  .table th,
  .table td {
    white-space: nowrap;
  }

  /* Scroll wrappers only — no forced min-width on every table */
  .table-responsive:not(table),
  .table-responsive-sm:not(table),
  .dataTables_wrapper,
  .php-email-form,
  .php-caste-form {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* If .table-responsive is on the table, wrap-scroll via parent */
  #main .php-email-form:has(> table),
  #main .php-caste-form:has(> table),
  #main .col-lg-7:has(> .php-email-form),
  #main .col-lg-12:has(table),
  #main .container:has(table.table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* Footer */
  #footer .container {
    display: block !important;
    text-align: center !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  #footer .me-md-auto,
  #footer .credits {
    text-align: center !important;
    width: 100%;
  }

  #header .d-flex.align-items-center {
    display: flex !important;
    flex-wrap: wrap;
    width: 100%;
  }

  .swal2-popup {
    width: calc(100% - 24px) !important;
    max-width: 420px !important;
  }

  /* Dashboard */
  .container-scroller .navbar .navbar-menu-wrapper {
    width: 100% !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
    height: auto !important;
    min-height: 64px;
    flex-wrap: wrap;
  }

  .container-scroller .navbar .navbar-brand-wrapper {
    width: auto !important;
  }

  .container-scroller .navbar h3,
  .container-scroller .navbar h6 {
    font-size: clamp(12px, 3.5vw, 16px) !important;
    line-height: 1.3 !important;
    word-break: break-word;
  }

  .container-scroller .content-wrapper {
    padding: 10px 8px !important;
  }

  .sidebar-offcanvas {
    z-index: 1050;
  }

  /* -------------------------------------------------------------------- */
  /* Public site (home / login) — #wrapper + menuzord header              */
  /* -------------------------------------------------------------------- */
  #wrapper.clearfix {
    min-height: 100vh;
  }

  #header.header .menuzord .showhide {
    display: none !important;
  }

  #header.header #menuzord-right.menuzord {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
  }

  #header.header .menuzord-brand,
  #header.header .menuzord-brand.xs-pull-center {
    float: none !important;
    margin: 0 !important;
    text-align: left !important;
    max-width: calc(100% - 130px) !important;
  }

  #header.header .menuzord-brand img {
    max-height: 32px !important;
  }

  #header.header .menuzord-menu {
    display: flex !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    background: transparent !important;
    box-shadow: none !important;
    margin-left: auto !important;
  }

  #header.header .menuzord-menu > li {
    display: inline-block !important;
    float: none !important;
  }

  #footer.footer {
    display: block !important;
    width: 100% !important;
  }

  #footer .footer-bottom .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* Public home */
  .home-page .home-container {
    max-width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .home-page .home-panel {
    max-height: none !important;
    width: 100% !important;
  }

  /* Public login box full width */
  .divider .col-xs-10,
  .divider .col-sm-10 {
    width: 100% !important;
    margin-left: 0 !important;
  }

  .divider .login-form-2 .form-control {
    width: 100% !important;
    margin-left: 0 !important;
  }

  .divider .btnSubmit {
    width: 100% !important;
    margin-left: 0 !important;
  }

  /* Inline fixed widths used on some admin forms (e.g. width:38%) */
  #main [style*="width:38%"],
  #main [style*="width: 38%"],
  #main [style*="width:50%"],
  #main [style*="width: 50%"],
  #main [style*="width:60%"],
  #main [style*="width: 60%"],
  #main [style*="width:70%"],
  #main [style*="width: 70%"],
  #main [style*="width:80%"],
  #main [style*="width: 80%"] {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/* Phones */
@media (max-width: 575.98px) {
  #header .soc {
    font-size: 11px !important;
  }

  #header .logo,
  #header .logo a,
  #header .logo a span {
    font-size: clamp(14px, 5vw, 17px) !important;
  }

  .soft-year {
    font-size: 13px !important;
  }

  section,
  #main > section,
  section.contact,
  #main section.portfolio,
  section.portfolio {
    padding-top: 8px !important;
    padding-bottom: 12px !important;
  }

  #main[class*="-home-main"] {
    padding: 12px 10px 20px !important;
  }

  #main .container,
  #main .container-fluid,
  section .container,
  section .container-fluid {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .php-email-form,
  .php-caste-form,
  .contact .php-email-form {
    padding: 10px !important;
  }

  .img-fluid {
    border-width: 3px !important;
    border-radius: 10px !important;
  }

  table.table,
  .table {
    font-size: 12px;
  }

  .btn,
  button.btn {
    font-size: 13px;
  }
}

/* Desktop: hamburger hidden only */
@media (min-width: 992px) {
  #header .mobile-nav-toggle,
  .mobile-nav-toggle {
    display: none !important;
  }
}
