/* Редизайн: shell. Загружается после styles.css и переопределяет его. */

/* ---------- Верхняя панель ---------- */
/* clip, а не hidden: не создаёт контейнер прокрутки, sticky у topbar работает. */
html { overflow-x: clip; }

.page-shell > .topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  width: 100vw;
  margin-top: calc(-1 * clamp(20px, 2.4vw, 32px));
  margin-left: calc(50% - 50vw);
  background: linear-gradient(180deg, rgba(38, 47, 60, 0.92), rgba(22, 28, 38, 0.94));
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--glass-shadow-sm);
  color: var(--text-inverse);
}

.topbar__inner {
  width: min(1460px, calc(100% - clamp(22px, 3vw, 52px)));
  height: 60px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-inverse);
  text-decoration: none;
  flex-shrink: 0;
}

.topbar__logo {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(145deg, #9aa5b3, #5d6876);
  color: #151c26;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.topbar__title {
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.topbar__nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.topbar__user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.topbar__logout { margin: 0; }

.topbar__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: rgba(244, 247, 251, 0.78);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease;
}

.topbar__link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.topbar__link.is-active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-inverse);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.topbar__link:focus-visible,
.topbar__brand:focus-visible,
.topbar__burger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.topbar__burger {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-inverse);
  cursor: pointer;
  flex-shrink: 0;
}

.topbar__burger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Заголовок страницы ---------- */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 24px 0 16px;
}

.page-head h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  color: var(--text);
}

.page-head__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.page-head__actions .button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.page-head__actions .button:focus-visible,
.page-head__actions a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Планшет и ниже ---------- */
@media (max-width: 900px) {
  .topbar__burger { display: inline-flex; order: 2; }
  .topbar__user { order: 1; }

  .topbar__nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px clamp(22px, 3vw, 52px) 12px;
    background: linear-gradient(180deg, rgba(38, 47, 60, 0.97), rgba(22, 28, 38, 0.98));
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--glass-shadow-sm);
  }

  .topbar.is-open .topbar__nav { display: flex; }

  .topbar__nav .topbar__link {
    height: 48px;
    border-radius: 12px;
  }

  .topbar__inner { position: static; }
  .page-shell > .topbar { position: sticky; }
  .topbar__user { position: static; }

  .topbar__username { display: none; }

  .topbar__user .topbar__link {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }

  .topbar__logout-text { display: none; }

  .topbar__logout-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .page-shell > .topbar { height: 56px; }
  .topbar__inner { height: 56px; }
  .topbar__title { font-size: 15px; }

  .page-head { padding: 18px 0 12px; }
  .page-head h1 { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .topbar__link { transition: none; }
}

/* Бейдж роли в верхней панели */
.topbar__role {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: var(--text-inverse);
  background: rgba(255, 255, 255, 0.12);
}

.topbar__role--admin {
  background: rgba(199, 68, 49, 0.25);
}

.topbar__role--specialist {
  background: rgba(20, 90, 214, 0.28);
}

.topbar__role--manager {
  background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 900px) {
  .topbar__role { display: none; }
}

/* ============================================
   Мобильная вёрстка: раскрытое меню не просвечивает заголовок страницы
   ============================================ */
@media (max-width: 900px) {
  .topbar.is-open .topbar__nav {
    background: rgb(22, 28, 38);
    box-shadow: 0 12px 24px rgba(15, 20, 28, 0.35);
  }
}
