﻿
/*Container Classes*/
.site-container {
    display: grid;
    grid-template-columns: 100%;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
    min-width: 100%;
    max-width: var(--page-width-max);

    --site-horizontal-padding: var(--space-xl);
    --site-vertical-padding: var(--space-3xs);
}

.site-container > header {
    grid-row: 1;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
}

.site-container > .main-content-container {
    grid-row: 2;
    z-index: 0;
}

.site-container > footer {
    grid-row: 3;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 0;
}

.main-content-container {
    display: flex;
    flex-direction: row;
    min-height: 100%;
    min-width: 100%;
    justify-content: center;
    align-items: stretch;
}

.login-page-container {
    display: flex;
    flex-direction: column;
    width: var(--page-width);
    max-width: var(--page-width-max);
    justify-content: center;
    align-items: stretch;
    gap: var(--space-xl);
    padding: var(--space-2xl);
}

.page-container {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    flex-shrink: 1;
    align-items: stretch;
    box-sizing: border-box;
    overflow-y: auto;
}

.page-content {
    display: flex;
    flex-direction: column;
    align-content: stretch;
    justify-content: flex-start;
    padding: var(--space-xs) var(--space-m);
    flex-grow: 1;
    box-sizing: border-box;
    gap: var(--space-xs);
}

.help-menu {
    display: flex;
    flex-direction: column;
    z-index: 50;
    width: 0px;
    padding: 0 var(--space-2xs);
    box-sizing: border-box;
    justify-content: center;
    gap: var(--space-xs);
    transition: width ease 0.2s, opacity ease 0.2s;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    z-index: 50;
    max-width: 100%;
    box-sizing: border-box;
    gap: var(--space-2xs);
    height: 100%;
    overflow: auto;
}

.nav-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3xs);
    background: transparent;
    border: none;
    padding: var(--space-2xs) var(--space-xs);
    cursor: pointer;
    font: inherit;
}

.nav-toggle:hover {
    background: var(--coolgrey20-colour);
}

.hamburger-icon {
    width: 20px;
    height: 20px;
}

.side-column {
    background-color: var(--coolgrey30-colour);
    flex-grow: 1;
}

.content-container {
    display: flex;
    flex-direction: column;
    padding: var(--space-s) var(--space-m);
    outline: solid;
    outline-width: var(--base-border);
    outline-color: var(--coolgrey30-colour);
    height: fit-content;
    gap: var(--space-s);
    box-sizing: border-box;
}

.page-error-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-m);
    align-items: center;
}

.text-container {
    border: none;
    padding: 0 var(--space-s);
}

    .text-container > p {
        margin: var(--space-xs) 0;
    }

        .text-container > p:first-child {
            margin-top: 0;
        }

        .text-container > p:last-child {
            margin-bottom: 0;
        }


.divider {
    border: solid;
    border-width: 1px 0px 0px 0px;
    width: 100%;
    height: 0;
    border-color: var(--coolgrey30-colour);
}

.form-container {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-xs);
}

.form-input-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
    flex-grow: 1;
}

.form-input-container-group {
    display: flex;
    flex-direction: row;
    flex-grow: 1;
    gap: var(--space-xs);
}

.grid-container {
    overflow-x: auto;
    overflow-y: hidden;
}

.content-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-s);
}

.banner-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-xs);
    border-left: 4px solid;
    border-radius: 0 8px 8px 0;
    padding: var(--space-s);
    text-align: left;
}

