/* HRMS mobile layout contract.
   Loaded after module styles so desktop-only width and margin rules cannot
   override the off-canvas shell on phones and tablets. */
:root {
  --hrms-mobile-gutter: clamp(0.625rem, 3vw, 1rem);
  --hrms-mobile-control-height: 2.75rem;
  --hrms-mobile-radius: 0.625rem;
  --hrms-safe-top: env(safe-area-inset-top, 0px);
  --hrms-safe-right: env(safe-area-inset-right, 0px);
  --hrms-safe-bottom: env(safe-area-inset-bottom, 0px);
  --hrms-safe-left: env(safe-area-inset-left, 0px);
}

html {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-x: clip;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden !important;
  overflow-x: clip !important;
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
}

img,
video {
  height: auto;
}

.content,
.main-content,
.main-content > *,
.main-content .container,
.main-content .container-fluid,
.row > *,
.card,
.card-body,
.modal-content,
.tab-content,
.filter-panel,
.filter-bar,
.action-bar,
.toolbar {
  min-width: 0;
}

.hrms-auto-table-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.hrms-auto-table-scroll:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.34);
  outline-offset: 2px;
}

.hrms-auto-table-scroll > table {
  margin-bottom: 0;
}

@media (max-width: 991.98px) {
  :root {
    --hrms-mobile-sidebar-width: min(86vw, 20rem);
    --hrms-page-pad-x: var(--hrms-mobile-gutter);
    --hrms-page-pad-y: var(--hrms-mobile-gutter);
  }

  body.hrms-shell {
    display: block !important;
    min-width: 0 !important;
    background-attachment: scroll !important;
  }

  body.hrms-shell.hrms-mobile-nav-open {
    overflow: hidden !important;
    touch-action: none;
  }

  html[dir="ltr"] body.hrms-shell .content,
  html[dir="rtl"] body.hrms-shell .content,
  html[dir="ltr"] body.hrms-shell .sidebar:hover ~ .content,
  html[dir="ltr"] body.hrms-shell .sidebar:focus-within ~ .content,
  html[dir="rtl"] body.hrms-shell .sidebar:hover ~ .content,
  html[dir="rtl"] body.hrms-shell .sidebar:focus-within ~ .content {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 100svh;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
  }

  html[dir="ltr"] body.hrms-shell .sidebar,
  html[dir="rtl"] body.hrms-shell .sidebar,
  html[dir="ltr"] body.hrms-shell .sidebar:hover,
  html[dir="rtl"] body.hrms-shell .sidebar:hover,
  html[dir="ltr"] body.hrms-shell .sidebar:focus-within,
  html[dir="rtl"] body.hrms-shell .sidebar:focus-within {
    position: fixed !important;
    inset-block: 0 !important;
    z-index: 1080 !important;
    width: var(--hrms-mobile-sidebar-width) !important;
    min-width: var(--hrms-mobile-sidebar-width) !important;
    max-width: var(--hrms-mobile-sidebar-width) !important;
    height: 100vh !important;
    height: 100dvh !important;
    margin: 0 !important;
    padding-block: calc(0.75rem + var(--hrms-safe-top)) calc(1rem + var(--hrms-safe-bottom)) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    transition: transform 180ms ease, box-shadow 180ms ease !important;
  }

  html[dir="ltr"] body.hrms-shell .sidebar,
  html[dir="ltr"] body.hrms-shell .sidebar:hover,
  html[dir="ltr"] body.hrms-shell .sidebar:focus-within {
    right: auto !important;
    left: 0 !important;
    transform: translate3d(-105%, 0, 0) !important;
  }

  html[dir="rtl"] body.hrms-shell .sidebar,
  html[dir="rtl"] body.hrms-shell .sidebar:hover,
  html[dir="rtl"] body.hrms-shell .sidebar:focus-within {
    right: 0 !important;
    left: auto !important;
    transform: translate3d(105%, 0, 0) !important;
  }

  html[dir="ltr"] body.hrms-shell.hrms-mobile-nav-open .sidebar,
  html[dir="rtl"] body.hrms-shell.hrms-mobile-nav-open .sidebar {
    transform: translate3d(0, 0, 0) !important;
  }

  body.hrms-shell .sidebar-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 1070 !important;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
  }

  body.hrms-shell .sidebar-brand,
  body.hrms-shell .sidebar .nav-link,
  body.hrms-shell .sidebar:hover .nav-link,
  body.hrms-shell .sidebar:focus-within .nav-link {
    width: 100% !important;
    max-width: 100% !important;
  }

  body.hrms-shell .topbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 1060 !important;
    display: grid !important;
    grid-template-columns: auto minmax(0, 1fr) !important;
    align-items: center !important;
    width: 100% !important;
    min-height: 3.5rem !important;
    gap: 0.5rem !important;
    padding: calc(0.45rem + var(--hrms-safe-top)) calc(var(--hrms-mobile-gutter) + var(--hrms-safe-right)) 0.45rem calc(var(--hrms-mobile-gutter) + var(--hrms-safe-left)) !important;
  }

  body.hrms-shell .mobile-sidebar-toggle {
    grid-column: 1;
    grid-row: 1;
    min-width: 2.75rem;
    min-height: 2.75rem;
    margin: 0 !important;
  }

  body.hrms-shell .topbar-actions {
    grid-column: 2;
    grid-row: 1;
    display: flex !important;
    flex: none !important;
    flex-wrap: nowrap !important;
    justify-content: flex-end !important;
    width: 100%;
    min-width: 0;
    gap: 0.35rem !important;
    margin: 0 !important;
  }

  html[dir="rtl"] body.hrms-shell .topbar-actions {
    justify-content: flex-start !important;
  }

  body.hrms-shell .topbar form[role="search"] {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    gap: 0.4rem;
    margin: 0 !important;
  }

  body.hrms-shell .topbar form[role="search"] .form-control {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  body.hrms-shell .topbar .btn,
  body.hrms-shell .topbar .form-control,
  body.hrms-shell .topbar .form-select {
    min-height: 2.5rem !important;
  }

  body.hrms-shell .topbar img.rounded-circle {
    flex: 0 0 1.75rem;
    width: 1.75rem !important;
    height: 1.75rem !important;
    aspect-ratio: 1;
  }

  body.hrms-shell .topbar-user-display {
    min-width: 0;
    max-width: min(24vw, 8rem);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.hrms-shell .main-icon-bar {
    display: none !important;
  }

  body.hrms-shell .main-content {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: var(--hrms-mobile-gutter) !important;
    overflow-x: hidden !important;
    overflow-x: clip !important;
  }

  body.hrms-shell .main-content > .container,
  body.hrms-shell .main-content > .container-fluid,
  body.hrms-shell .main-content .container,
  body.hrms-shell .main-content .container-fluid,
  body.hrms-shell .main-content > main,
  body.hrms-shell .main-content > section,
  body.hrms-shell .main-content > article,
  body.hrms-shell .main-content > [class$="-page"],
  body.hrms-shell .main-content > [class*="-page"] {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-inline: auto !important;
    padding-inline: 0 !important;
  }

  body.hrms-shell .main-content :is(.row, .d-flex, .input-group, .btn-group, form) {
    max-width: 100%;
  }

  body.hrms-shell .main-content :is(.card, .dashboard-card, .chart-card, .filter-panel, .filter-bar, .summary-card, .apps-header, .module-strip, .workflow-band, .tab-content, .alert) {
    width: auto;
    max-width: 100% !important;
    margin-inline: 0;
  }

  body.hrms-shell .table-responsive,
  body.hrms-shell .table-wrap,
  body.hrms-shell .table-scroll,
  body.hrms-shell .hrms-table-scroll,
  body.hrms-shell .hrms-auto-table-scroll,
  body.hrms-shell .overflow-x-auto {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    overflow-y: visible;
  }

  body.hrms-shell :is(.table-responsive, .table-wrap, .table-scroll, .hrms-table-scroll, .hrms-auto-table-scroll) > table {
    width: max-content !important;
    min-width: max(100%, 47.5rem) !important;
    max-width: none !important;
  }

  body.hrms-shell .modal-dialog {
    width: calc(100vw - 1rem) !important;
    max-width: calc(100vw - 1rem) !important;
    margin: 0.5rem auto !important;
  }

  body.hrms-shell .modal-content {
    max-height: calc(100vh - 1rem);
    max-height: calc(100dvh - 1rem);
    overflow: hidden;
  }

  body.hrms-shell .modal-body {
    min-height: 0;
    max-height: none !important;
    overflow: auto !important;
    overscroll-behavior: contain;
  }

  body.hrms-shell .dropdown-menu {
    max-width: calc(100vw - 1rem);
    max-height: min(70vh, 32rem);
    overflow: auto;
  }

  body:not(.hrms-shell) {
    min-width: 0 !important;
    height: auto !important;
    min-height: 100svh;
    padding-inline: max(var(--hrms-mobile-gutter), var(--hrms-safe-left)) max(var(--hrms-mobile-gutter), var(--hrms-safe-right));
    padding-block: max(var(--hrms-mobile-gutter), var(--hrms-safe-top)) max(var(--hrms-mobile-gutter), var(--hrms-safe-bottom));
    background-attachment: scroll !important;
  }

  body:not(.hrms-shell) > * {
    max-width: 100%;
  }

  body:not(.hrms-shell) > :is(.container, .portal-shell, .portal-container, .login-container, .login-box, .login-wrapper, .auth-card, .page, main) {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-inline: auto !important;
  }

  body:not(.hrms-shell) :is(form, input, select, textarea, button, .btn) {
    max-width: 100%;
  }

  body:not(.hrms-shell) :is(input, select, textarea) {
    width: 100%;
  }
}

@media (max-width: 575.98px) {
  :root {
    --hrms-mobile-gutter: clamp(0.5rem, 2.8vw, 0.75rem);
  }

  body.hrms-shell .topbar-user-display,
  body.hrms-shell .topbar img.rounded-circle {
    display: none !important;
  }

  body.hrms-shell .topbar-actions .btn,
  body.hrms-shell .topbar-actions .language-switch .btn {
    min-height: 2.5rem !important;
    padding-inline: 0.55rem !important;
    font-size: 0.78rem !important;
  }

  body.hrms-shell .mobile-sidebar-toggle__label {
    max-width: 5rem;
  }

  body.hrms-shell .main-content :is(.filter-panel, .filter-bar, .action-bar, .page-actions, .toolbar, .button-row) {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100%;
    gap: 0.5rem !important;
  }

  body.hrms-shell .main-content :is(.filter-panel, .filter-bar, .action-bar, .page-actions, .toolbar, .button-row) > :is(.btn, button, a.btn, .form-control, .form-select, .input-group) {
    width: 100%;
    max-width: 100%;
  }

  body.hrms-shell .main-content form .row > [class*="col-"] {
    flex: 0 0 100%;
    width: 100%;
    max-width: 100%;
  }

  body.hrms-shell .main-content :is(h1, .h1, .page-title) {
    font-size: clamp(1.05rem, 5.5vw, 1.3rem) !important;
  }

  body.hrms-shell .main-content :is(h2, .h2, .section-title) {
    font-size: clamp(0.95rem, 4.8vw, 1.1rem) !important;
  }

  body.hrms-shell .main-content :is(.btn, button, input, select, textarea, .form-control, .form-select) {
    min-height: var(--hrms-mobile-control-height);
  }

  body.hrms-shell .hrms-status-grid__item,
  body.hrms-shell .attendance-status-grid .hrms-status-grid__item {
    flex: 1 1 calc(50% - 0.5rem) !important;
    width: auto !important;
    min-width: min(8.5rem, 100%) !important;
  }
}

@media (max-width: 340px) {
  body.hrms-shell .topbar {
    grid-template-columns: auto minmax(0, 1fr) !important;
  }

  body.hrms-shell .mobile-sidebar-toggle__label {
    display: none;
  }

  body.hrms-shell .topbar-actions {
    gap: 0.2rem !important;
  }

  body.hrms-shell .topbar-actions .btn,
  body.hrms-shell .topbar-actions .language-switch .btn {
    padding-inline: 0.42rem !important;
    font-size: 0.74rem !important;
  }

  body.hrms-shell .hrms-status-grid__item,
  body.hrms-shell .attendance-status-grid .hrms-status-grid__item {
    flex-basis: 100% !important;
  }
}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 991.98px) {
  body.hrms-shell .topbar {
    position: relative !important;
  }

  body.hrms-shell .sidebar {
    padding-block-start: max(0.5rem, var(--hrms-safe-top)) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  html:focus-within {
    scroll-behavior: auto !important;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .hrms-auto-table-scroll {
    width: 100% !important;
    max-width: none !important;
    overflow: visible !important;
  }
}
