/* Visits dashboard responsive maintenance — 2026-10-17
   Override contradictory historical rules without changing application data. */

/* Layout safety shared by the admin, representative and customer map pages. */
html { -webkit-text-size-adjust:100%; }
body.dashboardBody { overflow-x:clip !important; }
body.dashboardBody .dashboardContentWrap,
body.dashboardBody .dashboardMain,
body.dashboardBody .dashboardInner,
body.dashboardBody .tabPanel,
body.dashboardBody .card,
body.dashboardBody .reportLayout,
body.dashboardBody .trackingLayout,
body.dashboardBody .homePanel,
body.dashboardBody .reportResult,
body.dashboardBody .repLeft,
body.dashboardBody .repRight { min-width:0; max-width:100%; }
body.dashboardBody input,
body.dashboardBody select,
body.dashboardBody textarea { max-width:100%; }
body.dashboardBody .dashboardSidebar { scrollbar-width:thin; scrollbar-color:rgba(255,255,255,.3) transparent; }
body.dashboardBody .sidebarBrandText,
body.dashboardBody .sidebarProfile > div:last-child { overflow-wrap:anywhere; }
body.dashboardBody .sidebarMenu .navPill,
body.dashboardBody .sidebarFooterActions .sideActionBtn { position:relative; text-align:start !important; }
body.dashboardBody .sidebarMenu .navPill span,
body.dashboardBody .sidebarFooterActions .sideActionBtn span { flex:1 1 auto; min-width:0; }
body.dashboardBody .sidebarMenu .navPill i,
body.dashboardBody .sidebarFooterActions .sideActionBtn i { flex:0 0 34px; }
body.dashboardBody .sidebarMenu .navPill.active::after {
  content:""; position:absolute; inset-block:12px; inset-inline-start:0;
  width:3px; border-radius:6px; background:#eda21a;
}
body.dashboardBody .sidebarMenu .navPill:focus-visible,
body.dashboardBody .sidebarFooterActions button:focus-visible,
body.dashboardBody .iconTopBtn:focus-visible {
  outline:3px solid #eda21a !important; outline-offset:2px;
}
.sidebarSectionTitle { color:rgba(255,255,255,.56); font-size:11px; font-weight:800;
  letter-spacing:.5px; padding:0 12px; margin-block:2px -4px; }
.sidebarFooterHeading { margin-top:auto; }
body.dashboardBody .sidebarFooterHeading + .sidebarFooterActions { margin-top:0 !important; }
.sidebarCloseBtn { display:none; }

