/* Shared account navigation, including the signed-out preview of personal features. */

/* Keep account identity and sign-out visible; only the links in between scroll. */
:is(.topbar.app-topbar, .admin-modern) #userMenuPanel {
  --account-menu-paper: #f2f4fb;
  --account-menu-glow: rgb(111 89 226 / 6%);
  --account-menu-glow-height: 480px;
  --account-menu-muted: #58657b;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: min(calc(100dvh - 76px), var(--account-menu-available-height, calc(100dvh - 88px)));
  overflow: hidden;
  background-color: var(--account-menu-paper);
  background-image: radial-gradient(ellipse at 100% 0%, var(--account-menu-glow), transparent 70%);
  background-position: center top;
  background-size: 100% var(--account-menu-glow-height);
  background-repeat: no-repeat;
}

/* Pointer and keyboard feedback share a lighter fill than the current page. */
:is(.topbar.app-topbar, .admin-modern) #userMenuPanel .menu-item {
  transition: background-color .12s ease, color .12s ease;
}

:is(.topbar.app-topbar, .admin-modern) #userMenuPanel .menu-item:is(:hover, :focus-visible) {
  background: #e8eaff;
  color: var(--outlo-brand-text, #4338ca);
}

:is(.topbar.app-topbar, .admin-modern) #userMenuPanel .menu-item:is(:hover, :focus-visible) .nav-icon {
  color: inherit;
}

/* Keep the current page distinct from the lighter hover state. */
:is(.topbar.app-topbar, .admin-modern) #userMenuPanel .menu-item:is(.active, [aria-current="page"]) {
  background: #e0e4ff;
  color: var(--outlo-brand-text, #4338ca);
  box-shadow: inset 3px 0 var(--outlo-brand-accent, #4f46e5);
  font-weight: 700;
}

/* Restored keyboard focus stays inside the scrollable row on every page. */
:is(.topbar.app-topbar, .admin-modern) #userMenuPanel .menu-item:focus-visible {
  outline: 2px solid var(--outlo-brand-accent, #4f46e5);
  outline-offset: -2px;
}

@media (forced-colors: active) {
  :is(.topbar.app-topbar, .admin-modern) #userMenuPanel .menu-item:is(.active, [aria-current="page"]) {
    background: Highlight;
    color: HighlightText;
  }
}

#userMenuPanel :is(.user-menu-identity-copy small, .user-menu-section-label) {
  color: var(--account-menu-muted);
}

@media (max-width: 1120px) {
  :is(.topbar.app-topbar, .admin-modern) #userMenuPanel {
    --account-menu-glow: rgb(111 89 226 / 5%);
    --account-menu-glow-height: 440px;
  }
}

@media (forced-colors: active) {
  :is(.topbar.app-topbar, .admin-modern) #userMenuPanel {
    --account-menu-paper: Canvas;
    --account-menu-muted: CanvasText;
    background: Canvas;
  }
}

#userMenuPanel > .user-menu-identity,
#userMenuPanel > .user-menu-footer { flex: 0 0 auto; }

#userMenuScrollFrame {
  position: relative;
  display: flex;
  flex: 0 1 auto;
  min-height: 0;
  overflow: hidden;
}

#userMenuScroll {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  gap: 2px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  scrollbar-color: #c7cede transparent;
}

#userMenuScroll > * { flex-shrink: 0; }
/* Group boxes and titles are used by the mobile/tablet drawer. */
#userMenuScroll > .user-menu-group { display: contents; }
#userMenuScroll .user-menu-group > * { flex-shrink: 0; }
#userMenuScroll .user-menu-group-title { display: none; }

#userMenuScroll::-webkit-scrollbar { width: 5px; }
#userMenuScroll::-webkit-scrollbar-track { background: transparent; }
#userMenuScroll::-webkit-scrollbar-thumb { border-radius: 8px; background: #c7cede; }

#userMenuScrollFrame::before {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0 0 auto;
  height: 12px;
  background: linear-gradient(var(--account-menu-paper), transparent);
  opacity: 0;
  pointer-events: none;
}

#userMenuScrollFrame[data-scroll-before="true"]::before { opacity: 1; }

