/*
    Shell for every portal (GNTPortalLayout, Sabre.Shared.Web/Components/Portal).
    These rules were previously copied into each of the seven portal layouts as
    .{portal}-layout-* blocks. A portal layout now keeps only rules that are genuinely its own
    (page fill for its page classes, a nav or content tint) — never the grid or chrome.
*/

.gnt-portal-layout {
    display: grid;
    grid-template-rows: minmax(50px, auto) minmax(0, 1fr);
    grid-template-areas:
        "header"
        "body";
    height: 100%;
    width: 100%;
    min-width: 0;
    align-items: stretch;
    justify-items: stretch;
    position: relative;
    box-sizing: border-box;
}

.gnt-portal-layout--with-footer {
    grid-template-rows: minmax(50px, auto) minmax(0, 1fr) auto;
    grid-template-areas:
        "header"
        "body"
        "footer";
}

/* The shell is the document root (Platform), so it sizes to the viewport itself. */
.gnt-portal-layout--viewport {
    height: calc(100vh / var(--gnt-zoom));
    height: calc(100dvh / var(--gnt-zoom));
    min-height: calc(100vh / var(--gnt-zoom));
    min-height: calc(100dvh / var(--gnt-zoom));
    max-height: calc(100vh / var(--gnt-zoom));
    max-height: calc(100dvh / var(--gnt-zoom));
    overflow: hidden;
}

.gnt-portal-layout__hosts {
    grid-area: header;
    min-height: 0;
}

.gnt-portal-layout__header {
    grid-area: header;
    background: var(--sabre-chrome-bg);
    color: var(--sabre-chrome-fg);
    border-bottom: 1px solid var(--sabre-chrome-border);
    min-height: 0;
}

.gnt-portal-layout__body {
    grid-area: body;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    align-items: stretch;
    align-content: stretch;
    min-height: 0;
    min-width: 0;
    height: 100%;
    overflow: hidden;
}

.gnt-portal-layout__body--wide {
    grid-template-columns: minmax(0, 1fr);
}

.gnt-portal-layout__nav {
    border-right: 1px solid var(--gnt-border-color);
    overflow: auto;
    min-height: 0;
    height: 100%;
}

/* ResizableNav: the splitter fills the body and its bar is the nav/content separator. */
.gnt-portal-layout__body--split {
    grid-template-columns: minmax(0, 1fr);
}

.gnt-portal-layout__splitter.e-splitter {
    border: 0;
}

.gnt-portal-layout__splitter > .e-pane {
    min-height: 0;
    overflow: hidden;
}

.gnt-portal-layout__splitter .gnt-portal-layout__nav {
    border-right: 0;
    overflow: hidden;
}

/* GNTPortalNavMenu: search box pinned at the top, the command list scrolls under it. */
.gnt-portal-nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    height: 100%;
    min-height: 0;
    padding: 0.5rem;
    box-sizing: border-box;
}

.gnt-portal-nav__title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0 0 0.35rem 0.15rem;
}

.gnt-portal-nav__search.e-input {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    margin-bottom: 0.35rem;
}

.gnt-portal-nav__list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Collapse all / Expand all: one quiet link-sized button under the search, right-aligned. */
.gnt-portal-nav__fold-all {
    display: flex;
    justify-content: flex-end;
    flex: 0 0 auto;
    margin: -0.2rem 0 0.1rem 0;
}

.gnt-portal-nav__fold-all .e-btn {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    color: var(--gnt-text-tertiary);
}

/* The list scrolls; its rows keep their natural height instead of shrinking to fit. */
.gnt-portal-nav__list > *,
.gnt-portal-nav__section > *,
.gnt-portal-nav__children > * {
    flex: 0 0 auto;
}

.gnt-portal-nav__section,
.gnt-portal-nav__children {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

/* Group heading: a fold toggle for the section under it. */
.gnt-portal-nav__group {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    margin: 0.55rem 0 0 0;
    padding: 0.25rem 0.4rem;
    border: 0;
    border-radius: 4px;
    background: transparent;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
    color: var(--gnt-text-tertiary);
    cursor: pointer;
}

.gnt-portal-nav__group:hover {
    background: var(--gnt-surface-2);
}

.gnt-portal-nav__chevron {
    flex: 0 0 auto;
    width: 0.4rem;
    height: 0.4rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.12s ease;
}

.gnt-portal-nav__chevron--open {
    transform: rotate(45deg);
}

/* Tree guide: the section's links sit indented behind a thin rule. */
.gnt-portal-nav__children {
    margin-left: 0.65rem;
    padding-left: 0.35rem;
    border-left: 1px solid var(--gnt-border-color);
}

.gnt-portal-nav__link {
    display: block;
    padding: 0.4rem 0.65rem;
    border-radius: 4px;
    color: inherit;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gnt-portal-nav__link--home {
    font-weight: 600;
}

.gnt-portal-nav__link:hover {
    background: var(--gnt-surface-2);
    color: inherit;
}

.gnt-portal-nav__link.active {
    background: var(--gnt-primary-tint);
    color: var(--gnt-primary-strong);
    font-weight: 600;
}

.gnt-portal-nav__empty {
    padding: 0.4rem 0.65rem;
    font-size: 0.85rem;
    color: var(--gnt-text-tertiary);
}

.gnt-portal-layout__content {
    display: flex;
    flex-direction: column;
    align-self: stretch;
    min-height: 0;
    min-width: 0;
    height: 100%;
    overflow: auto;
    padding: 0.75rem;
    box-sizing: border-box;
}

/* The tab workspace owns its own scrolling and gives each tab its padding (main-tabs.css);
   a padded, scrolling pane around it double-scrolls the grid. */
.gnt-portal-layout__content--tabbed {
    padding: 0;
    overflow: hidden;
}

.gnt-portal-layout__content--tabbed > .main-data-root {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
}

/* Descendant, not direct child: in a tabbed pane the grid sits inside the tab host. */
.gnt-portal-layout__content .gnt-grid-selector-root {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
}

.gnt-portal-layout__content-footer {
    flex: 0 0 auto;
}

.gnt-portal-layout__content--tabbed > .gnt-portal-layout__content-footer {
    padding: 0 0.75rem;
}

.gnt-portal-layout__footer {
    grid-area: footer;
    /* The build watermark and the environment badge pin themselves to the footer's two ends. */
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 2px 12px;
    font-size: 0.8rem;
    background: var(--sabre-chrome-bg);
    color: var(--sabre-chrome-fg-muted);
    border-top: 1px solid var(--sabre-chrome-border);
}

/* Centres a portal's not-authorized message; the message itself stays portal-specific. */
.gnt-portal-denied {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 1rem;
}

/* The nav follows the per-user density (html[data-gnt-density], footer tool tray). Normal is the stock size. */
html[data-gnt-density="Compact"] .gnt-portal-nav__link { padding-top: 0.15rem; padding-bottom: 0.15rem; }
html[data-gnt-density="Compact"] .gnt-portal-nav__group { margin-top: 0.3rem; padding-top: 0.1rem; padding-bottom: 0.1rem; }
html[data-gnt-density="Comfortable"] .gnt-portal-nav__link { padding-top: 0.65rem; padding-bottom: 0.65rem; }
html[data-gnt-density="Comfortable"] .gnt-portal-nav__group { margin-top: 0.8rem; }