/* Modern compact sidebar; retain icons in collapsed mode (older CSS hid avatar). */
@media (min-width:1101px){
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.sidebarCollapsed .sidebarBrandLogo {
    flex:0 0 54px !important; width:54px !important; min-width:54px !important;
    max-width:54px !important; height:54px !important; padding:5px !important;
  }
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.sidebarCollapsed .sidebarBrandLogo img {
    width:42px !important; height:42px !important; max-width:42px !important;
  }
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.sidebarCollapsed .sidebarAvatar {display:grid !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.sidebarCollapsed .sidebarProfile {padding:9px !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.sidebarCollapsed .sidebarMenu .navPill,
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.sidebarCollapsed .sidebarFooterActions .sideActionBtn {
    justify-content:center !important; padding:8px 4px !important; min-height:50px !important;
  }
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.sidebarCollapsed .sidebarMenu .navPill i,
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.sidebarCollapsed .sidebarFooterActions .sideActionBtn i {flex:0 0 34px !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.sidebarCollapsed .sidebarSectionTitle {display:none;}
}

/* Admin: single breakpoint and true off-canvas sidebar on phones/tablets. */
@media (max-width:1100px){
  html body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.dashboardShell,
  html body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.dashboardShell.sidebarOpen {
    display:block !important; width:100% !important; max-width:100% !important;
    grid-template-columns:none !important; min-height:100dvh !important;
  }
  html body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .dashboardContentWrap,
  html body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.sidebarOpen .dashboardContentWrap {
    display:block !important; width:100% !important; max-width:100% !important;
    grid-column:auto !important; order:0 !important;
  }
  html body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .dashboardSidebar,
  html body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.sidebarOpen .dashboardSidebar {
    display:flex !important; position:fixed !important;
    top:0 !important; bottom:0 !important; inset-block:0 !important;
    flex-direction:column !important; width:min(320px,88vw) !important;
    max-width:88vw !important; min-width:0 !important;
    height:100vh !important; height:100dvh !important; max-height:100dvh !important;
    overflow-y:auto !important; overflow-x:hidden !important;
    padding:18px 12px calc(22px + env(safe-area-inset-bottom)) !important;
    z-index:1601 !important; grid-column:auto !important; order:0 !important;
    border-radius:0 !important; box-shadow:0 15px 50px rgba(3,20,30,.36) !important;
    transition:transform .22s ease !important;
  }
  html[dir="rtl"] body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .dashboardSidebar {
    right:0 !important; left:auto !important; transform:translateX(105%) !important;
  }
  html[dir="ltr"] body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .dashboardSidebar {
    left:0 !important; right:auto !important; transform:translateX(-105%) !important;
  }
  html[dir] body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.sidebarOpen .dashboardSidebar {
    transform:translateX(0) !important;
  }
  html body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .dashboardOverlay {
    display:none !important; position:fixed !important; inset:0 !important;
    z-index:1600 !important; background:rgba(3,18,28,.55) !important;
    backdrop-filter:blur(2px); cursor:pointer;
  }
  html body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.sidebarOpen .dashboardOverlay {display:block !important;}
  body.visitsMenuOpen {overflow:hidden !important; touch-action:pan-y;}
  body.dashboardBody .sidebarCloseBtn {
    display:grid !important; place-items:center; position:absolute; inset-inline-end:7px; top:8px;
    width:34px; height:34px; color:#fff; background:rgba(255,255,255,.14);
    border:1px solid rgba(255,255,255,.25); border-radius:11px;
    z-index:1; cursor:pointer;
  }
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) .sidebarBrand {position:relative; padding-inline-end:38px !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .dashboardMain.container.wide {padding:12px !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .dashboardTopbar {gap:8px !important; padding:10px 13px !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .dashboardInner.card {padding:0 !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) .adminQuickStats {grid-template-columns:repeat(2,minmax(0,1fr)) !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) .homeDashboardGrid,
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) .reportLayout,
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) .trackingLayout {display:grid !important;grid-template-columns:minmax(0,1fr) !important;gap:12px !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .sidebarFooterActions {position:static !important;}
}

@media (max-width:700px){
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .dashboardTopbar {
    min-height:60px !important; flex-wrap:nowrap !important;
  }
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .topbarRightCluster {
    display:flex !important; flex-wrap:nowrap !important; align-items:center !important; width:100% !important;
    justify-content:space-between !important; gap:8px !important;
  }
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .topbarPageInfoWrap {
    display:flex !important; flex:1 1 auto !important; flex-wrap:nowrap !important; width:auto !important;
    gap:8px !important; min-width:0 !important; justify-content:flex-start !important;
  }
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .topbarPageInfo {
    min-width:0 !important; flex:1; overflow:hidden;
  }
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .topbarPageInfo strong {
    display:block; font-size:14px !important; overflow:hidden; white-space:nowrap; text-overflow:ellipsis;
  }
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .topbarPageInfo span {display:none;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .langSwitchBtn {
    flex:0 0 auto !important; min-width:85px !important; width:auto !important; max-width:98px !important;
    font-size:11px !important; padding:0 6px !important;
  }
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .iconTopBtn {flex:0 0 40px !important; width:40px !important; height:40px !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .dashboardMain.container.wide {padding:9px !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .card {padding:11px !important;border-radius:15px !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .statCard {padding:12px !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .statCard .value {font-size:clamp(18px,5vw,24px) !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell #reportsTab .row .btn,
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell #trackingTab .row .btn,
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell #reportsTab .row button,
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell #trackingTab .row button {
    width:auto !important; flex:1 1 calc(50% - 6px) !important; min-width:0 !important;
    min-height:42px !important; font-size:12px !important; padding:8px !important;
  }
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell #customDateRangeRow,
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell #trackingCustomDateRangeRow {
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  }
}
@media (max-width:390px){
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .dashboardMain.container.wide {padding:7px !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .dashboardTopbar {padding:8px !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .topbarPageInfo strong {font-size:13px !important;}
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .langSwitchBtn {min-width:80px !important;}
}
/* Consistent two-column KPI layout on narrow screens, even below 420px. */
@media (max-width:420px){
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .adminQuickStats {grid-template-columns:repeat(2,minmax(0,1fr)) !important;}
}

/* Scroll WIDE tables inside their own wrapper; do not crush report text. */
body.dashboardBody .tableWrap,
body.dashboardBody .tableWrap.fit,
body.dashboardBody .tableWrap.reportFit {
  display:block; max-width:100% !important; min-width:0 !important;
  overflow-x:auto !important; overscroll-behavior-x:contain;
  -webkit-overflow-scrolling:touch;
}
body.dashboardBody:not(.customerMapPage) #homeTab .summaryTable {width:100% !important; min-width:550px !important;}
body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #reportResult .reportTable {min-width:1010px !important;}
body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #reportSummary .reportTable {min-width:650px !important;}
body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #trackingReportResult .reportTable {min-width:740px !important;}
body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) .reportTable th,
body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) .reportTable td {
  word-break:normal !important; overflow-wrap:normal !important; font-size:12px;
}
/* Tables generated without an explicit scroll wrapper get an overflow viewport at the card level. */
body.dashboardBody .tableWrap::-webkit-scrollbar{height:8px;}
body.dashboardBody .tableWrap::-webkit-scrollbar-thumb{background:#92a9b2;border-radius:9px;}

/* Dialogs remain usable when on-screen keyboard is visible / landscape. */
body.dashboardBody .drawer {
  max-width:calc(100vw - 18px) !important;
  width:min(620px,calc(100vw - 18px)) !important;
  max-height:calc(100dvh - 20px) !important;
}
body.dashboardBody .drawerBody {min-height:0;overflow-y:auto !important;overscroll-behavior:contain;}
body.dashboardBody .drawerFooter {flex:0 0 auto;}
@media (max-width:600px){
  body.dashboardBody .drawer {border-radius:15px !important;}
  body.dashboardBody .drawerHeader {padding:10px 12px !important;}
  body.dashboardBody .drawerBody {padding:12px !important;}
  body.dashboardBody .drawerFooter {padding:10px !important;gap:8px !important;}
  body.dashboardBody .drawerFooter .btn {min-height:42px;flex:1 1 auto;justify-content:center;}
  body.dashboardBody .daysGrid {grid-template-columns:repeat(2,minmax(0,1fr));}
  body.dashboardBody input,body.dashboardBody select,body.dashboardBody textarea {font-size:16px !important;}
  /* Representative: controls and details never render outside the viewport. */
  body.repDashboardPage .repLayout {display:flex !important;flex-direction:column !important;gap:10px !important;}
  body.repDashboardPage .repLeft,body.repDashboardPage .repRight {width:100% !important; min-width:0 !important;}
  body.repDashboardPage #clientsWrap {width:100% !important;min-width:0 !important;}
  body.repDashboardPage .repSearchRow {min-width:0 !important;max-width:100% !important;}
  body.repDashboardPage #searchBox {min-width:0 !important;max-width:100% !important;}
  body.repDashboardPage .detailGrid,body.repDashboardPage .visitFocusGrid {grid-template-columns:minmax(0,1fr) !important;}
  body.repDashboardPage .visitActionRow .btn,
  body.repDashboardPage .visitActionBar .btn {flex:1 1 auto !important;width:auto !important;}
}

/* Map: bring filters and results above the map in a clean single column on tablets. */
@media (max-width:1100px){
  body.customerMapPage .customerMapLayout {display:grid !important;grid-template-columns:minmax(0,1fr) !important;gap:12px !important;}
  body.customerMapPage .mapControlsPanel {width:100% !important;min-width:0 !important;}
  body.customerMapPage .mapCanvasCard {width:100% !important;min-width:0 !important;overflow:hidden !important;}
  body.customerMapPage .tableWrap.mapTable {overflow-x:auto !important;}
}
@media (max-width:700px){
  body.customerMapPage .customerMapLayout {display:flex !important;flex-direction:column !important;}
  body.customerMapPage .mapCanvasCard {height:60dvh !important;min-height:340px !important;flex:0 0 auto;}
  body.customerMapPage #map {height:100% !important;min-height:340px !important;}
  body.customerMapPage .mapGrid2 {grid-template-columns:repeat(2,minmax(0,1fr)) !important;}
  body.customerMapPage .mapGrid3 {grid-template-columns:minmax(0,1fr) !important;}
  body.customerMapPage .mapStatusBar {inset-inline:8px;top:8px;}
  body.customerMapPage .mapStatusBar .badge {font-size:11px;}
}
@media (prefers-reduced-motion:reduce){
  body.dashboardBody .dashboardSidebar {transition:none !important;}
}

/* RTL grid correction: CSS grid columns follow writing direction, so the first
   grid column is on the RIGHT in Arabic. Earlier rules reversed the sidebar. */
@media (min-width:1101px){
  html[dir="rtl"] body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.dashboardShell {
    grid-template-columns:320px minmax(0,1fr) !important;
  }
  html[dir="rtl"] body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.dashboardShell.sidebarCollapsed {
    grid-template-columns:96px minmax(0,1fr) !important;
  }
  html[dir="rtl"] body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell > .dashboardSidebar {
    grid-column:1 !important;
  }
  html[dir="rtl"] body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell > .dashboardContentWrap {
    grid-column:2 !important;
  }
  html[dir="rtl"] body.customerMapPage #pageShell.dashboardShell:not(.sidebarClosed) {
    grid-template-columns:320px minmax(0,1fr) !important;
  }
  html[dir="rtl"] body.customerMapPage #pageShell > .dashboardSidebar {grid-column:1 !important;}
  html[dir="rtl"] body.customerMapPage #pageShell > .dashboardContentWrap {grid-column:2 !important;}
}
@media (max-width:1100px){
  html[dir="rtl"] body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.dashboardShell.sidebarOpen #dashboardSidebar.dashboardSidebar,
  html[dir="ltr"] body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell.dashboardShell.sidebarOpen #dashboardSidebar.dashboardSidebar {
    transform:translateX(0) !important;
  }
}

/* The earlier light-colored sticky footer became unreadable over the dark sidebar. */
body.dashboardBody .dashboardSidebar .sidebarFooterActions {
  background:transparent !important;
  backdrop-filter:none !important;
  box-shadow:none !important;
  min-height:0 !important;
}
@media (max-width:1100px){
  body.dashboardBody:not(.repDashboardPage):not(.customerMapPage) #dashboardShell .sidebarFooterHeading {
    margin-top:10px !important;
  }
}
@media print {
  body.dashboardBody .tableWrap,
  body.dashboardBody .tableWrap.fit,
  body.dashboardBody .tableWrap.reportFit {
    overflow:visible !important;
    max-width:100% !important;
  }
  body.dashboardBody .drawerBackdrop {display:none !important;}
}