/* Blend the clipped row into the menu surface before the continuation action. */
#userMenuScrollFrame::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: auto 0 0;
  height: 72px;
  background: linear-gradient(to bottom, transparent, var(--account-menu-paper) 40%, var(--account-menu-paper));
  opacity: 0;
  pointer-events: none;
}

#userMenuScrollFrame[data-scroll-after="true"]::after { opacity: 1; }

#userMenuPanel #userMenuScrollHint {
  position: absolute;
  z-index: 3;
  inset: auto 0 0;
  display: none;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 44px;
  min-height: 44px;
  padding: 14px 8px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--outlo-brand-text, #4338ca);
  box-shadow: none;
  transform: none;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  cursor: pointer;
  touch-action: pan-y;
}

#userMenuPanel #userMenuScrollHint:is(:hover, :focus-visible) {
  color: var(--outlo-brand-text-hover, #3730a3);
  text-decoration: underline;
  text-underline-offset: 3px;
}

#userMenuPanel #userMenuScrollHint:focus-visible {
  outline: 2px solid var(--outlo-brand-accent, #4f46e5);
  outline-offset: -2px;
  border-radius: 6px;
}

#userMenuScrollHint svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#userMenuScrollFrame[data-scroll-after="true"] #userMenuScrollHint:not([hidden]) { display: flex; }

@media (forced-colors: active) {
  #userMenuScrollFrame::after { background: Canvas; }
  #userMenuPanel #userMenuScrollHint { color: LinkText; }
}

#userMenuPanel > .user-menu-footer {
  padding-top: 6px;
  margin-top: 4px;
  border-top: 1px solid #e3e9ef;
  background: transparent;
}

#userMenu.is-guest .user-menu-footer { display: none; }
#userMenuPanel .user-menu-footer #menuLogoutButton { margin-top: 0; }
#userMenuPanel .user-menu-footer #menuLogoutButton::before { content: none; }

/* Keep the disclosure arrow visible, including controls moved into workspace headers. */
#userMenu #userMenuButton > .nav-chevron {
  display: block !important;
  width: var(--outlo-icon-xs, 14px);
  height: var(--outlo-icon-xs, 14px);
  flex: 0 0 var(--outlo-icon-xs, 14px);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  transition: transform .16s ease;
}
#userMenu #userMenuButton[aria-expanded="true"] > .nav-chevron { transform: rotate(180deg); }
#userMenu #userMenuButton { position: relative; overflow: visible; }
@media (max-width: 1280px) {
  .topbar.app-topbar.is-public-page #userMenu #userMenuButton > .nav-chevron {
    position: absolute;
    z-index: 2;
    right: -2px;
    bottom: -2px;
    width: 19px !important;
    height: 19px !important;
    box-sizing: border-box;
    padding: 2px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--outlo-brand-soft, #eef2ff);
    color: var(--outlo-brand-accent, #4f46e5);
    stroke-width: 2.5;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .16);
  }
}
@media (max-width: 1120px) {
  .map-page .topbar.app-topbar #userMenu #userMenuButton > .nav-chevron {
    position: absolute;
    z-index: 2;
    right: -2px;
    bottom: -2px;
    width: 19px !important;
    height: 19px !important;
    box-sizing: border-box;
    padding: 2px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--outlo-brand-soft, #eef2ff);
    color: var(--outlo-brand-accent, #4f46e5);
    stroke-width: 2.5;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .16);
  }
}
@media (max-width: 1050px) {
  body:not(.map-page) .topbar.app-topbar #userMenu #userMenuButton > .nav-chevron {
    position: absolute;
    z-index: 2;
    right: -2px;
    bottom: -2px;
    width: 19px !important;
    height: 19px !important;
    box-sizing: border-box;
    padding: 2px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--outlo-brand-soft, #eef2ff);
    color: var(--outlo-brand-accent, #4f46e5);
    stroke-width: 2.5;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .16);
  }
}
@media (max-width: 760px) {
  .admin-modern #userMenu #userMenuButton > .nav-chevron {
    position: absolute;
    z-index: 2;
    right: -2px;
    bottom: -2px;
    width: 19px !important;
    height: 19px !important;
    box-sizing: border-box;
    padding: 2px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--outlo-brand-soft, #eef2ff);
    color: var(--outlo-brand-accent, #4f46e5);
    stroke-width: 2.5;
    box-shadow: 0 1px 4px rgba(15, 23, 42, .16);
  }
}
@media (prefers-reduced-motion: reduce) {
  #userMenu #userMenuButton > .nav-chevron { transition: none; }
}

