/* Справочники super-admin (компании, пользователи, приглашения) — общий язык списков.
   Глобальный (не scoped), чтобы переиспользоваться страницами Companies и PlatformUsers.
   Базовые таблица/чип/кнопка/карточка приходят из theme.css. */

.directory {
    max-width: 1040px;
    margin: 0 auto;
    padding: 28px 30px 72px;
}

/* ---------- Toolbar (search + count) — MudBlazor-версия ----------
   ВНИМАНИЕ: раньше здесь жил НАТИВНЫЙ search-wrapper (display:flex + align-items:center +
   собственный бордер/фон/паддинг + дочерний `.dir-search input`). Сейчас .dir-search висит
   на <MudTextField>, а .dir-toolbar — на <MudToolBar>. Старые правила ЛОМАЛИ Mud-поле:
   row-flex + align-items:center сжимали .mud-input-control → инпут не растягивался на всю
   ширину строки («место выделено, а инпут не во всё место»), плюс был двойной бордер.
   Здесь оставляем ТОЛЬКО то, чего нет в теме (ширина/отступы) — раскладку строки даёт сам
   MudToolBar + MudSpacer. Зеркалит scoped DataGrid.razor.css, чтобы страницы (Regions/
   Companies/Shops) и грид-компонент выглядели одинаково. */
.dir-toolbar {
    gap: 12px;
    margin-bottom: 8px;
}

/* Квалификатор .mud-input-control нужен, чтобы перебить Mud-дефолт
   `.mud-input-control{max-width:100%}` (одинаковая специфичность, но MudBlazor.min.css
   грузится позже directory.css). Зеркалит scoped DataGrid `.dir-search{max-width:360px}`. */
.mud-input-control.dir-search {
    max-width: 360px;
}

.dir-count {
    margin-left: 12px;
    white-space: nowrap;
    font-size: 12.5px;
    color: var(--text-3);
    font-weight: 600;
}
.dir-count .num { color: var(--text); font-weight: 700; }

/* ---------- Tabs row (segmented + action) ---------- */
.dir-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.dir-tabs .seg button .tab-n {
    margin-left: 6px;
    font-size: 11px;
    color: var(--text-4);
    font-weight: 700;
}

.dir-tabs .seg button.active .tab-n { color: var(--acc-text); }

/* ---------- Table cells ---------- */
.dir-card { padding: 0; overflow: hidden; }

.cell-id { display: flex; align-items: center; gap: 11px; min-width: 0; }

.ava {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-weight: 800;
    font-size: 13.5px;
    color: hsl(var(--seed, 150) 48% 42%);
    background: hsl(var(--seed, 150) 50% 50% / .14);
}

.ava.round { border-radius: 50%; }

html[data-theme="dark"] .ava {
    color: hsl(var(--seed, 150) 65% 68%);
    background: hsl(var(--seed, 150) 45% 60% / .16);
}

.ci-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ci-name { font-weight: 700; font-size: 13.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-sub { font-size: 11px; color: var(--text-4); }

.count-pill {
    display: inline-block;
    min-width: 26px;
    text-align: center;
    padding: 2px 8px;
    border-radius: 7px;
    background: var(--card-2);
    border: 1px solid var(--hair);
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-2);
}

.dim { color: var(--text-3); }
.mono-id { color: var(--text-4); letter-spacing: .01em; }
.ta-r { text-align: right; }

/* role tags inside a cell */
.roles { display: flex; flex-wrap: wrap; gap: 5px; }
.role-tag {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--acc-soft);
    color: var(--acc-text);
}
.role-tag.muted { background: var(--card-2); color: var(--text-4); border: 1px solid var(--hair); }

/* ---------- Loading skeleton ---------- */
.dir-skeleton { padding: 8px 0; }
.sk-row {
    height: 22px;
    margin: 13px 18px;
    border-radius: 7px;
    background: linear-gradient(90deg, var(--card-2) 25%, var(--hair) 37%, var(--card-2) 63%);
    background-size: 400% 100%;
    animation: sk 1.3s ease infinite;
}

@keyframes sk {
    from { background-position: 100% 50%; }
    to { background-position: 0 50%; }
}

/* ---------- Empty state ---------- */
.dir-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 7px;
    padding: 48px 24px;
}

.de-badge {
    width: 54px;
    height: 54px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    background: var(--acc-soft);
    color: var(--acc-text);
    margin-bottom: 6px;
}

.de-t { font: var(--t-h3); font-size: 16px; }
.de-s { font-size: 13px; color: var(--text-3); max-width: 44ch; line-height: 1.5; margin-bottom: 10px; }

@media (max-width: 640px) {
    .directory { padding: 22px 16px 56px; }
    .ci-sub, .mono-id { display: none; }
}

/* ---------- Modal create/invite (поверх .modal/.modal-scrim из theme.css) ---------- */
.dir-modal { position: relative; width: 560px; }

/* фирменная акцент-полоса по верхней кромке */
.dir-modal-accent {
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--acc), var(--c2) 70%, var(--c4));
    opacity: .9;
    z-index: 1;
}

.modal-x {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    color: var(--text-3);
    background: transparent;
    border: 1px solid transparent;
    transition: all .14s;
}

.modal-x:hover { background: var(--card-2); color: var(--text); border-color: var(--hair); }

