/*
 * leadity-Bibliothek · kanonische App-Shell
 * Quellen: Figma 2147:1502, 2376:24662, 2147:1518,
 * 2147:496, 2241:7633, 5370:14390
 * Dieser Layer wird nach den seitenspezifischen Styles geladen und hält
 * Header, Footer, Sidebar, Kontextnavigation und Breadcrumbs synchron.
 */

@import url("../../tokens.css");

.app-shell {
  grid-template-rows: 50px minmax(0, 1fr) 50px;
}

.global-header {
  min-width: 0;
  height: 50px;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: var(--leadity-space-6);
  gap: 0;
  background: var(--leadity-theme-main);
  color: var(--leadity-theme-on-main);
  box-shadow: var(--leadity-shadow-floating);
}

.global-header .header-cluster,
.global-header .header-user,
.global-header .user-context,
.global-header .company-context,
.global-header .header-actions {
  min-width: 0;
  display: flex;
  align-items: center;
}

.global-header .header-cluster { gap: 0; }
.global-header .header-user,
.global-header .user-context { gap: var(--leadity-space-4); }
.global-header .company-context { gap: var(--leadity-space-4); }
.global-header .header-actions { gap: 0; }

.global-header .company-context {
  min-height: 40px;
  padding-inline: var(--leadity-space-5);
  border-radius: var(--leadity-radius-full);
  font: 400 16px/18px var(--leadity-font-body);
}

.global-header .header-separator { opacity: 1; }

.global-header .company-name,
.global-header .user-name {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: 400 16px/18px var(--leadity-font-body);
}

.global-header .icon-button {
  width: 48px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 48px;
  position: relative;
  padding: 0;
  border: 0;
  border-radius: var(--leadity-radius-full);
  background: transparent;
  color: inherit;
  font-size: 20px;
  cursor: pointer;
  transform: none;
}

.global-header .icon-button:hover {
  background: color-mix(in srgb, var(--leadity-theme-on-main) 15%, transparent);
  transform: none;
}

.global-header :where(a, button, select, [tabindex]):focus-visible {
  outline-color: var(--leadity-white);
}

.global-header .icon-button:active { transform: none; }

.global-header .notification,
.global-header .notification-button { position: relative; }

.global-header .notification-count {
  min-width: 16px;
  height: 16px;
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  padding-inline: 3px;
  border: 1px solid var(--leadity-white);
  border-radius: var(--leadity-radius-full);
  background: var(--leadity-state-check-background);
  color: var(--leadity-white);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
}

.sidebar {
  width: var(--leadity-shell-sidebar-width);
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: calc(100dvh - 50px - 50px - var(--leadity-space-7) - var(--leadity-space-7));
  display: flex;
  flex-direction: column;
  align-self: start;
  overflow: hidden;
  border-radius: var(--leadity-radius-xl);
  background: var(--leadity-white);
  box-shadow: var(--leadity-shadow-default);
}

.app-shell[data-nav-open="false"] .sidebar { display: none; }
.app-shell[data-nav-open="true"] .sidebar { display: flex; }

.sidebar > .sidebar-head {
  width: 100%;
  min-height: 168px;
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 168px;
  padding: 48px 0 0;
}

.sidebar > .sidebar-head > .sidebar-logo {
  width: 162px;
  height: 40px;
  display: block;
  justify-self: center;
  align-self: center;
  max-width: 162px;
  object-fit: contain;
}

.sidebar .brand-mark { display: none; }

.sidebar-close {
  width: 40px;
  height: 40px;
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--leadity-radius-full);
  background: transparent;
  color: var(--leadity-neutral-60);
  font-size: 20px;
  cursor: pointer;
}

.sidebar-close:hover { background: var(--leadity-neutral-20); }

.nav-scroll {
  min-height: 0;
  flex: 1 1 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 var(--leadity-space-6) var(--leadity-space-6);
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: var(--leadity-neutral-40) transparent;
}

.nav-group + .nav-group { margin-top: var(--leadity-space-6); }

.nav-group { margin-inline: var(--leadity-space-3); }

.nav-group-title {
  min-height: 68px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--leadity-space-4);
  margin: 0;
  padding: var(--leadity-space-4) 0 var(--leadity-space-5);
  color: var(--leadity-text-dark);
  font: 700 21px/1.3 var(--leadity-font-display);
  letter-spacing: .1px;
}

.nav-group-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 40px;
}

.nav-group-icon::before {
  width: 32px;
  height: 32px;
  content: "";
  background: var(--leadity-neutral-60);
  -webkit-mask: var(--nav-group-icon) center / contain no-repeat;
  mask: var(--nav-group-icon) center / contain no-repeat;
}

.nav-item,
.nav-disclosure {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--leadity-space-1);
  padding: var(--leadity-space-1) 0;
  border: 0;
  border-radius: var(--leadity-radius-full);
  background: transparent;
  color: var(--leadity-text-default);
  font: 300 16px/20px var(--leadity-font-body);
  letter-spacing: .016px;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover,
.nav-disclosure:hover {
  background: transparent;
  color: var(--leadity-text-default);
  font-weight: 400;
}

.nav-item[aria-current="page"] {
  background: transparent;
  color: var(--leadity-text-default);
  font-weight: 700;
}

.nav-item[aria-current="page"]:hover { font-weight: 700; }

.nav-item > i,
.nav-disclosure > i {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  color: var(--leadity-neutral-60);
  font-size: 16px;
}

.nav-disclosure > i { transition: transform 160ms ease; }
.nav-disclosure:hover > i {
  border-radius: var(--leadity-radius-full);
  background: var(--leadity-neutral-20);
}
.nav-disclosure[aria-expanded="true"] > i { transform: rotate(180deg); }

.nav-submenu {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--motion-base) var(--ease-standard);
}

