/* Каркас конструктора: тёмная колонка меню слева (216 px), белая полоса с путём сверху, подсказки «i».
   Уже 900 px колонка прячется и выезжает поверх экрана по кнопке «Меню». Цвета — переменные из admin.css. */

.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { flex: none; display: block; }

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.6rem; letter-spacing: .02em; color: #fff; text-decoration: none; }
.brand::before { content: ""; width: 6px; height: 22px; background: var(--amber); border-radius: 1px; transform: translateY(4px); }

/* Экраны без колонки: вход и смена временного пароля */
.plain-top { background: var(--side); padding: 12px 16px; }
.plain-top .brand { font-size: 1.3rem; }

/* Раскладка: колонка слева во всю высоту, справа полоса и содержимое */
.has-side .frame { display: grid; grid-template-columns: 216px minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }
.side {
  grid-row: 1 / span 2; position: sticky; top: 0; height: 100vh; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 14px; padding: 18px 8px 12px;
  background: var(--side); color: var(--side-ink); font-size: .95rem; scrollbar-width: thin;
}
.side a { color: inherit; text-decoration: none; }
.side :focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }
.side-close { display: none; }
.side summary { list-style: none; cursor: pointer; }
.side summary::-webkit-details-marker { display: none; }
.chev { margin-left: auto; width: 14px; height: 14px; color: var(--side-muted); transition: transform .15s; }
details[open] > summary .chev { transform: rotate(180deg); }

/* Выбор сайта */
.site-pick { position: relative; }
.site-pick > summary {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 10px;
  border: 1px solid var(--side-line); border-radius: var(--radius);
}
.site-pick > summary:hover { background: var(--side-hover); }
.site-pick-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 10; padding: 4px;
  background: var(--card); color: var(--ink); border-radius: var(--radius); box-shadow: 0 6px 20px rgb(0 0 0 / .25);
}
.site-pick-list a { display: block; padding: 9px 10px; border-radius: 6px; color: var(--ink); }
.site-pick-list a:hover { background: var(--hover); }
.site-pick-list a[aria-current="page"] { font-weight: 600; color: var(--green); }

