/* TheaCRM v2.8.437 – unified UI layers / overlay manager
   Jeden systém vrstev pro horní lištu, dropdowny, globální hledání, modály
   a mobilní spodní navigaci. Neřeší se lokálními z-index hotfixy v modulech. */
:root{
  /* Global layer contract. Components may consume these tokens, but must not invent
     competing page-level z-index scales. */
  --thea-z-content:1;
  --thea-z-sticky:900;
  --thea-z-header:1100;
  --thea-z-sidebar:1150;
  --thea-z-bottom-nav:1200;
  --thea-z-quick-add:1250;
  --thea-z-dropdown:1600;
  --thea-z-popover:1700;
  --thea-z-status:1800;
  --thea-z-app-backdrop:2000;
  --thea-z-app-dialog:2010;
  --thea-z-modal-backdrop:3000;
  --thea-z-modal:3010;
  --thea-z-modal-step:20;
  --thea-z-custom-dialog:4000;
  --thea-z-blocking-overlay:5000;
  --thea-z-toast:6000;
  --thea-z-accessibility:7000;
  --thea-z-critical:var(--thea-z-toast);
  --thea-visible-viewport-height:100dvh;
  --thea-visible-viewport-top:0px;
  --thea-measured-bottom-nav-height:0px;
}

/* Základní pořadí vrstev. */
.header{z-index:var(--thea-z-header) !important;}
.sidebar{z-index:var(--thea-z-sidebar) !important;}
.sidebar-overlay{z-index:calc(var(--thea-z-sidebar) - 10) !important;}
.thea-mobile-bottom-nav{z-index:var(--thea-z-bottom-nav) !important;}
.thea-mobile-quick-add-backdrop{z-index:calc(var(--thea-z-quick-add) - 10) !important;}
.thea-mobile-quick-add{z-index:var(--thea-z-quick-add) !important;}
.flash-pill-overlay{z-index:var(--thea-z-critical) !important;}

/* Sticky hlavičky modulů nesmí přelézat přes globální overlaye. */
.sticky-top,
.email-toolbar,
.filter-bar,
.thea-sticky-actions,
.thea-toolbar-sticky,
.thea-mobile-sticky-actions,
body.thea-email-ui-page .email-toolbar,
body.thea-email-ui-page #toolbar-default,
body.thea-email-ui-page .email-action-more,
body.thea-email-ui-page .email-triage-dropdown,
body.thea-email-ui-page .pager-bar .dropdown{
  z-index:var(--thea-z-sticky) !important;
}

/* Bootstrap dropdowny a e-mailová menu jsou popover vrstva: nad obsahem/spodní lištou,
   ale pod skutečným modalem typu globální hledání. */
.dropdown-menu,
.dropdown-menu.show,
.email-action-more-menu,
.email-action-more-menu.show,
.email-triage-menu,
.email-triage-menu.show,
body.thea-email-ui-page .email-toolbar .dropdown-menu,
body.thea-email-ui-page .email-toolbar .dropdown-menu.show,
body.thea-email-ui-page .email-action-more-menu,
body.thea-email-ui-page .email-action-more-menu.show,
body.thea-email-ui-page .email-triage-menu,
body.thea-email-ui-page .email-triage-menu.show,
body.thea-email-ui-page .pager-bar .dropdown-menu,
body.thea-email-ui-page .pager-bar .dropdown-menu.show{
  z-index:var(--thea-z-popover) !important;
}

/* Anchored layers stay in their original DOM scope. Position:fixed escapes the
   content/card overflow contract while preserving Bootstrap keyboard handling,
   modal focus traps and the stacking context of the owning (possibly stacked) modal. */
.thea-anchored-layer{
  position:fixed !important;
  transform:none !important;
  margin:0 !important;
  z-index:var(--thea-z-popover) !important;
  overflow-x:hidden;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
}
.thea-anchored-layer[data-thea-placement="top"]{transform-origin:bottom center;}
.thea-anchored-layer[data-thea-placement="bottom"]{transform-origin:top center;}

/* A modal is its own managed stacking context. The menu remains its descendant,
   so lower-modal menus cannot cross above the next modal/backdrop pair. */