/* Keep navigation labels calm without changing avatar initials or count badges. */
.topbar.app-topbar #allEventsLink,
.topbar.app-topbar #allEventsLink > span,
:is(.topbar.app-topbar, .admin-modern) #userMenuButton,
:is(.topbar.app-topbar, .admin-modern) #userMenuName {
  font-weight: 500;
}

/* Shared geometry; the role-aware primary action keeps the filled-action colors. */
.topbar.app-topbar :is(#allEventsLink, #userMenuButton) {
  height: 42px !important;
  min-height: 42px !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: var(--outlo-control-radius, 12px) !important;
  transform: none !important;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.topbar.app-topbar #userMenuButton {
  background: #fff !important;
  color: #334155;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06) !important;
}

.topbar.app-topbar #allEventsLink {
  align-self: center;
  flex: 0 0 auto;
  gap: 8px;
  margin: 0;
  padding-inline: 12px;
  white-space: nowrap;
}

.topbar.app-topbar #userMenuButton:is(:hover, [aria-expanded="true"]) {
  border-color: #cbd5e1 !important;
  background: #f8fafc !important;
  color: #334155;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .06) !important;
}

.topbar.app-topbar :is(#allEventsLink, #userMenuButton):focus-visible {
  outline: 2px solid var(--outlo-brand-accent, #4f46e5) !important;
  outline-offset: 3px;
}

.topbar.app-topbar #allEventsLink:focus-visible {
  outline-color: var(--outlo-control-focus, #a5b4fc) !important;
}

.topbar.app-topbar #allEventsLink > span {
  max-width: none;
  overflow: visible;
}

.topbar.app-topbar #allEventsLink .nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  box-shadow: none;
  stroke-width: 1.8;
}

.topbar.app-topbar #allEventsLink .nav-icon path { stroke-width: 1.8; }