/* ---------- Form scaffolding (общее для модальных форм) ---------- */
.field-group { margin-bottom: 14px; }

.card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.field-group .validation-message {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--dang);
}

/* ---------- Role picker ---------- */
.role-picker { display: flex; flex-direction: column; gap: 8px; }

.role-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    text-align: left;
    background: var(--card-2);
    border: 1.5px solid var(--hair);
    transition: all .15s;
    cursor: pointer;
    width: 100%;
}

.role-option.selected { background: var(--acc-soft); border-color: var(--acc); }

.role-radio {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 5px solid var(--hair-strong);
    background: var(--card);
    transition: border-color .15s;
}

.role-option.selected .role-radio { border-color: var(--acc); }
.role-text { flex: 1; }
.role-name { display: block; font-weight: 700; font-size: 13.5px; color: var(--text); }
.role-desc { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ---------- Success state inside modal ---------- */
.form-done { display: flex; flex-direction: column; }

.fd-badge {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: var(--acc-soft);
    color: var(--acc-text);
    margin-bottom: 12px;
}

.fd-t { font: var(--t-h3); font-size: 16px; }
.fd-s { font-size: 13px; color: var(--text-3); margin: 3px 0 16px; line-height: 1.5; }

.result-list { display: flex; flex-direction: column; gap: 12px; margin: 0; }

.result-list > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--hair);
}

.result-list > div:last-child { border-bottom: none; padding-bottom: 0; }
.result-list dt { font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.result-list dd {
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    text-align: right;
    word-break: break-all;
}

/* ---------- Ukraine admin area map (Регіони) — GLOBAL because the SVG is built via RenderTreeBuilder
   (no scoped-css attribute reaches the <path>s). ---------- */
.ua-map { width: 100%; height: auto; display: block; }
.ua-ob {
    fill: var(--card-2);
    stroke: var(--hair-strong);
    stroke-width: 1.6;
    stroke-linejoin: round;
    cursor: pointer;
    transition: fill .14s ease, stroke .14s ease, filter .14s ease;
    outline: none;
}
.ua-ob:hover, .ua-ob:focus-visible { fill: var(--acc-soft); stroke: var(--acc); }
.ua-ob.has { fill: var(--acc-soft); stroke: var(--acc); }
.ua-ob.has:hover, .ua-ob.has:focus-visible { fill: var(--acc); stroke: var(--acc-2); }
.ua-ob.sel { fill: var(--acc); stroke: var(--acc-2); filter: drop-shadow(0 1px 4px rgba(0,0,0,.18)); }
.ua-ob[data-code="kyiv-city"] { stroke-width: 2.2; }

/* FitViewport-hook: страница с DataGrid(FitViewport=true) добавляет этот класс к .page,
   чтобы отключить скролл на уровне страницы (скролл только внутри зоны строк грида).
   Использование: добавить class="page--fit-grid" на корневой элемент страницы-списка. */
.page.page--fit-grid {
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Список на весь екран (.directory.dir-fit) ──
   Сторінки-списки додають клас `dir-fit` на корінь `.directory`. Тоді сторінка (.page) не
   скролиться, а сама `.directory` стає flex-колонкою на всю висоту контенту: PageHeader
   зверху фіксований, DataGrid (.dg-root.dg-fit) забирає решту й скролить ЛИШЕ зону рядків
   (sticky-шапка + пейджер лишаються на місці). :has — щоб не чіпати не-спискові .page-сторінки.
   ErrorBoundary рендерить контент без обгортки, тож .directory — прямий нащадок .page. */
.page:has(> .directory.dir-fit),
.page:has(.directory.dir-fit) {
    overflow: hidden;
}

.directory.dir-fit {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
}

/* За замовчуванням діти не ростуть (PageHeader, чипи тощо); залишок забирає грід АБО вкладки. */
.directory.dir-fit > * {
    flex: 0 0 auto;
}

.directory.dir-fit > .dg-root,
.directory.dir-fit > .mud-tabs {
    flex: 1 1 auto;
    min-height: 0;
}

/* ── Fit крізь MudTabs (сторінка «Персонал»: зовнішні + вкладені вкладки) ──
   Кожен рівень .mud-tabs стає flex-колонкою на всю висоту; зона панелей забирає залишок,
   активна панель — flex-колонка, всередині якої грід (.dg-fit) фітиться й скролить рядки. */
.directory.dir-fit .mud-tabs {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.directory.dir-fit .mud-tabs > .mud-tabs-panels {
    flex: 1 1 auto;
    min-height: 0;
}

.directory.dir-fit .mud-tabs .mud-tab-panel {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Єдиний скрол — зона рядків (.dg-table-zone). Внутрішній .mud-table-container НЕ скролить
   (overflow:visible), тож найближчим скрол-предком шапки стає .dg-table-zone — і sticky-шапка
   липне саме до неї. Правило ГЛОБАЛЬНЕ (scoped ::deep до thead MudDataGrid не доїжджає, тому
   аналог у DataGrid.razor.css не спрацьовував). Лише для FitViewport-гридів (.dg-fit). */
.dg-root.dg-fit .mud-table-container { overflow: visible; }

.dg-root.dg-fit .dir-grid thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--card);
}
