/* ============================================================
   Layout-стили клиента по официальной «Палитре платформы».
   Акцент — Orange 500, основа — Ink (сине-графит), тёмный сайдбар.
   Глобальные (не scoped), т.к. классы используются несколькими
   layout-компонентами совместно.
   ============================================================ */

:root {
    --wh-sidebar-w: 260px;
    --wh-topbar-h: 56px;
    --wh-bottomnav-h: 64px;

    /* Акцент · Orange */
    --wh-accent: #E8730F;
    --wh-accent-hover: #D2640F;
    --wh-accent-active: #B8520E;
    --wh-accent-soft: #FDF3EA;

    /* Ink (сине-графит) */
    --wh-graphite: #1C2430;   /* Ink 900 — сайдбар */
    --wh-graphite-2: #27313F; /* Ink 800 */
    --wh-ink: #1C2430;        /* основной текст/заголовки */
    --wh-muted: #475467;      /* Ink 600 — вторичный текст */
    --wh-placeholder: #7A8699;/* Ink 400 — подписи/плейсхолдеры */

    /* Поверхности и границы */
    --wh-border: #C2CAD4;
    --wh-bg: #F4F6F8;
    --wh-surface: #FFFFFF;
    --wh-muted-block: #F0F3F6;

    /* Семантика статусов */
    --wh-success: #1E8A5A;
    --wh-error: #D23B3B;
    --wh-warning: #C8890C;
    --wh-info: #2B6CB0;
}

/* ---------- Page heading (топбар-секция) ---------- */
.page-heading__eyebrow {
    display: block;
    font-size: .68rem;
    color: var(--wh-muted);
    line-height: 1.1;
}
.page-heading__title {
    margin: .05rem 0 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--wh-ink);
    line-height: 1.15;
}

/* ---------- Back link (под шапкой, слева) ---------- */
.back-link {
    color: var(--wh-muted);
    text-transform: none;
    font-weight: 500;
    padding-left: .35rem;
    padding-right: .6rem;
}
.back-link:hover {
    color: var(--wh-ink);
    background: var(--wh-muted-block);
}

/* ============================================================
   DESKTOP SHELL
   ============================================================ */