#userMenu.is-guest #userMenuAvatar,
:is(#userMenuPanel,#accountMobileSheet) .guest-account-avatar {
  display: inline-grid;
  place-items: center;
  background: var(--outlo-brand-soft, #eef2ff);
  color: var(--outlo-brand-accent, #4f46e5);
}

#userMenu.is-guest #userMenuAvatar > svg,
:is(#userMenuPanel,#accountMobileSheet) .guest-account-avatar > svg {
  width: var(--outlo-icon-lg, 20px);
  height: var(--outlo-icon-lg, 20px);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:is(.topbar.app-topbar, .admin-modern) #userMenu .user-menu-identity[hidden] {
  display: none !important;
}

/* Compact guest account strip: native links share one row. */
:is(.topbar.app-topbar, .admin-modern) #userMenuPanel #guestAccountActions.user-menu-guest {
  display: grid;
  grid-template-columns: minmax(0, 3fr) 1px minmax(0, 2fr);
  align-items: center;
  gap: 0;
  padding: 0;
  margin-bottom: 0;
}

:is(#userMenuPanel,#accountMobileSheet) .guest-account-login,
:is(#userMenuPanel,#accountMobileSheet) .guest-account-register {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  gap: 7px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 40px;
  min-height: 40px;
  padding: 8px 4px;
  border-radius: 6px;
  background: transparent;
  color: #222b43;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  text-decoration: none;
}

:is(#userMenuPanel,#accountMobileSheet) .guest-account-login {
  display: grid;
  /* Equal outer tracks keep the label centered while the icon sits before it. */
  grid-template-columns: 18px max-content 18px;
  color: var(--outlo-brand-text, #5145cd);
  font-size: 14px;
  font-weight: 600;
}

:is(#userMenuPanel,#accountMobileSheet) .guest-account-login > .guest-account-login-icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:is(#userMenuPanel,#accountMobileSheet) .guest-account-divider {
  width: 1px;
  height: 20px;
  background: #dfe4f1;
}

:is(#userMenuPanel,#accountMobileSheet) .user-menu-guest a:is(:hover, :focus-visible) {
  background: linear-gradient(90deg, transparent, rgb(232 234 255 / 50%) 24%, rgb(232 234 255 / 50%) 76%, transparent);
  color: var(--outlo-brand-text, #4338ca);
  text-decoration: none;
}
:is(#userMenuPanel,#accountMobileSheet) .user-menu-guest a:focus-visible { outline: 2px solid var(--outlo-brand-accent, #4f46e5); outline-offset: -2px; }

@media (forced-colors: active) {
  :is(#userMenuPanel,#accountMobileSheet) .guest-account-divider { background: CanvasText; }
}

#userMenu.is-guest #menuNotifications:not([hidden]) { display: grid !important; }

:is(.topbar.app-topbar, .admin-modern) #userMenuPanel .menu-item.requires-login {
  grid-template-columns: 18px minmax(0, 1fr) 14px;
}

#userMenuPanel .menu-lock {
  justify-self: end;
  width: 13px;
  height: 13px;
  color: #94a3b8;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The menu add action stays independent of the primary header shortcut. */
:is(.topbar.app-topbar, .admin-modern) #userMenuPanel #newEventButton.menu-add-event:not([hidden]) {
  display: grid !important;
  grid-template-columns: 18px minmax(0, 1fr);
  align-self: stretch;
  align-items: center;
  width: 100%;
  height: auto !important;
  min-height: 40px !important;
  gap: 0 12px !important;
  margin: 0;
  padding: 9px 10px !important;
  border: 0;
  border-radius: 6px !important;
  background: transparent;
  color: var(--outlo-brand-text, #4338ca);
  box-shadow: none;
  font-size: 13px !important;
  font-weight: 600;
  line-height: 20px;
}

:is(.topbar.app-topbar, .admin-modern) #userMenuPanel #newEventButton.workspace-last {
  margin-bottom: 8px;
}

:is(.topbar.app-topbar, .admin-modern) #userMenuPanel #newEventButton.menu-add-event:is(:hover, :focus-visible) {
  background: #e8eaff;
  color: var(--outlo-brand-text, #4338ca);
}

:is(.topbar.app-topbar, .admin-modern) #userMenuPanel #newEventButton.menu-add-event .nav-icon {
  width: 18px !important;
  min-width: 18px !important;
  height: 18px !important;
  flex: 0 0 18px !important;
  padding: 0 !important;
  border-radius: 0 !important;
  background: transparent;
  color: inherit;
  box-shadow: none;
  stroke-width: 1.8;
}

:is(.topbar.app-topbar, .admin-modern) #userMenuPanel #newEventButton > .menu-add-event-copy {
  display: grid;
  gap: 2px;
  max-width: none;
  overflow: visible;
  font-size: 13px !important;
  white-space: normal;
}

:is(.topbar.app-topbar, .admin-modern) #userMenuPanel #newEventButton > .menu-add-event-copy::after {
  content: none !important;
}

#userMenuPanel .menu-add-event-copy > span { max-width: none; }

#userMenuPanel #menuAddEventHint {
  color: var(--account-menu-muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.45;
}

#accountAccessDialog.account-access-dialog {
  width: min(420px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid #e3e9ef;
  border-radius: 18px;
  background: #fff;
  color: #172536;
}

#accountAccessDialog .dialog-head { display: grid; grid-template-columns: 52px minmax(0, 1fr) 36px; align-items: center; gap: 14px; padding: 20px 20px 10px; }
#accountAccessDialog .dialog-head h2 { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.3; }
#accountAccessDialog .dialog-head .icon-button { flex: 0 0 36px; width: 36px; height: 36px; min-height: 36px; }
#accountAccessDialog #accountAccessText { margin: 0; padding: 0 20px 20px; color: #64748b; font-size: 14px; font-weight: 400; line-height: 1.6; }
#accountAccessDialog .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 16px 20px 20px; }
#accountAccessDialog .dialog-actions > a { min-height: 44px; font-size: 13px; font-weight: 600; }

@media (max-width: 900px) {
  .topbar.app-topbar #allEventsLink { min-height: 42px; height: 42px; padding: 6px 10px; gap: 6px; font-size: 13px; }
  .topbar.app-topbar #allEventsLink > span { font-size: 0; }
  .topbar.app-topbar #allEventsLink > span::after { content: "Akce"; font-size: 13px; }
  .topbar.app-topbar .top-actions > #allEventsLink[data-action="create"] {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    gap: 0 !important;
    flex: 0 0 44px !important;
    justify-content: center;
  }
  .topbar.app-topbar .top-actions > #allEventsLink[data-action="create"] > span { display: none !important; }
  .topbar.app-topbar .top-actions > #allEventsLink[data-action="create"] > span::after { content: none; }
  .topbar.app-topbar .top-actions > #allEventsLink[data-action="create"] .nav-icon {
    width: 24px !important;
    min-width: 24px !important;
    height: 24px !important;
    flex: 0 0 24px !important;
    padding: 0 !important;
  }
}