.nav-submenu[data-open="true"] { grid-template-rows: 1fr; }
.nav-submenu-inner { overflow: hidden; }
.nav-submenu .nav-item { padding-left: var(--leadity-space-6); }
.nav-submenu .nav-submenu .nav-item { padding-left: var(--leadity-space-8); }

.context-rail {
  width: 48px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  align-self: start;
  gap: var(--leadity-space-4);
}

.context-action {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-radius: var(--leadity-radius-full);
  background: var(--leadity-white);
  color: var(--leadity-text-dark);
  box-shadow: var(--leadity-shadow-default);
  font-size: 20px;
  cursor: pointer;
  transform: none;
  transition: background var(--motion-fast) var(--ease-standard), box-shadow var(--motion-fast) var(--ease-standard);
}

.context-action:hover {
  background: var(--leadity-neutral-20);
  box-shadow: var(--leadity-shadow-hover);
  transform: none;
}

.context-action:active { transform: none; }
.context-action > i { font-size: 20px; }
.context-action > img {
  width: 24px;
  height: 24px;
  display: block;
  object-fit: contain;
}
.context-action[data-icon-size="24"] > i { font-size: 24px; }

.breadcrumbs {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--leadity-space-4);
  padding-block: var(--leadity-space-3);
  color: var(--leadity-text-default);
  font: 400 14px/21px var(--leadity-font-body);
}

.breadcrumbs a,
.breadcrumbs [aria-current="page"] {
  min-width: 0;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumbs a {
  min-height: 21px;
  display: inline-flex;
  align-items: center;
  color: var(--leadity-text-default);
}

.breadcrumbs a:hover {
  color: inherit;
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.breadcrumbs [aria-current="page"] { color: var(--leadity-text-default); }
.breadcrumb-chevron { width: 16px; font-size: 16px; color: var(--leadity-neutral-50); }

.global-footer {
  min-width: 0;
  height: 50px;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--leadity-space-6);
  padding-inline: var(--leadity-space-6);
  background: var(--leadity-neutral-80);
  color: var(--leadity-white);
  box-shadow: var(--leadity-shadow-floating);
  font: 400 16px/18px var(--leadity-font-body);
}

.footer-brand,
.footer-links,
.footer-link,
.footer-links a {
  display: flex;
  align-items: center;
}

.footer-brand { gap: var(--leadity-space-6); }
.footer-logo { width: 69px; height: 17.162px; display: block; object-fit: contain; }
.footer-tagline { color: var(--leadity-neutral-20); opacity: 1; }
.footer-links { gap: 0; }
.footer-link,
.footer-links a {
  min-height: 40px;
  gap: var(--leadity-space-4);
  padding-inline: var(--leadity-space-5);
  border-radius: var(--leadity-radius-full);
  white-space: nowrap;
}

.footer-link > i,
.footer-links a > i {
  width: 20px;
  font-size: 20px;
  text-align: center;
}

.footer-link:hover,
.footer-links a:hover {
  background: color-mix(in srgb, var(--leadity-white) 15%, transparent);
  text-decoration: none;
}

@media (max-width: 1279px) {
  .global-header,
  .global-footer { padding-inline: var(--leadity-space-5); }
  .footer-tagline { display: none; }
}

@media (max-width: 1023px) {
  .sidebar {
    width: min(344px, calc(100vw - 32px));
    height: calc(100dvh - var(--leadity-shell-external-offset, 0px) - var(--leadity-shell-header-height) - var(--leadity-shell-footer-height) - var(--leadity-space-7) - var(--leadity-space-7));
    display: none;
    position: fixed;
    top: calc(var(--leadity-shell-external-offset, 0px) + var(--leadity-shell-header-height) + var(--leadity-space-7));
    left: var(--leadity-space-4);
    z-index: 60;
    box-shadow: var(--leadity-shadow-floating);
  }

  .app-shell[data-nav-open="true"] .sidebar { display: flex; }
}

@media (max-width: 767px) {
  body { overflow: auto; }

  .app-shell {
    height: auto;
    min-height: 100dvh;
    grid-template-rows: 50px minmax(0, auto) 256px;
  }

  .global-header { padding-inline: var(--leadity-space-4); }
  .global-header .company-name {
    max-width: 132px;
    display: block !important;
  }
  .global-header .header-separator,
  .global-header .leadity-header-year-picker,
  .global-header .user-name { display: none !important; }
  .global-header .header-actions .header-optional { display: inline-grid !important; }
  .sidebar { width: min(344px, calc(100vw - 32px)); }

  .context-rail {
    width: 100%;
    flex-direction: row;
    align-items: flex-start;
    justify-content: flex-start;
  }

  .global-footer {
    min-height: 256px;
    align-items: flex-start;
    justify-content: flex-start;
    flex-direction: column;
    gap: var(--leadity-space-7);
    padding: var(--leadity-space-7) var(--leadity-space-4);
  }

  .global-footer .footer-links {
    order: 1;
    width: 100%;
    display: flex !important;
    align-items: flex-start;
    flex-direction: column;
    gap: var(--leadity-space-3);
  }

  .global-footer .footer-brand { order: 2; }
  .footer-link,
  .footer-links a { padding-inline: 0; }
  .footer-link:hover,
  .footer-links a:hover { background: transparent; text-decoration: underline; }
}

@media (max-width: 560px) {
  .global-header { padding-inline: var(--leadity-space-1); }
  .global-header .header-cluster > a.icon-button { display: none; }
  .global-header .company-name { max-width: 72px; }
  .global-header .header-cluster,
  .global-header .header-user,
  .global-header .user-context { gap: var(--leadity-space-2); }
}

@media (prefers-reduced-motion: reduce) {
  .nav-disclosure > i { transition: none; }
}
