﻿.scrollbar__invisible {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
    .scrollbar__invisible::-webkit-scrollbar {
        display: none;
    }

/* States */
[disabled] {
    opacity: 0.6;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* COLLECTION VIEW */

.collection-view {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.collection-view__items {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: auto;
    width: 100%;
    max-width: 100%;
}

.collection-view__item {
    position: relative;
    transition: all 0.2s ease;
}

.collection-view__item--selectable {
    cursor: pointer;
}

    .collection-view__item--selectable:hover {
        background-color: var(--accent-soft);
        border-color: var(--accent-line);
    }

.collection-view__item--selected {
    background-color: var(--blue-100);
    border-color: var(--accent);
}

.collection-view__item-selected {
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 20px 20px 0;
    border-color: transparent var(--accent) transparent transparent;
}

.collection-view__separator {
    height: 1px;
    background-color: var(--ink-300);
    margin: 0.5rem 0;
}

/* Grid layout */
.collection-view--grid .collection-view__item {
    break-inside: avoid;
}

/* Horizontal scroll */
.collection-view--horizontal {
    overflow-x: auto;
    flex-wrap: nowrap;
}

/* Virtualized styles */
.virtualized-collection-view {
    height: 100%;
    position: relative;
}

    .virtualized-collection-view .virtualized-container {
        height: 100%;
        overflow-y: auto;
    }

/* LAYOUTS */
.layout-container {
    box-sizing: border-box;
    position: relative;
}

.layout-content {
    display: flex;
}

.layout-item {
    transition: all 0.2s ease;
}

.layout-item--selectable {
    cursor: pointer;
}

    .layout-item--selectable:hover {
        background-color: var(--accent-soft);
    }

.layout-item--selected {
    background-color: var(--blue-100);
    border-color: var(--accent);
}

/* HorizontalLayout  */
.horizontal-layout {
    width: 100%;
}

.horizontal-layout__content-wrapper {
    position: relative;
    width: 100%;
}

.horizontal-layout__virtualized {
    display: flex;
    flex-direction: row;
}

.horizontal-layout__item {
    flex-shrink: 0;
}

/* Vertical scrolling with indicators */
.horizontal-layout--scrollable {
    position: relative;
}

    .horizontal-layout--scrollable::-webkit-scrollbar {
        height: 8px;
    }

    .horizontal-layout--scrollable::-webkit-scrollbar-track {
        background: var(--ink-100);
        border-radius: 4px;
    }

    .horizontal-layout--scrollable::-webkit-scrollbar-thumb {
        background: var(--ink-300);
        border-radius: 4px;
    }

        .horizontal-layout--scrollable::-webkit-scrollbar-thumb:hover {
            background: var(--ink-400);
        }

.scroll-indicator {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 5;
}

.scroll-btn {
    pointer-events: all;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: white;
    border: 1px solid var(--ink-300);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s ease;
}

    .scroll-btn:hover:not(:disabled) {
        background: var(--surface);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    }

    .scroll-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

.scroll-prev {
    margin-left: 10px;
}

.scroll-next {
    margin-right: 10px;
}

/* VerticalLayout */
.vertical-layout {
    height: 100%;
}

.vertical-layout__content-wrapper {
    flex: 1;
    overflow: hidden;
}

.vertical-layout__item {
    width: 100%;
}

/* Adaptive стили */
@media (max-width: 768px) {
    .horizontal-layout__item {
        min-width: 150px !important;
    }

    .scroll-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .horizontal-layout--scrollable .layout-content {
        flex-wrap: wrap;
    }

    .horizontal-layout__item {
        flex: 1 0 100%;
    }
}

/* Animations */
.layout-item-enter {
    opacity: 0;
    transform: translateY(10px);
}

.layout-item-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 300ms, transform 300ms;
}

.layout-item-exit {
    opacity: 1;
}

.layout-item-exit-active {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 300ms, transform 300ms;
}

.tco-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(22, 30, 57, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;

    z-index: var(--z-modal);
}

.tco-dialog {
    position: relative;
    background: #FFFFFF;
    border-radius: 20px;
    padding: 28px 24px 24px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 48px rgba(22, 30, 57, .25);
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: center;
    box-sizing: border-box;
}

.tco-dialog__close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--gray-500);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color .15s ease;
}

    .tco-dialog__close:hover { background: var(--gray-200); }

.tco-dialog__title {
    font-family: var(--third-family);
    font-weight: 700;
    font-size: 18px;
    color: var(--text-dark-color);
    margin: 4px 16px 0 16px;
}

.tco-dialog__sub {
    font-family: var(--font-family);
    font-weight: 500;
    font-size: 14px;
    color: var(--gray-600);
    margin: 0;
    word-break: break-word;
}

