/* =============================================================
   HITSOFT Portal responsive completion layer
   Stable candidate: 2026-07-13
   Shared by the central portal and every subportal.
   ============================================================= */

:root {
  --hit-mobile-topbar-h: var(--lp-topbar-h, 58px);
  --hit-mobile-gutter: clamp(.6rem, 2.8vw, 1rem);
  --hit-touch-target: 42px;
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  scroll-padding-top: calc(var(--hit-mobile-topbar-h) + .75rem);
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

body.sidebar-open {
  overscroll-behavior: contain;
}

img,
svg,
canvas,
video,
iframe,
object,
embed {
  max-width: 100%;
}

img,
video {
  height: auto;
}

.lp-wrapper,
.schedule-wrapper,
.portal-wrapper,
.lp-main,
.schedule-main,
.portal-main,
.lp-content,
.schedule-content,
.portal-content,
.settings-wrap,
.card,
.card-body,
.card-header,
.card-footer,
.modal-content,
.modal-body,
.tab-content,
.row,
[class*="col-"] {
  min-width: 0;
}

.lp-main,
.schedule-main,
.portal-main {
  width: 100%;
}

.lp-topbar,
.schedule-topbar,
.portal-topbar {
  padding-left: max(var(--hit-mobile-gutter), env(safe-area-inset-left)) !important;
  padding-right: max(var(--hit-mobile-gutter), env(safe-area-inset-right)) !important;
}

.lp-brand,
.schedule-brand,
.portal-brand,
.navbar-brand {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-topbar-actions,
.lp-topbar .ms-auto,
.schedule-topbar .ms-auto,
.portal-topbar .ms-auto {
  min-width: 0;
  flex: 0 0 auto;
}

.lp-sidebar,
.schedule-sidebar,
.portal-sidebar {
  padding-bottom: env(safe-area-inset-bottom);
}

.lp-sidebar-inner,
.schedule-sidebar-inner,
.portal-sidebar-inner {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.mobile-scroll-region,
.table-responsive,
.dataTables_wrapper.mobile-table-host,
.dataTables_scroll,
.dataTables_scrollBody,
.settings-role-matrix-wrap,
.gantt-scroll,
.team-calendar-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto !important;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.mobile-scroll-region:focus-visible,
.table-responsive:focus-visible,
.dataTables_wrapper.mobile-table-host:focus-visible {
  outline: 2px solid rgba(37, 99, 235, .55);
  outline-offset: 2px;
}

.table {
  max-width: none;
}

.table.mobile-wide-table {
  width: max-content !important;
  min-width: 100% !important;
}

.table.mobile-wide-table th,
.table.mobile-wide-table td {
  white-space: nowrap;
}

.table.mobile-wide-table td.text-wrap,
.table.mobile-wide-table th.text-wrap,
.table.mobile-wide-table .text-wrap,
.table.mobile-wide-table td.mobile-allow-wrap,
.table.mobile-wide-table th.mobile-allow-wrap {
  white-space: normal;
  min-width: 180px;
}

.dataTables_wrapper {
  width: 100%;
  max-width: 100%;
}

.dataTables_wrapper .dataTables_scrollHeadInner,
.dataTables_wrapper .dataTables_scrollHeadInner table,
.dataTables_wrapper .dataTables_scrollBody table {
  min-width: 100%;
}

.dataTables_wrapper .row {
  --bs-gutter-y: .5rem;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select,
.col-filter,
.col-filter-select,
.form-control,
.form-select,
.input-group,
textarea {
  max-width: 100%;
}

.modal-dialog {
  max-width: calc(100vw - 1rem);
}

.modal-content {
  max-width: 100%;
}

.modal-body {
  min-height: 0;
  overflow-x: hidden;
}

.dropdown-menu,
.popover,
.tooltip-inner,
.toast {
  max-width: calc(100vw - 1rem);
}

#portalToastHost {
  max-width: 100vw;
  padding-top: max(1rem, env(safe-area-inset-top)) !important;
  padding-right: max(.75rem, env(safe-area-inset-right)) !important;
  padding-left: max(.75rem, env(safe-area-inset-left)) !important;
}

#portalToastHost .toast {
  width: min(360px, calc(100vw - 1.5rem));
}

.portal-tiles {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr));
  align-items: stretch;
}

