/*
 * App frame on alignvu UI v2.1 (css/vendor/alignvu_ui_v2.css): top bar, sidebar, page header and main column.
 * Loaded after the screen stylesheets. Screens use the variables below instead of fixed frame sizes:
 *   --app-sidebar-width  the sidebar's current width (240px, 64px when folded)
 *   --app-sticky-top     where sticky content starts: below the top bar and the sticky page header
 *                        (kept up to date by js/modules/shared/shell.js)
 *   --app-main-pad-x     the main column's side padding
 */

:root {
    --app-sidebar-width: var(--sidebar);
    --app-sticky-top: 150px;
    --app-main-pad-x: var(--space-8);
}

@media (max-width: 1099px) {
    :root {
        --app-sidebar-width: 64px;
    }
}

@media (max-width: 819px) {
    :root {
        --app-main-pad-x: 16px;
    }
}

body {
    background-color: var(--paper);
}

.app-shell {
    min-height: 100vh;
}

/* ---------- Top bar ---------- */

.av-topbar.head-nav {
    position: sticky;
    top: 0;
    z-index: 9998; /* above page content and the filter panel (9997); pop-ups use 9999 and up */
    height: var(--header-height);
    gap: 24px;
}

.app-topbar__search {
    flex: 1 1 auto;
    max-width: 640px;
    min-width: 0;
    margin-left: auto;   /* on the right, beside the account menu; the environment sits by the logo */
}

.av-topbar.head-nav .av-topbar__status {
    margin-left: 0;
    flex: none;
}

.av-topbar .search-bar {
    min-width: 0;
    width: 100%;
    height: var(--control-height);
    border: 1px solid var(--muted);
    border-radius: var(--radius-sm);
    box-shadow: none;
    background: var(--surface);
}

.av-topbar .search-bar select,
.av-topbar .search-bar input[type="search"] {
    height: 100%;
    font: 400 14px/20px var(--font-display);
    border-radius: 0;
}

.av-topbar .search-bar select {
    width: auto;
    max-width: 150px;
    padding: 0 8px 0 12px;
    color: var(--body-ink);
    background: var(--day-band);
    border-right: 1px solid var(--border);
}

.app-topbar__searchbutton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 100%;
    border: none;
    background: none;
    color: var(--heading-ink);
    cursor: pointer;
}

.av-topbar .search-results-container {
    left: auto;
    right: 0;   /* the search is on the right: the suggestions open leftwards from its right edge */
    top: calc(var(--control-height) + 6px);
    width: min(720px, calc(100vw - var(--app-sidebar-width) - 48px));
}

.app-topbar__end {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: none;
}

.app-usermenu {
    position: relative;
}

.app-usermenu__button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: var(--control-height);
    padding: 0 8px;
    border: none;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--heading-ink);
    font: 400 14px/20px var(--font-display);
    cursor: pointer;
}

.app-usermenu__button:hover,
.app-usermenu__button.active {
    background: var(--fill);
}

.app-usermenu__list {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 180px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(26, 26, 46, 0.12);
    z-index: 1001;
}

/* ---------- Sidebar ---------- */

.av-sidebar.navigation {
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    z-index: 9997; /* above the page (a folded section's menu opens over it), under the top bar so the search
                      suggestions open over the sidebar */
}

.navigation .av-navitem {
    cursor: pointer;
}

.navigation .nav.active {
    background: var(--fill);
    color: var(--heading-ink);
    font-weight: 600;
}

.navigation .nav.nav-disabled {
    color: var(--muted);
    opacity: 0.6;
    pointer-events: none;
}

.navigation .application-steps {
    padding: 2px 0 6px 30px;
}

.application-steps .module-nav-item {
    margin: 0;
}

.application-steps .module-nav-item p {
    margin: 0;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font: 400 13px/18px var(--font-display);
    color: var(--body-ink);
    cursor: pointer;
}

.application-steps .module-nav-item p:hover {
    background: var(--fill);
}

.application-steps .module-nav-item.active p {
    background: var(--fill);
    color: var(--heading-ink);
    font-weight: 600;
}

.application-steps .module-nav-item.active {
    pointer-events: none;
}

.application-steps .module-nav-item.nav-disabled p {
    color: var(--muted);
    opacity: 0.6;
    cursor: default;
}

.application-steps .module-nav-item.nav-disabled {
    pointer-events: none;
}

.application-steps .sub-nav,
.application-steps .module-nav-item.module-nav-child {
    padding-left: 12px;
}

/* a step under the item above it (views.js navIndent, e.g. Setup Schedule's Feeds and Delivery) */
.application-steps .module-nav-item.module-nav-step {
    padding-left: 24px;
}

.navigation .nav-footer p {
    margin: 0 0 6px;
    font: 400 12px/18px var(--font-display);
    color: var(--muted);
}

.app-linkbutton {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    color: var(--body-ink);
    text-decoration: underline;
    cursor: pointer;
}

/* Folded sidebar: a section's menu opens beside its icon */
@media (max-width: 1099px) {
    .av-sidebar.navigation {
        overflow: visible;
    }

    .navigation .app-navsection {
        position: relative;
    }

    .navigation .application-steps {
        display: none !important;
    }

    .navigation .app-navsection:hover > .application-steps:has(.module-nav-item),
    .navigation .app-navsection:focus-within > .application-steps:has(.module-nav-item) {
        display: block !important;
        position: absolute;
        left: 100%;
        top: 0;
        min-width: 220px;
        max-height: calc(100vh - var(--header-height) - 16px);
        overflow-y: auto;
        padding: 4px;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        box-shadow: 0 8px 24px rgba(26, 26, 46, 0.12);
        z-index: 1001;
    }
}

/* ---------- Main column and page header ---------- */

.av-main.main_panel {
    gap: 0;
    padding: 0 var(--app-main-pad-x) 48px;
    min-height: calc(100vh - var(--header-height));
    background: var(--paper);
}

.app-pagehead {
    position: sticky;
    top: var(--header-height);
    z-index: 998;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 18px;
    margin: 0 calc(-1 * var(--app-main-pad-x)) 16px;
    padding: 20px var(--app-main-pad-x) 12px;
    background: var(--paper);
    border-bottom: 1px solid var(--border);
}

.app-pagehead__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.app-pagehead .module-name {
    font: 400 13px/18px var(--font-display);
    color: var(--muted);
}

.app-pagehead .view-header h2.av-pagetitle {
    margin: 0;
}

.app-pagehead .next-button-container {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

/* Sidebar footer: the version straight above its release notes link */
.navigation .nav-footer p.ui-current-version {
    margin-bottom: 0;
}