.tco-dialog__actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.tco-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 16px;
    min-height: 48px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 15px;
    transition: filter .15s ease, background-color .15s ease, transform .1s ease;
}

    .tco-btn:hover:not(:disabled) { filter: brightness(1.05); }
    .tco-btn:active:not(:disabled) { transform: scale(.98); }

.tco-btn--primary {
    background: var(--accent-action);
    color: #FFFFFF;
}

.tco-btn--ghost {
    background: var(--gray-200);
    color: var(--text-dark-color);
}

/* ===================== Toasts (service layer, batch A) ===================== */
.toasts {
    position: fixed;
    right: var(--s-6);
    bottom: var(--s-6);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    align-items: flex-end;
    pointer-events: none;
}

@media (max-width: 767px) {
    .toasts {
        left: var(--s-3);
        right: var(--s-3);
        bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s-3));
        align-items: stretch;
    }
}

.toast {
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-width: 280px;
    max-width: 400px;
    background: var(--surface-inverse);
    color: var(--white);
    border-radius: var(--r-md);
    padding: var(--s-3) var(--s-4);
    box-shadow: var(--elev-3);
    font-family: var(--font-ui);
    animation: toast-in var(--d-base) var(--ease-out);
}

    .toast::before {
        content: "";
        position: absolute;
        left: 0;
        top: 10px;
        bottom: 10px;
        width: var(--edge);
        border-radius: 0 var(--edge) var(--edge) 0;
        background: var(--toast-mark, var(--info-mark));
    }

.toast--success { --toast-mark: var(--success-mark); }
.toast--danger { --toast-mark: var(--danger-mark); }
.toast--info { --toast-mark: var(--info-mark); }

.toast__icon {
    flex: 0 0 auto;
    display: flex;
    color: var(--toast-mark);
}

/* The body takes the free width so the close button always sits at the right edge. */
.toast__body {
    flex: 1 1 auto;
    min-width: 0;
}

.toast__title {
    margin: 0;
    font-weight: var(--w-semi);
    font-size: var(--t-sub);
    line-height: var(--t-sub-lh);
}

.toast__sub {
    margin: 1px 0 0;
    color: rgba(255, 255, 255, .78);
    font-size: var(--t-cap);
    line-height: var(--t-cap-lh);
}

.toast__close {
    flex: 0 0 auto;
    margin: -6px -8px -6px 0;
    width: 32px;
    height: 32px;
    border-radius: var(--r-xs);
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, .6);
    display: grid;
    place-items: center;
}

@media (hover: hover) {
    .toast__close:hover {
        color: var(--white);
        background: rgba(255, 255, 255, .10);
    }
}

.toast--leaving {
    animation: toast-out 140ms var(--ease-in) forwards;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

@keyframes toast-out {
    to { opacity: 0; transform: translateY(6px); }
}

@media (prefers-reduced-motion: reduce) {
    .toast, .toast--leaving { animation: none; }
}

/* ===================== Section error state (batch A) ===================== */
.sec-err {
    position: relative;
    display: flex;
    gap: var(--s-4);
    align-items: flex-start;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: var(--s-5);
    box-shadow: var(--elev-1);
}

    .sec-err::before {
        content: "";
        position: absolute;
        left: 0;
        top: 14px;
        bottom: 14px;
        width: var(--edge);
        border-radius: 0 var(--edge) var(--edge) 0;
        background: var(--danger-mark);
    }

.sec-err--warn::before {
    background: var(--warning-mark);
}

.sec-err--warn .sec-err__icon {
    background: var(--warning-soft);
    color: var(--warning);
}

.sec-err__icon {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: var(--r-sm);
    background: var(--danger-soft);
    color: var(--danger);
    display: grid;
    place-items: center;
}

.sec-err__body {
    min-width: 0;
}

.sec-err__title {
    margin: 0;
    font-weight: var(--w-semi);
    font-size: var(--t-ui);
    color: var(--text-primary);
}

.sec-err__sub {
    margin: 2px 0 0;
    color: var(--text-secondary);
    font-size: var(--t-sub);
    line-height: var(--t-sub-lh);
    max-width: 56ch;
}

.sec-err__actions {
    display: flex;
    gap: var(--s-2);
    margin-top: var(--s-3);
    flex-wrap: wrap;
}

/* ---------- Section head (search, library, my tests) ---------- */

.sr-section {
    display: grid;
    gap: var(--s-3);
}

.sr-section__head {
    display: flex;
    align-items: baseline;
    gap: var(--s-2);
}

.sr-section__title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: var(--w-semi);
    font-size: var(--t-head);
    letter-spacing: var(--track-tight);
    color: var(--text-primary);
}

