/*
 * Entity workspace — section spacing and section toolbars (tabir, org units, treasury).
 * Canonical .workspace-* classes; .tabir-workspace-* aliases preserved for existing markup.
 */

.workspace-section + .workspace-section,
.tabir-workspace-section + .tabir-workspace-section,
.workspace-section + .tabir-workspace-section,
.tabir-workspace-section + .workspace-section {
  margin-top: var(--space-6);
}

.workspace-toolbar,
.tabir-workspace-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.workspace-toolbar__primary,
.tabir-workspace-toolbar__primary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.workspace-toolbar__actions,
.tabir-workspace-toolbar__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* Index / dashboard section heading + “+” menu (home overview, stanytsias browse, …). */
.workspace-section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.workspace-section-header__heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.workspace-section-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.workspace-section-header__menu {
  flex-shrink: 0;
}

.workspace-section-header__menu .dropdown-menu {
  z-index: 1075;
}

.workspace-section-header__menu .dropdown-menu .dropdown-item[type="button"],
.workspace-section-header__menu .dropdown-menu a.dropdown-item {
  width: 100%;
  text-align: start;
  border: 0;
  background: transparent;
  text-decoration: none;
}

.workspace-section-header__menu-icon {
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1;
}

.workspace-framed-list {
  margin-bottom: 0;
  background: var(--bg-surface);
}

.workspace-framed-list .list-group-item {
  background: var(--bg-surface);
}

.skhodyny-schedule-overview__row--past {
  opacity: 0.55;
}

.skhodyny-schedule-overview__row--next {
  box-shadow: inset 0 0 0 2px var(--border-secondary);
  font-weight: 600;
}

.skhodyny-schedule-overview__row--next .row-primary {
  font-weight: 600;
}

.overview-list-more__toggle {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  line-height: inherit;
  color: var(--link-content-color);
  cursor: pointer;
  text-align: inherit;
}

.overview-list-more__toggle:hover,
.overview-list-more__toggle:focus-visible {
  color: var(--link-content-hover-color);
}

.overview-list-more__toggle:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.workspace-list-section + .workspace-list-section {
  margin-top: var(--space-4);
}

/*
 * Full-bleed workspace head — title + primary entity tabs under the nav.
 * Background paints via ::before so content stays in the Bootstrap column
 * (works for both :wide col-12 and :browse col-xl-10).
 */
.workspace-head {
  position: relative;
  /* Cancel .container.mt-4 so the band sits flush under the fixed navbar */
  margin-top: calc(-1 * var(--space-6));
  margin-bottom: var(--space-4);
  padding-top: var(--space-4);
  padding-bottom: 0;
  z-index: 0;
}

/*
 * Bootstrap .card is position:relative with z-index:auto, so it shares this
 * band’s layer and, coming later in the tree, paints over it. A menu’s own
 * z-index only competes inside the band, which is why the hurtok/riy New
 * menu disappears behind the white panel under the title.
 * Lift only while a menu is open: a permanent raise would cover pinned
 * matrix headers (1020) as the band scrolls away. Stay under flash (1050)
 * and the navbar (1100).
 */
.workspace-head:has(.dropdown-menu.show) {
  z-index: 1030;
}

.workspace-head::before {
  content: "";
  position: absolute;
  /* Cover navbar-height overscroll so paper canvas does not flash over the head. */
  top: calc(-1 * (var(--nav-sticky-top) + 6rem));
  bottom: 0;
  left: 50%;
  width: 100vw;
  max-width: 100vw;
  transform: translateX(-50%);
  background: var(--workspace-head-bg);
  border-bottom: 1px solid var(--workspace-head-border);
  z-index: -1;
  pointer-events: none;
}

.workspace-head__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  padding-bottom: var(--space-1);
}

.workspace-head:has(.workspace-head-nav) .workspace-head__inner {
  padding-bottom: 0;
  gap: var(--space-2);
}

.workspace-head__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}

.workspace-head__heading {
  margin: 0;
  min-width: 0;
  font-family: var(--font-display);
  font-size: var(--font-ui-section);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.3;
  color: var(--text-primary);
}

.workspace-head__heading-block {
  min-width: 0;
}

/* Location line under the page title: type and ancestors on a unit, unit path on a person. */
.workspace-head__path {
  margin: 0.2rem 0 0;
  min-width: 0;
}

.workspace-head__path-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.45rem;
  row-gap: 0.15rem;
  min-width: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.35;
  color: var(--text-secondary);
}

.workspace-head__path .app-body-link--breadcrumb {
  font-size: inherit;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
}

.workspace-head__path .app-body-link--breadcrumb:hover,
.workspace-head__path .app-body-link--breadcrumb:focus-visible {
  color: var(--accent-primary);
  text-decoration: none;
}

.workspace-head__path .workspace-head__breadcrumb-sep {
  font-size: inherit;
}

