/* AruHub mobile layout repair. App data, permissions and desktop layout are unchanged. */
@media (max-width: 1279px) {
  [data-slot="sidebar-inset"] { min-width: 0; }
  [data-slot="sidebar-inset"] .flex.shrink-0.flex-wrap { max-width: 100%; flex-shrink: 1; }
  [data-slot="sidebar-wrapper"] > header > div { min-width: 0; }
  [data-slot="sidebar-wrapper"] > header .ms-auto { min-width: 0; }
  /* The existing compact navigation was inside a desktop-only parent. */
  [data-slot="sidebar-wrapper"] > header .me-1.hidden.lg\:block { display: block !important; }
  [data-slot="sidebar-wrapper"] > header .me-1 > .lg\:hidden { display: block !important; }
  [data-slot="sidebar-wrapper"] > header nav { display: none !important; }
  [data-slot="sidebar-wrapper"] > header button:has(> .lucide-search) {
    width: 36px !important; min-width: 36px; height: 36px; padding: 0 !important;
    flex: 0 0 36px !important; justify-content: center;
  }
  [data-slot="sidebar-wrapper"] > header button:has(> .lucide-search) > :is(span,kbd) { display: none !important; }
  [data-slot="sidebar-wrapper"] > header button > .lucide-search { position: static; transform: none; }
}
@media (max-width: 767px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { background-attachment: scroll; }
  [data-slot="sidebar-wrapper"] { min-height: 100svh; min-height: 100dvh; }
  [data-slot="sidebar-wrapper"] > header {
    --app-header-height: calc(52px + env(safe-area-inset-top, 0px));
    height: var(--app-header-height); padding-top: env(safe-area-inset-top, 0px);
    box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none;
  }
  [data-slot="sidebar-wrapper"] > header > div { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); gap: 4px; }
  [data-slot="sidebar-wrapper"] > header > div > a { min-width: 0; flex-shrink: 1; }
  [data-slot="sidebar-wrapper"] > header > div > a > span { max-width: 7rem; }
  [data-slot="sidebar-wrapper"] > header .ms-auto { gap: 2px; flex-shrink: 0; }
  [data-slot="sidebar-wrapper"] > header button:not([style*="display: none"]) { min-width: 36px; min-height: 36px; }
  [data-slot="sidebar-wrapper"] > header [data-slot="avatar"] { width: 28px; height: 28px; }
  [data-slot="sidebar-inset"] {
    min-width: 0; width: 100%; margin: 0 !important;
    height: calc(100svh - 52px - env(safe-area-inset-top, 0px)) !important;
    height: calc(100dvh - 52px - env(safe-area-inset-top, 0px)) !important;
    border-radius: 0 !important;
  }
  [data-slot="sidebar-inset"] > main,
  [data-slot="sidebar-inset"] .flex.flex-col,
  [data-slot="sidebar-inset"] [data-slot="card"],
  [data-slot="sidebar-inset"] [data-slot="tabs"] { min-width: 0; }
  /* Let the dashboard controls wrap inside their actual available width. */
  [data-slot="sidebar-inset"] .flex.shrink-0.flex-wrap { max-width: 100%; flex-shrink: 1; }
  [data-slot="sidebar-inset"] [data-slot="tabs-list"] { max-width: 100%; overflow-x: auto; }
  [data-slot="sidebar"][data-mobile="true"] {
    width: min(20rem, calc(100vw - 48px)) !important;
    max-width: calc(100vw - 48px); height: 100svh; height: 100dvh;
    max-height: 100dvh; gap: 0;
    padding: max(44px, env(safe-area-inset-top)) 0 env(safe-area-inset-bottom);
  }
  [data-slot="sidebar"][data-mobile="true"] > .flex { min-height: 0; flex: 1; }
  [data-slot="sidebar"][data-mobile="true"] > button {
    display: inline-flex !important; position: absolute; top: max(4px, env(safe-area-inset-top)); right: 8px;
    width: 36px; height: 36px; align-items: center; justify-content: center; z-index: 1;
  }
  [data-mobile="true"] [data-slot="sidebar-content"] {
    min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch; padding-bottom: 12px;
  }
  [data-mobile="true"] [data-slot="sidebar-menu-button"] { min-height: 44px; }
  :is([data-slot="dialog-content"],[data-slot="alert-dialog-content"]) {
    max-width: calc(100vw - 24px) !important; min-width: 0 !important;
    max-height: calc(100svh - 24px); max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto; overscroll-behavior: contain;
  }
  html:root :is([data-slot="dialog-content"],[data-slot="alert-dialog-content"]) {
    top: calc(var(--aru-visual-top, 0px) + var(--aru-visual-height, 100dvh) / 2) !important;
    translate: -50% -50% !important;
    max-height: calc(var(--aru-visual-height, 100dvh) - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
  }
  [data-slot="sheet-content"] { max-width: 100vw; max-height: var(--aru-visual-height, 100dvh); }
  [data-slot="sheet-content"]:is([data-side="left"],[data-side="right"]) {
    top: var(--aru-visual-top, 0px); bottom: auto;
    height: var(--aru-visual-height, 100dvh);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  :is([data-slot="dialog-content"],[data-slot="sheet-content"]) :is(input,textarea,select) { font-size: 16px; }
  /* Existing global overflow:unset defeats the modal scroll lock on phones. */
  body[data-scroll-locked] { overflow: hidden !important; }
  [data-slot="sidebar-inset"] iframe { max-width: 100%; }
}
@media (max-width: 359px) {
  [data-slot="sidebar-wrapper"] > header > div > a > span { display: none; }
}


@media (max-width: 767px) {
  /* Stacked log filters must not consume the fixed-height list viewport. */
  main:has(.usage-export-panel) > .min-h-0.overflow-hidden {
    overflow-y: auto; overscroll-behavior-y: contain;
  }
  main:has(.usage-export-panel) .h-full:has(.usage-export-panel) { height: auto; }
  main:has(.usage-export-panel) .h-full:has(.usage-export-panel) > .min-h-0.flex-1 {
    flex: 0 0 auto;
  }
  main:has(.usage-export-panel) .min-h-0.flex-1.overflow-y-auto {
    flex: 0 0 auto; overflow-y: visible;
  }
}