.sr-section__count {
    color: var(--text-tertiary);
    font-size: var(--t-cap);
    font-weight: var(--w-semi);
    font-variant-numeric: tabular-nums;
}

.sr-section__all {
    margin-left: auto;
    border: none;
    background: none;
    padding: 0;
    color: var(--accent-action);
    font-family: var(--font-ui);
    font-size: var(--t-sub);
    font-weight: var(--w-semi);
    cursor: pointer;
}

@media (hover: hover) {
    .sr-section__all:hover {
        text-decoration: underline;
    }
}


/* ===================== Page top bar =====================
   The page's own header (not the site header): first in the content column,
   full column width. Back, the path above the title, actions on the right.
   Content follows directly on --surface; there is no shared white sheet. */
.pbar {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 76px;
    box-sizing: border-box;
    padding: 14px 16px;
    border-radius: 20px;
    background: var(--surface-raised);
    box-shadow: 0 2px 10px rgba(22, 30, 57, 0.06);
}

/* Root sections (Мои тесты, Библиотека) have no way back and no path: the title and the
   actions stand straight on the surface without the bar card. */
.pbar--plain {
    min-height: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

    .pbar--plain .pbar__title {
        font-size: var(--t-display);
        line-height: var(--t-display-lh);
    }

.pbar__back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    background: var(--surface-sunken);
    color: var(--text-primary);
    cursor: pointer;
    transition: background-color .15s ease;
}

    .pbar__back:hover {
        background: var(--ink-200);
    }

.pbar__heading {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 auto;
    min-width: 0;
}

.pbar__crumbs {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}

.pbar__crumb {
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
    text-decoration: none;
}

a.pbar__crumb:hover {
    color: var(--accent-hover);
}

.pbar__sep {
    flex: 0 0 auto;
    color: var(--text-disabled);
}

/* The path over a coloured cover that acts as the page bar. */
.pbar__crumbs--on-color .pbar__crumb,
.pbar__crumbs--on-color .pbar__sep {
    color: rgba(255, 255, 255, .85);
}

.pbar__crumbs--on-color a.pbar__crumb:hover {
    color: #FFFFFF;
    text-decoration: underline;
}

.pbar__eyebrow {
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: var(--track-caps);
    text-transform: uppercase;
    color: var(--accent-action);
}

.pbar__title {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: var(--track-tight);
    color: var(--text-primary);
}

.pbar__sub {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--text-secondary);
}

.pbar__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    flex: 0 0 auto;
}

/* Buttons that live in a page bar. */
.pbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    box-sizing: border-box;
    border: none;
    border-radius: 12px;
    background: var(--surface-sunken);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s ease, opacity .15s ease;
}

    .pbar-btn:hover {
        background: var(--ink-200);
        color: var(--text-primary);
    }

    .pbar-btn:disabled {
        opacity: .5;
        cursor: default;
    }

.pbar-btn--primary {
    background: var(--accent-action);
    color: var(--text-on-accent);
}

    .pbar-btn--primary:hover {
        background: var(--accent-hover);
        color: var(--text-on-accent);
    }

.pbar-btn--danger {
    background: var(--danger-soft);
    color: var(--danger);
}

    .pbar-btn--danger:hover {
        background: var(--red-100);
        color: var(--red-700);
        opacity: .85;
    }

.pbar-btn--icon {
    width: 44px;
    padding: 0;
}

.pbar-btn--busy {
    opacity: .6;
    pointer-events: none;
}

/* A search field placed among the bar actions. */
.pbar .mt-list-search {
    width: 280px;
}

    .pbar .mt-list-search-input {
        height: 44px;
    }

.pbar-badge {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    border-radius: var(--r-full);
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    background: var(--info-soft);
    color: var(--text-on-soft);
}

.pbar-badge--ok {
    background: var(--success-soft);
    color: var(--success);
}

/* Phones: only the nearest parent stays in the path, actions wrap under the title. */
@media (max-width: 767.98px) {
    .pbar {
        flex-wrap: wrap;
        gap: 12px;
        min-height: 0;
        padding: 12px;
    }

    .pbar__title {
        font-size: 20px;
    }

    .pbar__crumbs > :not(:last-child) {
        display: none;
    }

    .pbar-btn__label:not(:only-child) {
        display: none;
    }

    .pbar .mt-list-search {
        flex: 1 1 100%;
        width: 100%;
    }

    .pbar__actions {
        flex: 1 1 100%;
        justify-content: flex-start;
    }

    .pbar__actions:empty {
        display: none;
    }

    .pbar-btn {
        height: 40px;
        padding: 0 14px;
        font-size: 14px;
    }

    .pbar-btn--icon {
        width: 40px;
        padding: 0;
    }
}