.workspace-head__heading-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.5rem;
  row-gap: 0.2rem;
  min-width: 0;
}

.workspace-head__path .workspace-head__type-label {
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: 0;
  color: inherit;
  white-space: nowrap;
}

.workspace-head__breadcrumb-sep {
  font-size: inherit;
  font-weight: 500;
  color: var(--text-tertiary);
  opacity: 0.55;
  user-select: none;
}

.workspace-head__breadcrumb-sep.workspace-head__breadcrumb-sep--dot {
  color: inherit;
  opacity: 1;
}

.workspace-head__status-badges {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  align-self: center;
  gap: var(--space-2);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.2;
}

.workspace-head__meta {
  margin-top: var(--space-2);
}

.workspace-head__meta.org-unit-meta,
.workspace-head .org-unit-meta {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0 !important;
}

/* Primary section titles in the band — text links, not pills */
.workspace-head .entity-sub-nav.mb-3,
.workspace-head .workspace-head__tabs {
  margin-bottom: 0 !important;
}

.workspace-head-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  min-width: 0;
}

.workspace-head-nav__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0.55rem 0.85rem 0.65rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.25;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--transition-fast, 0.15s ease);
}

/*
 * Active mark as ::after, flush with the band bottom. Hairlines sit behind it
 * (head ::before border / secondary inset shadow) — not a flow border-bottom.
 */
.workspace-head-nav__link::after {
  content: "";
  position: absolute;
  right: 0.85rem;
  bottom: 0;
  left: 0.85rem;
  height: 2px;
  border-radius: 1px 1px 0 0;
  background: transparent;
  pointer-events: none;
  transition: background var(--transition-fast, 0.15s ease);
}

.workspace-head-nav__link:hover::after,
.workspace-head-nav__link:focus-visible::after {
  background: color-mix(in srgb, var(--accent-mark) 40%, transparent);
}

.workspace-head-nav__link:focus-visible {
  outline: none;
  border-radius: var(--radius-sm);
  box-shadow: inset 0 0 0 2px rgba(var(--accent-mark-rgb), 0.35);
}

.workspace-head-nav__link.is-active,
.workspace-head-nav__link[aria-selected="true"] {
  color: var(--text-primary);
  font-weight: 600;
}

.workspace-head-nav__link.is-active::after,
.workspace-head-nav__link[aria-selected="true"]::after {
  background: var(--accent-mark);
}

body.pointer-nav-hover-locked .workspace-head-nav__link:hover:not(.is-active):not([aria-selected="true"]) {
  color: var(--text-secondary);
}

body.pointer-nav-hover-locked .workspace-head-nav__link:hover:not(.is-active):not([aria-selected="true"])::after {
  background: transparent;
}

/*
 * Narrow viewports: one swipeable row of section titles
 * (bottom dock already carries primary tabs).
 */
@media (max-width: 991.98px) {
  .workspace-head {
    padding-top: var(--space-3);
    margin-bottom: var(--space-3);
  }

  .workspace-head__heading {
    font-size: clamp(1.0625rem, 2.2vw, 1.25rem);
  }

  /* Primary tabs only — overflow on .workspace-sub-nav clips its full-bleed ::before. */
  .workspace-head .workspace-head-nav {
    flex-wrap: nowrap;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    margin-inline: calc(-1 * var(--space-1));
    padding-inline: var(--space-1);
  }

  .workspace-head .workspace-head-nav::-webkit-scrollbar {
    display: none;
  }

  .workspace-head-nav__link {
    flex: 0 0 auto;
    padding: 0.4rem 0.7rem 0.55rem;
    font-size: 0.875rem;
    font-weight: 500;
  }

  .workspace-head-nav__link::after {
    right: 0.7rem;
    left: 0.7rem;
  }
}

/*
 * Secondary section rail — same titles links as the head, on a mid-tone
 * full-bleed band that hangs under workspace_head (tabir + org unit).
 * Target .workspace-sub-nav-band (the sibling wrapper); .workspace-sub-nav
 * lives inside it. Use ~ (not +): kurin headers often render access-request
 * modals between the head and the nested rail, which would leave a margin
 * gap with +.
 */
.workspace-head:has(~ .workspace-sub-nav-band) {
  margin-bottom: 0;
  padding-bottom: 0;
}

.workspace-sub-nav.workspace-head-nav {
  position: relative;
  z-index: 0;
  margin-top: 0 !important;
  margin-bottom: var(--space-4) !important;
  padding-bottom: 0;
  /* Nest under primary head tabs — modest inset, smaller on narrow viewports */
  padding-inline-start: var(--space-4);
}

.workspace-sub-nav.workspace-head-nav::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 100vw;
  max-width: 100vw;
  transform: translateX(-50%);
  background: var(--workspace-sub-nav-bg);
  /* Inset hairline so the active mark covers it (same idea as .workspace-head::before). */
  border-bottom: 0;
  box-shadow: inset 0 -1px 0 var(--workspace-sub-nav-border);
  z-index: -1;
  pointer-events: none;
}