.shell--desktop {
    display: flex;
    min-height: 100vh;
}
.shell__sidebar {
    width: var(--wh-sidebar-w);
    flex: 0 0 var(--wh-sidebar-w);
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--wh-graphite);
}
.shell__main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.topbar {
    height: var(--wh-topbar-h);
    flex: 0 0 var(--wh-topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 1.5rem;
    background: var(--wh-surface);
    border-bottom: 1px solid var(--wh-border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar__actions {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.shell__content {
    flex: 1 1 auto;
    padding: 1rem 1.5rem;
    overflow-x: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: #A8B1BF; /* Ink 300 */
}
.sidebar__brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.25rem;
}
.sidebar__logo {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    background: var(--wh-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 700;
}
.sidebar__brand-text { display: flex; flex-direction: column; }
.sidebar__brand-title { color: #fff; font-weight: 700; font-size: .98rem; line-height: 1.1; }
.sidebar__brand-sub { color: #7A8699; font-size: .72rem; }
.sidebar__nav {
    flex: 1 1 auto;
    min-height: 0; /* позволяет flex-элементу сжиматься, иначе контент выдавливает футер за фон */
    overflow-y: auto; /* раскрытые группы прокручиваются внутри сайдбара */
    padding: .5rem .5rem;
    scrollbar-width: thin;
    scrollbar-color: #3A4658 transparent;
}
.sidebar__nav::-webkit-scrollbar { width: 6px; }
.sidebar__nav::-webkit-scrollbar-thumb { background: #3A4658; border-radius: 3px; }
.sidebar__nav::-webkit-scrollbar-track { background: transparent; }
.sidebar__footer {
    padding: .85rem 1rem;
    border-top: 1px solid #27313F;
}

/* MudNavLink в тёмном сайдбаре */
.sidebar__nav .mud-nav-link {
    color: #A8B1BF;
    border-radius: 8px;
    margin: 2px 0;
    font-size: .92rem;
    border-left: none !important;
}
.sidebar__nav .mud-nav-link:hover {
    background: #27313F;
    color: #fff;
}
.sidebar__nav .mud-nav-link.active,
.sidebar__nav .mud-nav-link.active:hover {
    background-color: var(--wh-accent) !important;
    color: #fff;
    font-weight: 600;
    border-left: none !important; /* убираем встроенный индикатор MudBlazor — фон сам выделяет пункт */
}
.sidebar__nav .mud-nav-link.active:hover { background: var(--wh-accent-hover); }
.sidebar__nav .mud-nav-link.active .mud-nav-link-text,
.sidebar__nav .mud-nav-link.active .mud-icon-root { color: #fff; }
.sidebar__nav .mud-nav-link .mud-icon-root { color: #7A8699; }

/* Счётчик горящих задач у пункта «Мои задачи»: красная плашка справа, как бейдж колокольчика.
   MudNavLink кладёт подпись и счётчик в один .mud-nav-link-text — делаем его flex, иначе
   margin-left:auto не действует и плашка липнет вплотную к тексту. */
.sidebar__nav .mud-nav-link-text {
    display: flex;
    align-items: center;
}
.sidebar__badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--mud-palette-error, #d32f2f);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

/* Подпункты раскрывающейся группы — мельче и с отступом, чем главные разделы */
.sidebar__nav .mud-collapse-container .mud-nav-link {
    font-size: .82rem;
    padding-top: .3rem;
    padding-bottom: .3rem;
    padding-left: 2.85rem; /* выравнивание под текст родителя (после иконки) */
    min-height: 34px;
}
.sidebar__nav .mud-collapse-container .mud-nav-link .mud-nav-link-text {
    font-size: .82rem;
}

/* ---------- User chip / menu ---------- */
/* Собственное меню профиля (не MudMenu): его popover позиционируется JS-ом MudBlazor и в подвале
   сайдбара оставался за пределами экрана (top:-9999px) — «меню не открывалось». Здесь всё на чистом
   CSS: панель абсолютно позиционирована над чипом внутри .user-menu, клик по фону-подложке закрывает. */
.user-menu { position: relative; z-index: 1300; }
.user-chip {
    display: flex;
    align-items: center;
    gap: .6rem;
    cursor: pointer;
    min-width: 0; /* позволяет имени сжиматься и обрезаться */
    max-width: 100%;
    position: relative;
    z-index: 2; /* чип выше подложки, чтобы повторный клик закрывал меню */
}
.user-menu__backdrop { position: fixed; inset: 0; z-index: 1; } /* ловит клик вне меню */
.user-menu__panel {
    position: absolute;
    bottom: calc(100% + 8px); /* раскрытие вверх, над профилем */
    left: 0;
    min-width: 220px;
    z-index: 2;
    padding: 4px 0;
}
.user-chip .mud-avatar { flex: 0 0 auto; } /* аватар не сжимается */
.user-chip__name {
    color: #C7CDD4;
    font-size: .9rem;
    /* ФИО обрезается троеточием, если не влезает в ширину сайдбара */
    min-width: 0;
    max-width: calc(var(--wh-sidebar-w) - 92px); /* минус паддинги футера, аватар и gap */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================
   MOBILE SHELL
   ============================================================ */
.shell--mobile {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--wh-bg);
}
.mobile-topbar {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .6rem 1rem;
    background: var(--wh-surface);
    border-bottom: 1px solid var(--wh-border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.mobile-topbar .page-heading__title { font-size: 1.2rem; }
.mobile-topbar__actions { display: flex; align-items: center; gap: .4rem; }
.shell__content--mobile {
    padding: 1rem;
    padding-bottom: calc(var(--wh-bottomnav-h) + 1rem);
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--wh-bottomnav-h);
    display: flex;
    background: var(--wh-surface);
    border-top: 1px solid var(--wh-border);
    z-index: 20;
}
.bottom-nav__item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--wh-muted);
    font-size: .68rem;
}
.bottom-nav__item .mud-icon-root { font-size: 1.4rem; }
/* Счётчик задач поверх иконки вкладки (позиционируется относительно самой вкладки). */
.bottom-nav__item { position: relative; }
.bottom-nav__badge {
    position: absolute;
    top: 4px;
    left: calc(50% + 4px);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--mud-palette-error, #d32f2f);
    color: #fff;
    font-size: .66rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
.bottom-nav__item--active { color: var(--wh-accent); font-weight: 600; }
.bottom-nav__item--active .mud-icon-root { color: var(--wh-accent); }

/* ============================================================
   AUTH LAYOUT
   ============================================================ */
.auth-layout {
    display: flex;
    min-height: 100vh;
}
.auth-layout__brand {
    flex: 1 1 60%;
    background: var(--wh-graphite-2);
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-layout__brand-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 2rem;
    text-align: center;
}
.auth-layout__logo {
    width: 72px; height: 72px;
    border-radius: 16px;
    background: #2C3036; color: #C7CDD4;
    display: flex; align-items: center; justify-content: center;
}
.auth-layout__brand-title {
    color: #E6E9ED;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: .01em;
}
.auth-layout__brand-caption {
    max-width: 360px;
    color: #8A9199;
    font-size: .92rem;
    line-height: 1.6;
}
.auth-layout__form-pane {
    flex: 0 0 40%;
    max-width: 560px;
    background: var(--wh-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.auth-layout__form { width: 100%; max-width: 380px; }

@media (max-width: 960px) {
    .auth-layout__brand { display: none; }
    .auth-layout__form-pane { flex: 1 1 100%; max-width: none; }
}

/* ============================================================
   SIGNING LAYOUT (публичный)
   ============================================================ */
.signing-layout { min-height: 100vh; background: var(--wh-bg); }
.signing-layout__bar {
    height: var(--wh-topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background: var(--wh-surface);
    border-bottom: 1px solid var(--wh-border);
}
.signing-layout__brand { display: flex; align-items: center; gap: .75rem; }
.signing-layout__logo {
    width: 36px; height: 36px; border-radius: 8px;
    background: var(--wh-graphite-2); color: #C7CDD4;
    display: flex; align-items: center; justify-content: center; font-size: .65rem;
}
.signing-layout__title { font-weight: 700; color: var(--wh-ink); }
.signing-layout__content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}
.signing-layout__session .user-chip__name { color: var(--wh-ink); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login__title { font-size: 1.6rem; font-weight: 700; color: var(--wh-ink); margin: 0; }
.login__subtitle { color: var(--wh-muted); margin: .25rem 0 1.75rem; }
.login__label { display: block; color: var(--wh-muted); margin-bottom: .25rem; }
.login__submit { height: 48px; font-weight: 600; }
.login__nfc {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.25rem;
    color: var(--wh-ink);
    font-size: .95rem;
}

/* ============================================================
   SERVICES (mobile)
   ============================================================ */
.services-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
    margin-top: .5rem;
}
.service-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: 1.1rem .5rem;
    background: var(--wh-surface);
    border: 1px solid var(--wh-border);
    border-radius: 14px;
    text-decoration: none;
    color: var(--wh-ink);
}
.service-tile__icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    background: var(--wh-bg);
    display: flex; align-items: center; justify-content: center;
}
.service-tile__label { font-size: .8rem; text-align: center; }

/* ============================================================
   SIGN DOCUMENT
   ============================================================ */
.sign-doc {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 2rem;
    align-items: start;
}
.sign-doc__qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2.5rem;
    background: var(--wh-surface);
}
@media (max-width: 768px) {
    .sign-doc { grid-template-columns: 1fr; }
}