.portal-tiles .p-tile,
.portal-tiles .lp-tile {
  width: 100% !important;
  max-width: none !important;
  height: 100%;
}

.chart-container,
.schedule-chart-card,
canvas[data-chart],
.card canvas {
  max-width: 100% !important;
}

#scheduleTimeline,
.vis-timeline,
.leave-gantt,
.leave-gantt-grid,
.team-calendar-grid {
  max-width: 100%;
  touch-action: pan-x pan-y;
}

.scroll-to-top,
#scrollToTop,
.back-to-top {
  right: max(1rem, env(safe-area-inset-right)) !important;
  bottom: max(1rem, env(safe-area-inset-bottom)) !important;
}

@media (max-width: 991.98px) {
  body.lp-body,
  body.schedule-body,
  body.portal-body {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .lp-main,
  .schedule-main,
  .portal-main {
    margin-left: 0 !important;
    max-width: 100% !important;
  }

  .lp-content,
  .schedule-content,
  .portal-content,
  .settings-wrap {
    width: 100%;
    max-width: 100%;
    padding-left: var(--hit-mobile-gutter) !important;
    padding-right: var(--hit-mobile-gutter) !important;
  }

  .lp-sidebar,
  .schedule-sidebar.lp-sidebar,
  .portal-sidebar {
    top: var(--hit-mobile-topbar-h) !important;
    bottom: 0 !important;
    left: 0 !important;
    width: min(86vw, 310px) !important;
    max-width: 310px;
    height: auto !important;
    transform: translate3d(-105%, 0, 0) !important;
    transition: transform .22s ease !important;
    z-index: 1042 !important;
    box-shadow: 10px 0 30px rgba(15, 23, 42, .28);
  }

  .lp-sidebar.open,
  .lp-sidebar.show,
  .schedule-sidebar.lp-sidebar.open,
  .schedule-sidebar.lp-sidebar.show,
  .portal-sidebar.open,
  .portal-sidebar.show,
  body.sidebar-open .lp-sidebar,
  body.sidebar-open .schedule-sidebar,
  body.sidebar-open .portal-sidebar {
    transform: translate3d(0, 0, 0) !important;
  }

  .lp-overlay.show,
  .schedule-overlay.show,
  .portal-overlay.show,
  body.sidebar-open .lp-overlay,
  body.sidebar-open .schedule-overlay,
  body.sidebar-open .portal-overlay {
    display: block !important;
    position: fixed !important;
    inset: var(--hit-mobile-topbar-h) 0 0 !important;
    background: rgba(15, 23, 42, .55) !important;
    backdrop-filter: blur(2px);
    z-index: 1041 !important;
  }

  .lp-page-header,
  .page-header,
  .portal-page-header,
  .content-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start !important;
    gap: .75rem;
  }

  .lp-page-header > *,
  .page-header > *,
  .portal-page-header > *,
  .content-header > * {
    min-width: 0;
  }

  .lp-page-header .ms-auto,
  .page-header .ms-auto,
  .portal-page-header .ms-auto,
  .content-header .ms-auto,
  .page-actions,
  .lp-page-actions,
  .portal-page-actions {
    margin-left: 0 !important;
    display: flex;
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: .5rem;
  }

  .card-header > .d-flex,
  .card-footer > .d-flex,
  .filter-bar,
  .filters-bar,
  .toolbar,
  .page-toolbar {
    flex-wrap: wrap !important;
    gap: .5rem;
  }

  form.d-flex:not(.portal-global-search),
  .card-body > .d-flex.flex-wrap {
    max-width: 100%;
  }

  .settings-display-table,
  #tblRoleMatrix {
    min-width: 900px;
  }

  #scheduleTimeline {
    min-height: 58vh;
  }
}

