/* App pages grid layout (base_app_v3.html.twig).
   Tokens: --color-* from dynamic.css. */

:root {
    --app-sidebar-width: 336px;
    --app-sidebar-collapsed-width: 72px;
    --app-content-max-width: 1920px;
}

/* Body flex column — gives .app-layout explicit height so 1fr grid rows work */
body:has(.app-layout) {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Center the 1920px layout on very wide viewports */
@media (min-width: 1921px) {
    body:has(.app-layout) {
        align-items: center;
    }
    body:has(.app-layout) .app-footer {
        align-self: stretch; /* footer must remain full viewport width */
    }
}

/* === Grid layout === */
.app-layout {
    display: grid;
    grid-template-columns: var(--app-sidebar-width) 1fr;
    grid-template-rows: 1fr;
    flex: 1; /* grow to fill body → gives grid explicit height for 1fr rows */
    max-width: 1920px;
    width: 100%;
    transition: grid-template-columns .25s ease;
}

.app-layout--collapsed {
    grid-template-columns: var(--app-sidebar-collapsed-width) 1fr;
}

.app-sidebar {
    grid-row: 1 / 2;
    grid-column: 1 / 2;
}

.app-main {
    grid-row: 1 / 2;
    grid-column: 2 / 3;
    min-width: 0;
    background: var(--color-surface-dashboard, #EEF2FC);
}


/* === App content === */
.app-content {
    padding: 40px 60px;
}

/* === Welcome banner === */
.app-welcome-banner {
    margin-bottom: 24px;
}

.app-welcome-banner__inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.app-welcome-banner__text {
    flex: 1;
    min-width: 0;
}

/* Right-side action area: page buttons + help button in one row */
.app-welcome-banner__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.app-welcome-banner__actions .property-color-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid var(--color-border);
}

/* .app-breadcrumbs — стиль централизованного компонента _breadcrumbs.html.twig
   перенесён в канон components.css (TD-61: CSS компонента — в едином каноне,
   грузится везде, включая external-лейаут). */

.app-welcome-banner__title {
    font-family: 'Inter', sans-serif;
    font-size: var(--font-size-9xl);
    font-weight: var(--font-weight-bold);
    margin: 0 0 12px;
    color: var(--color-text);
    line-height: var(--line-height-tight);
    letter-spacing: -0.03em;
}

.app-welcome-banner__description {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: var(--font-size-lg);
    font-family: 'Inter', sans-serif;
    line-height: var(--line-height-normal);
}

/* === Mobile topbar (hidden on desktop) === */
.app-topbar {
    display: none;
}

/* === Footer === */
.app-footer {
    background: var(--color-text);
    padding: 32px 40px;
}

.app-footer__logo {
    display: flex;
    flex-shrink: 0;
    text-decoration: none;
}

.app-footer__logo svg {
    display: block;
    height: 90px;
    width: auto;
}

.app-footer__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 1920px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.app-footer__nav {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}

.app-footer__link {
    color: var(--color-white);
    text-decoration: none;
    font-size: var(--font-size-base);
    opacity: .7;
    transition: opacity .2s;
}

.app-footer__link:hover {
    opacity: 1;
}

.app-footer__copy {
    color: var(--color-white);
    opacity: .5;
    font-size: var(--font-size-sm);
}

/* === Narrow desktop (768–1199px): always collapsed grid === */
@media (min-width: 768px) and (max-width: 1199px) {
    .app-layout,
    .app-layout--collapsed {
        grid-template-columns: var(--app-sidebar-collapsed-width) 1fr;
        position: relative; /* anchor for sidebar absolute overlay on hover */
    }
}

/* === Print === */
@media print {
    /* Скрыть навигационные элементы — при печати не нужны */
    .app-sidebar,
    .app-sidebar__toggle,
    .app-topbar,
    .app-footer {
        display: none !important;
    }

    /* Сбросить grid на block-layout — .app-main займёт всю ширину */
    .app-layout,
    .app-layout--collapsed {
        display: block !important;
    }

    /* Контент на всю ширину без отступа под колонку сайдбара */
    .app-main {
        width: 100% !important;
        margin: 0 !important;
        /* grid-column переопределять не нужно: display:block на родителе убирает grid */
    }

    /* Снять ограничение max-width у контента */
    .app-content {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
    }
}

/* === Mobile (< 768px) === */
@media (max-width: 767px) {
    .app-layout,
    .app-layout--collapsed {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        grid-column: 1 / 2;
    }

    .app-main {
        grid-column: 1 / 2;
    }

    .app-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 2px 16px;
        background: var(--color-white);
        border-bottom: 1px solid var(--color-border-card, rgba(20, 28, 48, .08));
        position: relative;
        z-index: 400;
    }

    .app-content {
        padding: 20px 20px;
    }

    /* TASK-000517: на узком экране кнопки шапки уезжают в собственную строку —
       в одну строку с заголовком они его перекрывали (стало заметно после
       добавления переключателя языка к help-кнопке и фильтрам страницы).
       column-reverse: ряд контролов идёт НАД заголовком — на мобиле он
       ближе к шапке приложения и не отодвигает заголовок от контента.

       Trade-off (осознанный): визуальный порядок здесь расходится с DOM, то есть
       Tab с хлебных крошек уходит визуально вверх. Починить это перестановкой
       разметки нельзя — DOM-порядок [actions, text] потребовал бы row-reverse на
       десктопе и перенёс бы то же расхождение туда, где фокусируемых элементов в
       actions больше (кнопки страницы), то есть задело бы больше пользователей. */
    .app-welcome-banner__inner {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 16px;
    }

    .app-welcome-banner__actions {
        justify-content: flex-start;
    }

    .app-welcome-banner__title {
        font-size: var(--font-size-6xl);
        letter-spacing: -0.02em;
    }

    .app-footer {
        padding: 20px 16px;
    }

    .app-footer__nav {
        gap: 12px;
    }
}