@media (max-width: 560px) {
  #accountAccessDialog .dialog-head { grid-template-columns: 46px minmax(0, 1fr) 36px; gap: 11px; }
}

@media (max-width: 380px) {
  #accountAccessDialog .dialog-actions { grid-template-columns: 1fr; }
}

@media (max-width: 720px), (pointer: coarse) {
  :is(#userMenuPanel,#accountMobileSheet) .guest-account-login,
  :is(#userMenuPanel,#accountMobileSheet) .guest-account-register { height: 44px; min-height: 44px; }
  :is(.topbar.app-topbar, .admin-modern) #userMenuPanel #newEventButton.menu-add-event { min-height: 44px !important; }
}

@media (prefers-reduced-motion: reduce) {
  .topbar.app-topbar :is(#allEventsLink, #userMenuButton),
  :is(.topbar.app-topbar, .admin-modern) #userMenuPanel .menu-item { transition: none; }
}

/* The notification bell and account menu are neighbouring actions, so they use
   the regular action spacing without a divider in between. */
.topbar.app-topbar #userMenu {
  margin-left: 0;
}

.topbar.app-topbar #userMenu::before {
  content: none !important;
  display: none !important;
}

/* Same-role mobile header actions share one size and silhouette. Text links,
   the circular desktop bell and the avatar inside the account action keep
   their distinct roles. The larger create-action plus is intentional. */
@media (max-width: 900px) {
  .topbar.app-topbar .top-actions :is(#mobileSearchToggle, #userMenuButton),
  .admin-modern .admin-header-actions :is(#mobileSearchToggle, #userMenuButton) {
    box-sizing: border-box;
    flex: 0 0 44px !important;
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    align-self: center;
    border-radius: var(--outlo-control-radius, 12px) !important;
  }
  .topbar.app-topbar .top-actions #allEventsLink {
    height: 44px !important;
    min-height: 44px !important;
    border-radius: var(--outlo-control-radius, 12px) !important;
  }
  .admin-modern .admin-header-actions > #allEventsLink[data-action="create"] > .nav-icon {
    width: 24px !important;
    min-width: 24px !important;
    height: 24px !important;
    flex: 0 0 24px !important;
  }
  .topbar.app-topbar .top-actions,
  .admin-modern .admin-header-actions {
    align-items: center;
    gap: 6px !important;
  }
  .topbar.app-topbar .top-actions :is(#mobileSearchToggle, #userMenuButton),
  .admin-modern .admin-header-actions :is(#mobileSearchToggle, #userMenuButton) {
    box-shadow: 0 1px 3px rgb(15 23 42 / 6%) !important;
  }
  .topbar.app-topbar .top-actions :is(#mobileSearchToggle, #allEventsLink, #userMenuButton):focus-visible,
  .admin-modern .admin-header-actions :is(#mobileSearchToggle, #allEventsLink, #userMenuButton):focus-visible {
    outline: 3px solid #a5b4fc !important;
    outline-offset: 2px;
  }
}
@media (max-width: 370px) {
  .topbar.app-topbar .top-actions,
  .admin-modern .admin-header-actions { gap: 4px !important; }
}