.modal.thea-modal-layer-managed .thea-anchored-layer,
.modal.show .thea-anchored-layer{
  z-index:var(--thea-z-popover) !important;
}

.dropdown,
.dropup,
.dropend,
.dropstart,
.email-toolbar,
#toolbar-default,
.email-action-more,
.email-triage-dropdown,
.pager-bar .dropdown{
  overflow:visible !important;
}

/* Horní dropdowny: zvonek a obálka. */
#notificationDropdown.thea-top-dropdown,
#mailDropdown.thea-top-dropdown,
.thea-top-dropdown{
  z-index:var(--thea-z-dropdown) !important;
  max-height:calc(var(--thea-visible-viewport-height, 100dvh) - var(--navbar-height,64px) - var(--thea-measured-bottom-nav-height,0px) - 24px) !important;
  overflow:hidden !important;
}
#notificationDropdown.thea-top-dropdown ul,
#mailDropdown.thea-top-dropdown ul,
.thea-top-dropdown ul{
  max-height:calc(var(--thea-visible-viewport-height, 100dvh) - var(--navbar-height,64px) - var(--thea-measured-bottom-nav-height,0px) - 122px) !important;
  overflow-y:auto !important;
  overscroll-behavior:contain;
}

/* Globální hledání je modal. Musí být nad e-mailovou lištou, dropdowny i spodní lištou. */
.thea-global-search-backdrop{
  z-index:var(--thea-z-app-backdrop) !important;
}
.thea-global-search-modal{
  z-index:var(--thea-z-app-dialog) !important;
  height:var(--thea-visible-viewport-height,100dvh) !important;
  top:var(--thea-visible-viewport-top,0px) !important;
  bottom:auto !important;
}
body.thea-global-search-open .thea-mobile-bottom-nav,
body.thea-global-search-open .thea-mobile-quick-add,
body.thea-global-search-open .thea-mobile-quick-add-backdrop,
body.thea-global-search-open #notificationDropdown,
body.thea-global-search-open #mailDropdown{
  display:none !important;
}
body.thea-global-search-open .email-toolbar,
body.thea-global-search-open .filter-bar,
body.thea-global-search-open .sticky-top{
  z-index:0 !important;
}

/* Bootstrap modal stack is finalized by thea-modal-layers.js. These declarations
   are non-important fallbacks, so the manager's inline pair ordering always wins. */
.modal-backdrop{z-index:var(--thea-z-modal-backdrop);}
.modal{z-index:var(--thea-z-modal);}
.offcanvas-backdrop{z-index:var(--thea-z-modal-backdrop) !important;}
.offcanvas{z-index:var(--thea-z-modal) !important;}

@media (max-width:767.98px){
  .thea-global-search-modal{
    inset:auto 0 auto 0 !important;
    height:var(--thea-visible-viewport-height,100dvh) !important;
    padding:calc(env(safe-area-inset-top,0px) + 8px) 8px calc(12px + env(safe-area-inset-bottom,0px)) !important;
    align-items:stretch !important;
  }
  .thea-global-search-dialog{
    max-height:calc(var(--thea-visible-viewport-height,100dvh) - 20px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px)) !important;
  }
  .thea-global-search-results{
    max-height:none !important;
    min-height:0;
  }
  .thea-layer-dropdown-menu,
  .dropdown-menu.show{
    max-width:calc(100vw - 18px) !important;
    overscroll-behavior:contain;
  }
  .thea-top-dropdown{
    width:min(420px, calc(100vw - 18px)) !important;
  }
}

/* TheaCRM v2.8.505 – mobile quick-add stacking context
   Keep the backdrop below the bottom nav when the quick-add panel is open. */
@media (max-width: 767.98px){
  .thea-mobile-bottom-nav.is-quick-add-open{
    z-index: calc(var(--thea-z-quick-add, 1250) + 20) !important;
  }
  .thea-mobile-bottom-nav.is-quick-add-open .thea-mobile-quick-add{
    z-index: calc(var(--thea-z-quick-add, 1250) + 30) !important;
  }
  .thea-mobile-quick-add-backdrop:not([hidden]){
    z-index: calc(var(--thea-z-quick-add, 1250) + 5) !important;
  }
}
