/* ==========================================================================
   Responsive Layout - Mobile/Tablet Support
   All rules inside media queries - zero impact on desktop (>1024px)
   ========================================================================== */

/* Hide hamburger on desktop (element only exists for responsive) */
#hamburger-btn { display: none; }

/* ==========================================================================
   TABLET (<=1024px)
   Hamburger menu, stacked columns, scrollable tables
   ========================================================================== */

@media (max-width: 1024px) {

  /* --- Viewport --- */
  #page { min-width: 0; }

  /* --- Navigation panel: positioning context for hamburger --- */
  #nav_Panel {
    position: relative;
  }

  /* --- Hamburger Button (sits over the #pre_nav bar) --- */
  #hamburger-btn {
    display: block;
    position: absolute;
    top: -1px;
    left: 20px;
    z-index: 10;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    width: 28px;
    height: 24px;
    -webkit-appearance: none;
    outline: none;
  }

  #hamburger-btn span {
    display: block;
    width: 100%;
    height: 3px;
    background-color: #152950;
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.2s ease;
  }

  #hamburger-btn span:nth-child(1) { margin-bottom: 5px; }
  #hamburger-btn span:nth-child(3) { margin-top: 5px; }

  /* Animate to X when open */
  #hamburger-btn.open span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }
  #hamburger-btn.open span:nth-child(2) {
    opacity: 0;
  }
  #hamburger-btn.open span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }

  /* --- Navigation --- */
  #nav {
    display: none;
    padding: 8px 20px 12px 20px;
  }

  #nav.open {
    display: block;
  }

  .nav_item {
    float: none;
    display: block;
    margin-right: 0;
    margin-bottom: 6px;
    text-align: center;
  }

  .nav_title {
    text-align: center;
  }

  /* --- Pre-nav bar --- */
  #pre_nav {
    padding-left: 56px;
  }

  #pre_nav_inner {
    width: auto;
    max-width: 250px;
  }

  #loggedin {
    width: auto;
    max-width: 200px;
    font-size: 9px;
  }

  /* --- Page content --- */
  .page_body {
    padding: 16px 10px;
    overflow-x: auto;
  }

  /* --- Scrollable table containers --- */
  #listScheduleContainer,
  #tSheet_table_container,
  .page_body {
    -webkit-overflow-scrolling: touch;
  }

  /* --- Subnav row: stack splits --- */
  .subnav_row .split {
    float: none;
    display: block;
    margin-right: 0;
    margin-bottom: 8px;
  }

  .subnav_row {
    font-size: 16px;
  }

  /* --- Form selects: fluid width --- */
  select {
    min-width: 0;
    max-width: 100%;
  }

  /* --- Table button groups: stack --- */
  .table_btns_container {
    float: none;
    display: flex;
    flex-wrap: wrap;
    overflow: visible;
    border-radius: 0;
    border: none;
  }

  .table_btn {
    float: none;
    border: 1px solid #AFAEAC;
    border-radius: 4px;
    margin: 0 4px 4px 0;
  }

  /* --- Modal tweaks --- */
  .modal-dialog {
    max-width: 98%;
    margin: 10px auto;
  }

  .modal-header {
    height: 60px;
    padding: 14px 16px;
    background-size: 160px auto;
  }

  .modal .nav_border {
    top: 60px;
  }

  .modal-body {
    position: relative;
    padding: 76px 16px 16px 16px;
  }

  .modal-title {
    font-size: 18px;
    line-height: 30px;
  }

  .modal-buttons .btn {
    min-width: 80px;
    font-size: 11px;
    padding: 6px;
  }

  /* --- Modal columns: stack --- */
  .modal-body .column {
    width: 100%;
    float: none;
  }

  .modal-body .column:nth-child(1) { padding-right: 0; }
  .modal-body .column:nth-child(2) { padding-left: 0; margin-top: 16px; }

  /* --- Modal sidebar: stack above body --- */
  .modal-sidebar {
    position: relative;
    width: 100%;
    height: auto;
    padding: 76px 16px 16px 16px;
    border-right: none;
    border-bottom: 1px solid #c4c4c4;
    overflow-y: visible;
  }

  .modal-body-with-sidebar {
    position: relative;
    height: auto;
    padding: 16px;
    overflow-y: visible;
  }

  #accountModal .modal-sidebar { width: 100%; }
  #accountModal .modal-body-with-sidebar { padding-left: 16px; }

  .modal-content {
    min-height: auto;
  }

  /* --- Modal form items: stack label/field --- */
  .modal_item .split {
    float: none;
    display: block;
    min-width: 0;
    margin-right: 0;
    margin-bottom: 4px;
  }

  .modal_item .split:nth-child(2) {
    min-width: 0;
  }

  .modal_item .label { min-width: 0; }
  .modal_item .labelled_item { min-width: 0; margin-left: 0; }

  .modal_textarea {
    min-width: 0;
    width: 100%;
  }

  /* --- DataTables controls: full width --- */
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    width: 100%;
    text-align: left;
    float: none;
    margin-bottom: 8px;
  }

  /* --- Page title row: stack --- */
  .page_title_inner {
    float: none;
    margin-bottom: 8px;
  }

}