@media (max-width: 767.98px) {
  :root {
    --hit-touch-target: 44px;
  }

  body.lp-body,
  body.schedule-body,
  body.portal-body {
    font-size: .91rem;
  }

  .lp-topbar.navbar,
  .schedule-topbar.navbar,
  .portal-topbar.navbar {
    gap: .3rem !important;
  }

  .lp-brand,
  .schedule-brand,
  .portal-brand,
  .navbar-brand {
    max-width: calc(100vw - 188px) !important;
    margin-right: auto !important;
    font-size: .94rem !important;
  }

  .portal-welcome-pill {
    display: none !important;
  }

  .lp-topbar-btn,
  .topbar-btn,
  .portal-topbar-btn,
  .lp-sidebar-toggle {
    min-width: var(--hit-touch-target);
    min-height: var(--hit-touch-target);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .35rem .5rem !important;
  }

  .lp-content,
  .schedule-content,
  .portal-content,
  .settings-wrap {
    padding-top: .85rem !important;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)) !important;
  }

  .card {
    border-radius: 12px;
  }

  .card-header,
  .card-body,
  .card-footer {
    padding-left: .85rem;
    padding-right: .85rem;
  }

  .btn:not(.btn-sm):not(.btn-close),
  .form-control:not(.form-control-sm),
  .form-select:not(.form-select-sm),
  .input-group-text:not(.input-group-sm .input-group-text) {
    min-height: var(--hit-touch-target);
  }

  input.form-control,
  select.form-select,
  textarea.form-control,
  input[type="date"],
  input[type="datetime-local"],
  input[type="time"],
  input[type="number"],
  input[type="search"] {
    font-size: 16px !important;
  }

  .input-group.mobile-wrap,
  .modal-body .input-group,
  .filter-bar .input-group,
  .filters-bar .input-group {
    flex-wrap: wrap;
    gap: .35rem;
  }

  .input-group.mobile-wrap > .form-control,
  .input-group.mobile-wrap > .form-select,
  .modal-body .input-group > .form-control,
  .modal-body .input-group > .form-select,
  .filter-bar .input-group > .form-control,
  .filters-bar .input-group > .form-control {
    flex: 1 1 100%;
    width: 100%;
    border-radius: var(--bs-border-radius) !important;
  }

  .modal-dialog,
  .modal-dialog.modal-sm,
  .modal-dialog.modal-lg,
  .modal-dialog.modal-xl {
    width: auto !important;
    max-width: calc(100vw - .75rem) !important;
    margin: .375rem auto !important;
  }

  .modal-content {
    max-height: calc(100dvh - .75rem);
    overflow: hidden;
  }

  .modal-header,
  .modal-footer {
    flex: 0 0 auto;
  }

  .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
  }

  .modal-footer .btn {
    flex: 1 1 calc(50% - .25rem);
    min-height: var(--hit-touch-target);
  }

  .dataTables_wrapper > .row > [class*="col-"] {
    width: 100% !important;
    text-align: left !important;
  }

  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dt-buttons,
  .dataTables_wrapper .dataTables_info,
  .dataTables_wrapper .dataTables_paginate {
    float: none !important;
    width: 100% !important;
    max-width: 100%;
    text-align: left !important;
  }

  .dataTables_wrapper .dataTables_length label,
  .dataTables_wrapper .dataTables_filter label {
    width: 100%;
  }

  .dataTables_wrapper .dataTables_filter input,
  .dataTables_wrapper .dataTables_length select {
    width: 100% !important;
    min-height: var(--hit-touch-target);
    margin: .25rem 0 0 !important;
  }

  .dataTables_wrapper .dt-buttons {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .4rem;
  }

  .dataTables_wrapper .dt-buttons .btn {
    width: 100%;
    white-space: normal;
  }

  .dataTables_wrapper .pagination {
    justify-content: flex-start !important;
    flex-wrap: wrap;
    gap: .2rem;
  }

  .table th,
  .table td {
    padding: .5rem .55rem;
    font-size: .84rem;
  }

  .mobile-sticky-first th:first-child,
  .mobile-sticky-first td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bs-body-bg, #fff);
    box-shadow: 1px 0 0 rgba(148, 163, 184, .32);
  }

  .mobile-sticky-first thead th:first-child {
    z-index: 4;
  }

  body[data-theme="dark"] .mobile-sticky-first th:first-child,
  body[data-theme="dark"] .mobile-sticky-first td:first-child {
    background: #111827;
  }

  .page-actions .btn,
  .lp-page-actions .btn,
  .portal-page-actions .btn,
  .content-header .btn,
  .lp-page-header .btn,
  .page-header .btn {
    flex: 1 1 auto;
  }

  .receipt-name {
    max-width: min(220px, 60vw) !important;
  }

  .profile-card,
  .password-card,
  .login-card,
  .error-card {
    width: calc(100% - 1rem) !important;
    max-width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .two-factor-qr-img {
    width: min(220px, 70vw) !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
  }

  #scheduleTimeline .vis-labelset .vis-label,
  #scheduleTimeline .vis-time-axis .vis-text {
    font-size: .78rem;
  }
}

