/* ==========================================================================
   responsive.css — app-wide mobile responsiveness
   Loaded LAST (after style.css / style2.css) so it overrides the desktop theme.
   Targets the shared layout: .content-wrap > .main > .container-fluid > .row.
   ========================================================================== */

html, body { max-width: 100%; overflow-x: hidden; overflow-x: clip; }
img { max-width: 100%; height: auto; }
table { max-width: 100%; }

/* --- Let wide report tables scroll inside their card instead of breaking layout --- */
.card, .card-body { max-width: 100%; }
@media (max-width: 991px) {
  .card-body, .content-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* --- Tablet & phone: stack every column full-width --- */
@media (max-width: 991px) {
  .row {
    display: flex;
    flex-wrap: wrap;
    margin-left: 0;
    margin-right: 0;
  }
  .row > [class*="col-"] {
    flex: 0 0 100%;
    width: 100%;
    max-width: 100%;
    padding-left: 8px;
    padding-right: 8px;
  }
  .main { padding-left: 8px; padding-right: 8px; }
  .container-fluid { padding-left: 8px; padding-right: 8px; }

  /* page header: title over breadcrumb */
  .main .page-header { min-height: auto; margin: 10px 0 5px; padding: 0 5px; }
  .main .page-header h1 { font-size: 17px; padding: 8px 0; }
  .main .page-header .breadcrumb { float: none; padding: 0 0 8px; }
}

/* --- Phone --- */
@media (max-width: 767px) {
  /* On phones, the collapsed desktop icon rail must be fully off-canvas. */
  .sidebar.sidebar-hide-to-small {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 250px !important;
    z-index: 1101 !important;
    transform: translateX(0);
    transition: transform 300ms ease-in-out;
  }
  body.sidebar-hide .sidebar.sidebar-hide-to-small {
    left: 0 !important;
    width: 250px !important;
    transform: translateX(-100%);
    visibility: hidden;
    pointer-events: none;
  }
  body:not(.sidebar-hide) .sidebar.sidebar-hide-to-small {
    visibility: visible;
    pointer-events: auto;
  }
  /* Mobile navigation is an overlay; it never reserves content width. */
  .sidebar.sidebar-shrink ~ .content-wrap,
  .sidebar.sidebar-hide-to-small ~ .content-wrap,
  body.sidebar-hide .sidebar.sidebar-hide-to-small ~ .content-wrap {
    margin-left: 0 !important;
    transform: none !important;
  }
  .header,
  body.sidebar-hide .sidebar.sidebar-hide-to-small ~ .header {
    margin-left: 0 !important;
  }
  .mobile-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, .35);
    opacity: 0;
    visibility: hidden;
    display: none;            /* never present unless the drawer is open */
    pointer-events: none;     /* purely visual dimming; never intercepts clicks */
    transition: opacity 300ms ease-in-out, visibility 300ms ease-in-out;
  }
  body.mobile-sidebar-open .mobile-sidebar-backdrop {
    display: block;
    opacity: 1;
    visibility: visible;
    pointer-events: none;
  }

  .main .page-header h1 { font-size: 15px; line-height: 1.35; }
  .main .page-header .breadcrumb li a,
  .main .page-header .breadcrumb li.active { font-size: 12px; }
  .card { margin-bottom: 12px; }
  .card-body { padding: 12px; }
  .btn { white-space: normal; }
  .table > thead > tr > th,
  .table > tbody > tr > td { padding: 6px 8px; font-size: 13px; }

  /* header bar */
  .header-icon { padding: 10px; font-size: 16px; }
  .user-avatar { font-size: 12px; }
  .dropdown-profile { width: 180px; }
}

@media (max-width: 480px) {
  .main .page-header h1 { font-size: 14px; }
  .card-body { padding: 10px; }
  .table > thead > tr > th,
  .table > tbody > tr > td { padding: 5px 6px; font-size: 12px; }

  /* full-width primary actions on tiny screens */
  .text-center > .btn-primary,
  .text-center > input[type="submit"] { width: 100% !important; }

  /* fixed-width tables/panels (e.g. success pages) become fluid */
  table[style*="width:400px"], table[style*="width: 400px"] { width: 100% !important; }
  .dropdown-menu { max-width: calc(100vw - 20px); }
}

/* --- Login page --- */
@media (max-width: 767px) {
  .unix-login .container-fluid { padding: 0 12px; }
  .login-content { margin: 0 auto; }
  .login-form { padding: 15px; }
}

/* --- Only the table scrolls (height is set by js/table-scroll.js) --- */
.table-scroll { overflow: auto; -webkit-overflow-scrolling: touch; }
.table-scroll > .table { margin-bottom: 0; }

/* --- Day repeaters (Add/Edit GCK): stack fields on phones so Label is full width --- */
@media (max-width: 767px) {
  #daysTable, #mDaysTable { display: block; width: 100%; }
  #daysTable thead, #mDaysTable thead { display: none; }
  #daysTable tbody, #mDaysTable tbody,
  #daysTable tr, #mDaysTable tr { display: block; width: 100%; }
  #daysTable td, #mDaysTable td {
    display: block; width: 100%; padding: 4px 0; border: 0;
  }
  #daysTable tr, #mDaysTable tr {
    border-bottom: 1px solid #e3e6f0; padding-bottom: 8px; margin-bottom: 8px;
  }
  #daysTable td:last-child, #mDaysTable td:last-child { text-align: right; }
  #daysTable td:last-child .rm, #mDaysTable td:last-child .rm { display: inline-block; }
}