/* Mobile and Tablet styles (below 1200px) */
@media (max-width: 1199px) {
    /* Hide the nav menu by default on mobile; show only when .open is added */
    #app-nav-menu {
        display: none;
    }

    #app-nav-menu.open {
        display: flex;
    }
    /* Move nav-bar to top - remove from flex row */
    .main-content-container {
        flex-direction: column;
    }

    .page-container {
        flex-direction: column;
        width: 100%; /* ← Take full width */
    }

    .desktop-nav-bar {
        display: none;
    }

    .desktop-help-bar {
        display: none;
    }

    .mobile-top-bar {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        position: relative;
        z-index: 1000;
        border: solid;
        border-width: 0 0 1px 0;
        border-color: var(--coolgrey30-colour);
    }

    .mobile-top-bar .nav-toggle,
    .mobile-top-bar .help-toggle {
        padding: var(--space-3xs);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .nav-menu {
        width: 0;
        position: absolute;
        background: border-box var(--white-colour);
        top: 100%;
        padding: 0;
        height: auto;
        overflow: hidden;
    }

    .nav-menu > * {
        display: none;
    }

    .nav-menu.open {
        border: solid;
        border-width: 1px 1px 1px 0;
        border-color: var(--primary-colour);
        border-top-color: var(--coolgrey30-colour);
        border-bottom-right-radius: 10px;
        width: 250px;
        padding: var(--space-2xs) 0;
        overflow-x: hidden;
        overflow-y: auto;
        /* Switch to fixed so the menu is positioned relative to the viewport,
           not the document. --mobile-nav-top is set by NavBar.razor.js to the
           measured bottom edge of the mobile top bar, ensuring the menu never
           extends below the visible viewport and scroll works end-to-end. */
        position: fixed;
        top: var(--mobile-nav-top, 50px);
        max-height: calc(100vh - var(--mobile-nav-top, 50px));
    }

    .nav-menu.open > * {
        display: revert;
        flex-shrink: 0;
    }

    .help-menu {
        width: 0;
        position: absolute;
        background-color: var(--white-colour);
        right: 0;
        top: 100%;
        overflow: hidden;
        visibility: hidden;
    }

    .help-menu > * {
        display: none;
    }

    .help-menu.open {
        border: solid;
        border-width: 0 0 1px 1px;
        border-color: var(--coolgrey30-colour);
        width: 250px;
        visibility: visible;
    }

    .help-menu.open > * {
        display: initial;
    }

    .desktop-nav {
        display: none;
    }

    .content-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.35);
        backdrop-filter: blur(2px);
        pointer-events: auto;
        z-index: 999; /* ← This is correct, menu should be 1001 */
    }

    .side-column {
        display: none;
    }

    .page-content {
        padding: var(--space-2xs) var(--space-s);
    }
}

@media (max-width: 425px) {
    .nav-menu {
        left: 0;
        right: 0;
        width: 100%;
        max-width: none;
        border-width: 0px 0px 1px 0px;
    }

    /* Re-apply hide at this breakpoint — width:100% above would otherwise break the
       width:0 clip used at 1199px, so ensure display:none takes effect explicitly. */
    #app-nav-menu:not(.open) {
        display: none;
        overflow: hidden;
    }

    .form-input-container-group {
        display: flex;
        flex-direction: column;
        flex-grow: 1;
        gap: var(--space-xs);
    }
}

/* Desktop styles (1200px and above) - Collapsible left sidebar */
@media (min-width: 1200px) {
    /* Constrain the content row to the grid area so children can scroll independently */
    .main-content-container {
        height: 100%;
        min-height: 0;
        overflow: hidden;
    }

    .page-container {
        flex-direction: column;
    }

    .mobile-top-bar {
        display: none;
    }

    .desktop-nav-bar {
        display: flex;
        flex-direction: column;
        flex-shrink: 0;
        gap: var(--space-2xs);
        padding: var(--space-2xs) 0 var(--space-2xs) calc(var(--site-horizontal-padding) - var(--space-l));
        width: max-content;
        max-width: 250px;
        overflow-y: auto;
    }

    .desktop-nav-bar > .nav-toggle {
        display: none;
    }

    .desktop-help-bar {
        display: flex;
        flex-direction: column;
        gap: var(--space-2xs);
        border: solid;
        border-width: 0 0 0 1px;
        border-color: var(--coolgrey30-colour);
        width: fit-content;
        max-width: 250px;
        overflow: hidden;
    }

    .nav-menu {
        position: static;
        border: none;
        box-shadow: none;
        padding: 0;
        width: 100%;
        overflow: hidden;
    }

    .nav-menu.open {
        opacity: 1;
        width: 100%;
        pointer-events: auto;
    }

    .nav-toggle > .hamburger-icon {
        display: none;
    }

    .nav-toggle {
        pointer-events: none;
    }

    .mobile-nav {
        display: none;
    }

    .help-menu {
        display: flex;
        flex-direction: column;
        z-index: 50;
        width: 0px;
        padding: 0 var(--space-2xs);
        opacity: 0;
        visibility: hidden;
        box-sizing: border-box;
        justify-content: flex-start;
        gap: var(--space-xs);
        transition:
            width ease 0.2s,
            opacity ease 0.2s;
    }

    .help-menu > * {
        display: none;
        width: 0px;
        transition: width ease 0.2s;
    }

    .help-menu.open {
        opacity: 1;
        visibility: visible;
        width: 100%;
        pointer-events: auto;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        padding: var(--space-2xs);
    }

    .help-menu.open > * {
        display: initial;
        width: initial;
    }

    .content-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.35);
        backdrop-filter: blur(2px);
        pointer-events: auto;
        z-index: 20;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .content-overlay.show {
        opacity: 1;
        visibility: visible;
    }
}