/* Пункты меню */
.side-nav { border-top: 1px solid var(--side-line); padding-top: 12px; }
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.side-item, .side-sub { position: relative; display: flex; align-items: center; }
.side-item > a, .side-group > details > summary {
  flex: 1; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 8px; margin: 1px 0;
  border-radius: var(--radius); color: var(--side-ink);
}
.side-item > a:hover, .side-group > details > summary:hover { background: var(--side-hover); }
.side-item > a[aria-current="page"] { background: var(--side-active); box-shadow: inset 3px 0 0 var(--amber); font-weight: 600; }
.side-name { min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
/* «Неопубликованные» с числом — в одну строку: чуть меньше промежуток, слово не переносится */
.side-item a:has(.side-badge) { gap: 6px; }
.side-item a:has(.side-badge) .side-name { white-space: nowrap; }
.side-badge { flex-shrink: 0; margin-left: auto; padding: 0 6px; font-size: .78rem; line-height: 1.5; border-radius: 4px; background: var(--side-line); color: #fff; }
.side-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--side-line); }
.side-group + .side-group { border-top: 0; margin-top: 0; }
.side-group + .side-item { margin-top: 8px; }
.side-group ul { margin: 2px 0 4px 14px; padding-left: 6px; border-left: 1px solid var(--side-line); }
.side-sub > a { flex: 1; display: block; padding: 7px 8px; font-size: .9rem; border-radius: 6px; color: var(--side-muted); line-height: 1.3; }
.side-sub > a:hover { color: var(--side-ink); background: var(--side-hover); }
.side-sub > a[aria-current="page"] { color: #fff; font-weight: 600; background: var(--side-active); }

/* Кто вошёл — внизу колонки */
.side-user { position: relative; margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--side-line); }
.avatar { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--side-active); color: #fff; font-weight: 600; }
.side-who { display: grid; min-width: 0; line-height: 1.25; }
.who-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { color: var(--side-muted); font-size: .85rem; }
.user-menu { margin-left: auto; }
.user-menu > summary { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 6px; color: var(--side-muted); }
.user-menu > summary:hover { background: var(--side-hover); color: #fff; }
.user-menu-list {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 10; padding: 4px;
  background: var(--card); border-radius: var(--radius); box-shadow: 0 6px 20px rgb(0 0 0 / .25);
}
.user-menu-list a, .user-menu-list button {
  display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 6px; background: none;
  color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.user-menu-list a:hover, .user-menu-list button:hover { background: var(--hover); }
.user-menu-list a[aria-current="page"] { font-weight: 600; color: var(--green); }
.user-menu-list form { margin: 0; border-top: 1px solid var(--line); padding-top: 4px; margin-top: 4px; }
.user-menu-list button { color: var(--red); }

/* Полоса сверху: путь и «Открыть сайт» / «История» */
.bar {
  grid-column: 2; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 32px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.crumbs { min-width: 0; flex: 1; }
.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; margin: 0; padding: 0; list-style: none; font-size: .95rem; }
.crumbs li { display: inline-flex; align-items: center; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin: 0 10px; color: var(--muted); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--green); text-decoration: underline; }
.crumbs [aria-current="page"] { color: var(--ink); font-weight: 600; }
.bar-actions { margin-left: auto; display: flex; gap: 16px; }
.bar-link { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.bar-link:hover { color: var(--green); }
.menu-btn { display: none; }

.has-side .page { grid-column: 2; margin: 0; width: 100%; padding: 28px 32px 96px; }

/* Подсказка «i»: при наведении и с клавиатуры, Esc прячет (admin.js) */
.tip { position: relative; display: inline-flex; vertical-align: middle; }
.tip-btn {
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0; margin: 0 2px;
  border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: help;
}
.tip-btn .ico { width: 16px; height: 16px; }
.tip-btn:hover, .tip-btn:focus-visible { color: var(--green); }
.tip-text {
  position: absolute; left: calc(100% + 6px); top: 50%; transform: translateY(-50%); z-index: 40; display: none;
  width: max-content; max-width: 280px; padding: 8px 12px; border-radius: 6px;
  background: var(--side); color: #fff; font-size: .88rem; font-weight: 400; line-height: 1.4; text-align: left; white-space: normal;
}
.tip:hover .tip-text, .tip-btn:focus-visible + .tip-text { display: block; }
.tip.tip-closed .tip-text { display: none; }
/* В колонке меню подсказка — у самого пункта: открывается под ним при наведении и фокусе, во всю ширину колонки */
.side .tip { display: flex; }
.side .tip > a:focus-visible + .tip-text { display: block; }
.side .tip-text { pointer-events: none; }
.side .tip-text { left: 0; right: 0; top: 100%; transform: none; max-width: none; width: auto; background: #fff; color: var(--ink); box-shadow: 0 6px 20px rgb(0 0 0 / .25); }

/* Телефон и узкое окно: колонка выезжает поверх экрана по кнопке «Меню» */
@media (max-width: 899px) {
  .has-side .frame { grid-template-columns: minmax(0, 1fr); }
  .bar, .has-side .page { grid-column: 1; }
  .bar { padding: 6px 16px; position: sticky; top: 0; z-index: 30; }
  .has-side .page { padding: 20px 16px 96px; }
  .menu-btn {
    display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 10px 0 6px; margin-left: -6px;
    border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; font-weight: 600;
  }
  .crumbs li:not(:last-child) { display: none; }
  .crumbs li + li::before { content: none; }
  .crumbs [aria-current="page"] { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .crumbs li { min-width: 0; }
  .bar-link span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .bar-link { min-width: 40px; justify-content: center; }
  .side {
    position: fixed; inset: 0 auto 0 0; z-index: 50; width: 280px; max-width: 85vw; height: auto;
    transform: translateX(-100%); visibility: hidden; transition: transform .2s ease-out, visibility .2s;
    box-shadow: 0 0 40px rgb(0 0 0 / .4);
  }
  .side:target, .side.open { transform: none; visibility: visible; }
  .side-close { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 6px; color: var(--side-ink); }
  .side-close:hover { background: var(--side-hover); }
  body.menu-open { overflow: hidden; }
  body.menu-open::after { content: ""; position: fixed; inset: 0; z-index: 45; background: rgb(0 0 0 / .45); }
}

@media (prefers-reduced-motion: reduce) {
  .side, .chev { transition: none; }
}
.side-logout .btn { color: var(--side-ink); background: none; border-color: var(--side-line); width: 100%; }