@media (max-width: 575.98px) {
  .lp-brand,
  .schedule-brand,
  .portal-brand,
  .navbar-brand {
    max-width: calc(100vw - 172px) !important;
  }

  .lp-page-header h1,
  .page-header h1,
  .portal-page-header h1,
  .content-header h1,
  h1.h3,
  h1.h4 {
    font-size: 1.12rem !important;
    line-height: 1.25;
  }

  .modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .modal-footer .btn {
    width: 100%;
    flex-basis: 100%;
  }

  .dataTables_wrapper .dt-buttons {
    grid-template-columns: 1fr;
  }

  .portal-tiles {
    grid-template-columns: 1fr !important;
    gap: .85rem !important;
    padding-left: .65rem !important;
    padding-right: .65rem !important;
  }

  .p-tile,
  .lp-tile {
    padding: 1.35rem .9rem !important;
  }

  .alert {
    padding: .75rem;
  }

  .badge {
    white-space: normal;
  }
}

@media (max-width: 430px) {
  .lp-topbar-btn,
  .topbar-btn,
  .portal-topbar-btn,
  .lp-sidebar-toggle {
    min-width: 38px;
    min-height: 38px;
    padding: .25rem .4rem !important;
  }

  .lp-brand,
  .schedule-brand,
  .portal-brand,
  .navbar-brand {
    max-width: calc(100vw - 154px) !important;
  }

  .lp-brand .bi,
  .schedule-brand .bi,
  .portal-brand .bi,
  .navbar-brand .bi {
    margin-right: .3rem !important;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .modal-content {
    max-height: calc(100dvh - .5rem);
  }

  .modal-dialog {
    margin-top: .25rem !important;
    margin-bottom: .25rem !important;
  }

  #scheduleTimeline {
    min-height: 320px;
  }
}

@media print {
  .mobile-scroll-region,
  .table-responsive,
  .dataTables_wrapper.mobile-table-host {
    overflow: visible !important;
  }

  .table.mobile-wide-table {
    width: 100% !important;
    min-width: 0 !important;
  }
}

/* =============================================================
   Global responsive sidebar toggle fix — 2026-07-13
   Applies to Central/Admin/Settings and every business subportal.
   ============================================================= */

#sidebarToggle.lp-sidebar-toggle {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 34px;
  min-height: 34px;
}

.lp-wrapper,
.schedule-wrapper,
.lp-sidebar,
.schedule-sidebar.lp-sidebar,
.lp-main,
.schedule-main {
  transition: width .22s ease, flex-basis .22s ease, transform .22s ease, opacity .18s ease;
}

@media (min-width: 992px) {
  body.sidebar-collapsed .lp-sidebar,
  body.sidebar-collapsed .schedule-sidebar.lp-sidebar {
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    flex: 0 0 0 !important;
    overflow: hidden !important;
    opacity: 0;
    transform: translate3d(-100%, 0, 0) !important;
    pointer-events: none;
    border: 0 !important;
  }

  body.sidebar-collapsed .lp-sidebar-inner,
  body.sidebar-collapsed .schedule-sidebar-inner {
    visibility: hidden;
  }

  body.sidebar-collapsed .lp-main,
  body.sidebar-collapsed .schedule-main {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 100% !important;
    margin-left: 0 !important;
  }
}
