/* Responsive override for Dashboard and custom modules. Does not alter PHP/HTML structure. */
:root {
  --ui-space-1: clamp(.25rem, .5vw, .5rem);
  --ui-space-2: clamp(.5rem, 1vw, 1rem);
  --ui-space-3: clamp(.75rem, 1.5vw, 1.5rem);
  --ui-space-4: clamp(1rem, 2vw, 2rem);
  --ui-sidebar: clamp(14rem, 18vw, 18rem);
  --ui-content-max: 100%;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: clamp(13px, .25vw + 12px, 18px); }
body { min-width: 200px; overflow-x: hidden; }
img, svg, video, canvas { max-width: 100%; height: auto; }
iframe { max-width: 100%; }

#wrapper { display: flex; flex-flow: row nowrap; align-items: stretch; width: 100%; min-height: 100vh; }
#sidebar-wrapper { flex: 0 0 var(--ui-sidebar); width: var(--ui-sidebar); max-width: 100vw; min-height: 100vh; }
#sidebar-wrapper .sidebar-heading { min-width: 0 !important; width: 100%; padding-inline: var(--ui-space-2); overflow-wrap: anywhere; }
#sidebar-wrapper .list-group-item { padding: clamp(.5rem, 1.1vw, .95rem) clamp(.65rem, 1.4vw, 1.25rem); }
#sidebar-wrapper .menu-text { overflow-wrap: anywhere; }
#page-content-wrapper { flex: 1 1 auto; width: auto; min-width: 0; max-width: var(--ui-content-max); }
#content, #page-content-wrapper > * { min-width: 0; }

.container, .container-fluid { width: 100%; max-width: 100%; padding-inline: var(--ui-space-3); }
.row { --bs-gutter-x: clamp(.5rem, 1.5vw, 1.5rem); }
.card, .modal-content, .dropdown-menu, .accordion, .input-group { max-width: 100%; }
.card-body, .modal-body, .table-responsive, .dataTables_wrapper { min-width: 0; }
.table-responsive { width: 100% !important; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { min-width: max-content; }
pre, code { max-width: 100%; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.form-control, .form-select, .select2-container, .select2-selection { max-width: 100%; min-width: 0; }
.btn { max-width: 100%; white-space: normal; }

#dragFiles { min-height: clamp(5rem, 12vw, 8rem); line-height: normal; display: grid; place-items: center; padding: var(--ui-space-3); text-align: center; }
#up { width: clamp(2.75rem, 5vw, 3.75rem); line-height: clamp(2.75rem, 5vw, 3.75rem); right: var(--ui-space-2); bottom: var(--ui-space-2); }

@media (max-width: 1199.98px) {
  #sidebar-wrapper { flex-basis: clamp(13rem, 24vw, 16rem); }
  .display-1, .display-2, .display-3, .display-4 { font-size: clamp(2rem, 5vw, 4rem); }
}

@media (max-width: 991.98px) {
  #wrapper { display: block; }
  #sidebar-wrapper { position: fixed; inset: 0 auto 0 0; width: min(82vw, 18rem); transform: translateX(-105%); transition: transform .25s ease; z-index: 1050; overflow-y: auto; }
  #sidebar-wrapper.show { transform: translateX(0); }
  #page-content-wrapper { width: 100%; }
  #menu-toggle { display: inline-flex; align-items: center; justify-content: center; margin: var(--ui-space-2); }
  .modal-dialog { width: auto; max-width: calc(100% - 1rem); margin: .5rem auto; }
  .row > [class*="col-"] { min-width: 0; }
}

@media (max-width: 767.98px) {
  html { font-size: clamp(13px, 1.2vw + 10px, 16px); }
  .container, .container-fluid { padding-inline: var(--ui-space-2); }
  .row { --bs-gutter-y: .75rem; }
  .d-flex:not(.flex-nowrap) { flex-wrap: wrap; }
  .btn-group, .input-group { flex-wrap: wrap; }
  .btn-group > .btn, .input-group > .form-control, .input-group > .form-select { flex: 1 1 auto; }
  .modal-dialog { max-width: calc(100% - .5rem); }
  .modal-header, .modal-footer { gap: var(--ui-space-1); flex-wrap: wrap; }
  .table { font-size: .875rem; }
  .table td, .table th { white-space: nowrap; }
  .nav-tabs, .pagination { overflow-x: auto; flex-wrap: nowrap; }
}

@media (max-width: 399.98px) {
  html { font-size: 13px; }
  .container, .container-fluid { padding-inline: .5rem; }
  .card-body { padding: .75rem; }
  .btn { width: 100%; }
  .btn-group { width: 100%; }
  .btn-group > .btn { flex: 1 1 100%; }
  .form-label { overflow-wrap: anywhere; }
}

@media (min-width: 1920px) {
  #page-content-wrapper { max-width: 100%; }
  .container, .container-fluid { padding-inline: clamp(1.5rem, 3vw, 4rem); }
}

@media (min-width: 2560px) {
  html { font-size: clamp(16px, .35vw + 12px, 22px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