/* ==========================================================================
   MOBILE (<=768px)
   Full-width forms, compact modals, smaller fonts
   ========================================================================== */

@media (max-width: 768px) {

  /* --- Body font --- */
  #page {
    font-size: 13px;
  }

  /* --- Tighter page padding --- */
  .page_body {
    padding: 12px 8px;
  }

  /* --- Form inputs: full width --- */
  input[type="text"],
  input[type="search"],
  select {
    width: 100%;
    max-width: 100%;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  /* --- Buttons: larger touch targets --- */
  .btn {
    padding: 10px 12px;
    font-size: 12px;
  }

  /* --- Pre-nav: compact --- */
  #loggedin {
    font-size: 8px;
    max-width: 160px;
  }

  /* --- Modal: compact headers --- */
  .modal-header {
    height: 50px;
    padding: 10px 12px;
    background-size: 130px auto;
  }

  .modal .nav_border {
    top: 50px;
  }

  .modal-body {
    padding: 66px 12px 12px 12px;
  }

  .modal-sidebar {
    padding: 66px 12px 12px 12px;
  }

  .modal-title {
    font-size: 16px;
    line-height: 28px;
  }

  .modal-buttons .btn {
    min-width: 60px;
    font-size: 10px;
    padding: 6px 4px;
    margin-right: 4px;
  }

  /* --- Leave navigation: stack --- */
  #leave_right {
    width: 100%;
    float: none;
    padding: 8px 0;
  }

  /* --- Subnav: smaller --- */
  .subnav_row {
    font-size: 14px;
    padding-bottom: 6px;
  }

  /* --- Table header: smaller font --- */
  table th {
    font-size: 13px;
    padding: 6px;
  }

  table td {
    font-size: 12px;
  }

  /* --- Nav items: slightly smaller --- */
  .nav_item {
    padding: 8px 12px;
    font-size: 11px;
  }

}


/* ==========================================================================
   SMALL PHONE (<=480px)
   Full-screen modals, minimal padding
   ========================================================================== */

@media (max-width: 480px) {

  /* --- Minimal page padding --- */
  .page_body {
    padding: 8px 4px;
  }

  /* --- Full-screen modals --- */
  .modal-dialog {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
  }

  .modal-content {
    border-radius: 0;
  }

  .modal-header {
    border-radius: 0;
  }

  /* --- Modal buttons: stack if needed --- */
  .modal-buttons {
    float: none;
    margin-top: 4px;
  }

  .modal-buttons .btn {
    margin-bottom: 4px;
  }

  /* --- Footer buttons: larger tap area --- */
  .modal-footer .btn {
    padding: 12px;
    font-size: 13px;
  }

  /* --- Pre-nav: very compact --- */
  #pre_nav {
    padding: 0 8px 0 48px;
    font-size: 10px;
  }

  #pre_nav_inner {
    max-width: 200px;
  }

  #loggedin {
    font-size: 8px;
    max-width: 140px;
  }

  /* --- Nav items: full width --- */
  .nav_item {
    padding: 10px;
    font-size: 12px;
    border-radius: 4px;
  }

  /* --- Subnav: even more compact --- */
  .subnav_row {
    font-size: 13px;
  }

  .subnav_row .split {
    margin-bottom: 6px;
  }

}
