/* Копия taspa/design — не править здесь, см. design/README.md в репозитории taspa. */
/* TASPA — общая оболочка систем: боковое меню слева, переключатели темы и
 * языка, пользователь. Требует taspa-tokens.css. Источник — taspa/design/.
 *
 * Разметка (одинаковая во всех системах, см. design/README.md):
 *   .tp-app > .tp-sidebar + .tp-main
 *   .tp-sidebar > .tp-brand, .tp-nav (.tp-nav-section > .tp-nav-label + .tp-nav-item), .tp-sidebar-foot
 */

.tp-body {
  margin: 0;
  font-family: var(--tp-font);
  color: var(--tp-text);
  background: var(--tp-bg);
  -webkit-font-smoothing: antialiased;
}

.tp-app {
  display: flex;
  min-height: 100vh;
  background: var(--tp-bg);
  color: var(--tp-text);
  font-family: var(--tp-font);
}

.tp-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Боковое меню ── */
.tp-sidebar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  flex: 0 0 var(--tp-sidebar-w);
  width: var(--tp-sidebar-w);
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;
  padding: 16px 12px 12px;
  background: var(--tp-panel);
  border-right: 1px solid var(--tp-line);
  font-family: var(--tp-font);
  overflow: hidden;
}

.tp-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 16px;
  color: var(--tp-text);
  text-decoration: none;
}
.tp-brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: var(--tp-radius-card);
  background: var(--tp-primary);
  color: var(--tp-on-primary);
  font: 800 17px/1 var(--tp-font);
  letter-spacing: -0.02em;
}
.tp-brand-mark img, .tp-brand-mark svg { width: 26px; height: 26px; }
.tp-brand-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tp-brand-family { color: var(--tp-text-3); font: 600 10px/1 var(--tp-font); letter-spacing: .1em; text-transform: uppercase; }
.tp-brand-name { color: var(--tp-primary); font: 800 19px/1.05 var(--tp-font); letter-spacing: .02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tp-nav {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 4px 0;
  overflow-y: auto;
  scrollbar-width: thin;
}
.tp-nav-section { display: flex; flex-direction: column; gap: 2px; }
.tp-nav-label {
  padding: 6px 12px 6px;
  color: var(--tp-text-3);
  font: 700 10.5px/1.2 var(--tp-font);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.tp-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 8px 12px;
  box-sizing: border-box;
  border: 0;
  border-radius: var(--tp-radius);
  background: transparent;
  color: var(--tp-text-2);
  font: 600 14px/1.25 var(--tp-font);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
.tp-nav-item svg { flex: 0 0 20px; width: 20px; height: 20px; stroke-width: var(--tp-icon-stroke); }
.tp-nav-item > span:not(.tp-nav-badge) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-nav-item:hover { background: var(--tp-primary-soft); color: var(--tp-primary); }
.tp-nav-item.is-active,
.tp-nav-item[aria-current="page"] { background: var(--tp-primary); color: var(--tp-on-primary); }
.tp-nav-item:focus-visible { outline: none; box-shadow: var(--tp-focus); }
.tp-nav-badge {
  margin-left: auto;
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--tp-danger);
  color: #fff;
  font: 700 11px/16px var(--tp-font);
  text-align: center;
}
:root[data-theme="dark"] .tp-nav-badge { color: #1b1215; }
.tp-nav-item.is-active .tp-nav-badge { background: var(--tp-on-primary); color: var(--tp-primary); }

/* Путь назад в портал TASPA из подключённой системы. */
.tp-nav-portal { color: var(--tp-text-3); font-weight: 600; }

/* ── Низ меню: язык, тема, пользователь ── */
.tp-sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--tp-line);
}
.tp-prefs { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }

.tp-seg {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--tp-line);
  border-radius: var(--tp-radius-card);
  background: var(--tp-panel-2);
}
.tp-seg button {
  min-width: 44px;
  min-height: 30px;
  padding: 4px 10px;
  border: 0;
  border-radius: var(--tp-radius);
  background: transparent;
  color: var(--tp-text-2);
  font: 700 12px/1 var(--tp-font);
  letter-spacing: .02em;
  cursor: pointer;
}
.tp-seg button:hover { color: var(--tp-primary); }
.tp-seg button[aria-pressed="true"] { background: var(--tp-primary); color: var(--tp-on-primary); }
.tp-seg button:focus-visible { outline: none; box-shadow: var(--tp-focus); }

.tp-icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--tp-line);
  border-radius: var(--tp-radius-card);
  background: var(--tp-panel);
  color: var(--tp-text-2);
  cursor: pointer;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.tp-icon-btn svg { width: 19px; height: 19px; stroke-width: var(--tp-icon-stroke); }
.tp-icon-btn:hover { background: var(--tp-primary-soft); color: var(--tp-primary); border-color: var(--tp-line-2); }
.tp-icon-btn:focus-visible { outline: none; box-shadow: var(--tp-focus); }
.tp-icon-btn.is-plain { border-color: transparent; background: transparent; }

.tp-user { display: flex; align-items: center; gap: 10px; padding: 6px 4px 2px; min-width: 0; }
.tp-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--tp-primary-soft);
  color: var(--tp-primary);
  font: 700 13px/1 var(--tp-font);
}
.tp-user-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 auto; }
.tp-user-name { color: var(--tp-text); font: 700 13px/1.2 var(--tp-font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-user-role { color: var(--tp-text-3); font: 500 11.5px/1.2 var(--tp-font); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Шапка рабочей области ── */
.tp-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 10px 24px;
  box-sizing: border-box;
  background: var(--tp-panel);
  border-bottom: 1px solid var(--tp-line);
}
.tp-topbar-title { margin: 0; color: var(--tp-text); font: 700 18px/1.25 var(--tp-font); }
.tp-menu-btn { display: none; }

/* ── Узкий экран: меню — выдвижная шторка ── */
.tp-scrim { display: none; }
@media (max-width: 900px) {
  .tp-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: var(--tp-shadow-pop);
  }
  .tp-app.is-nav-open .tp-sidebar { transform: none; }
  .tp-app.is-nav-open .tp-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgb(15 23 42 / 40%);
  }
  .tp-menu-btn { display: inline-grid; }
  .tp-topbar { padding: 8px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .tp-sidebar, .tp-nav-item, .tp-icon-btn { transition: none; }
}