.workspace-sub-nav > .workspace-head-nav__link {
  padding: 0.4rem 0.75rem 0.55rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.workspace-sub-nav > .workspace-head-nav__link::after {
  right: 0.75rem;
  left: 0.75rem;
}

.workspace-sub-nav > .workspace-head-nav__link.is-active,
.workspace-sub-nav > .workspace-head-nav__link[aria-selected="true"] {
  font-weight: 600;
}

@media (max-width: 991.98px) {
  .workspace-sub-nav.workspace-head-nav {
    /* Full-bleed on the element itself so sides aren't clipped by overflow */
    width: 100vw;
    max-width: 100vw;
    margin-top: 0 !important;
    margin-bottom: var(--space-3) !important;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: calc(50vw - 50% + var(--space-2));
    padding-right: calc(50vw - 50% + var(--space-2));
    background-color: var(--workspace-sub-nav-bg);
    border-bottom: 0;
    box-shadow: inset 0 -1px 0 var(--workspace-sub-nav-border);
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }

  .workspace-sub-nav.workspace-head-nav::-webkit-scrollbar {
    display: none;
  }

  .workspace-sub-nav.workspace-head-nav::before {
    display: none;
  }

  .workspace-sub-nav > .workspace-head-nav__link {
    flex: 0 0 auto;
    padding: 0.4rem 0.65rem 0.55rem;
    font-size: 0.8125rem;
  }

  .workspace-sub-nav > .workspace-head-nav__link::after {
    right: 0.65rem;
    left: 0.65rem;
  }
}

/* Completions groups: same paper as a framed list. Open state is the list-row
   wash, not Bootstrap's blue accordion highlight. */
.skhodyny-completions-accordion {
  --bs-accordion-border-width: 0;
  --bs-accordion-border-radius: var(--radius-panel);
  --bs-accordion-inner-border-radius: 0;
  --bs-accordion-bg: var(--bg-surface);
  --bs-accordion-btn-bg: var(--bg-surface);
  --bs-accordion-active-bg: var(--list-row-hover-bg);
  --bs-accordion-btn-color: var(--text-primary);
  --bs-accordion-active-color: var(--text-primary);
  --bs-accordion-btn-focus-box-shadow: 0 0 0 0.25rem rgba(var(--accent-primary-rgb), 0.22);
  --bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%232d5c44' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M2 5L8 11L14 5'/%3e%3c/svg%3e");
  --bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%232d5c44' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M2 5L8 11L14 5'/%3e%3c/svg%3e");
  overflow: hidden;
  background: var(--bg-surface);
}

html[data-theme="dark"] .skhodyny-completions-accordion {
  --bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2334a368' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M2 5L8 11L14 5'/%3e%3c/svg%3e");
  --bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2334a368' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M2 5L8 11L14 5'/%3e%3c/svg%3e");
}

.skhodyny-completions-accordion > .accordion-item {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-primary);
}

.skhodyny-completions-accordion > .accordion-item:last-child {
  border-bottom: 0;
}

.skhodyny-completions-accordion .accordion-button {
  box-shadow: none;
  color: var(--text-primary);
}

.skhodyny-completions-accordion .accordion-button:not(.collapsed) {
  box-shadow: none;
  color: var(--text-primary);
}

.skhodyny-completions-accordion .accordion-body {
  background: var(--bg-surface);
}

/* Same vertical rhythm as a tabir roster row (px-3 py-2), not the default 1rem list padding. */
.list-group-item.roster-person-row {
  padding: 0.5rem 0.75rem;
}

/* Role rows in the People modal are a ledger, not links. */
.regional-person-role-list .list-group-item:hover {
  background: transparent;
}

/* Regional People roster grouping — same visual language as tabir zaloha/hurtok headings. */
.regional-directory-roster .roster-group-heading__bar {
  line-height: 1.2;
}

.regional-directory-roster .roster-group-heading--parent .roster-group-heading__bar {
  padding-block: 0.4rem;
  background: var(--table-group-row-bg);
  color: var(--text-primary);
  font-weight: 700;
}

.regional-directory-roster .roster-group-heading--unit .roster-group-heading__bar {
  padding-block: 0.22rem;
  padding-inline-start: calc(var(--space-3) + 0.75rem);
  background: color-mix(in srgb, var(--table-group-row-bg) 55%, var(--bg-surface) 45%);
  color: var(--text-secondary);
  font-weight: 600;
}

.workspace-create-menu__toggle {
  min-width: 2rem;
  padding-inline: 0.55rem;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
}

.workspace-create-menu__toggle.dropdown-toggle::after {
  display: none;
}

.workspace-create-menu__list {
  z-index: 1035;
  min-width: 12rem;
}

.workspace-create-menu__item {
  display: flex;
  align-items: center;
  min-height: 44px;
}
