/* =========================================================================
   TicketingSystem app shell — shared by the customer portal (Components/Layout/MainLayout) and the
   staff app (XAF main form template, Blazor.Server/Templates). Header with the brand top-left and the
   user top-right, a light navigation pane with the accent-coloured active item, the content area and
   the footer; plus the sign-in page. Requires tokens.css. Content building blocks (page header, cards,
   lists, timelines) are in content.css.
   ========================================================================= */

/* ---------- app shell --------------------------------------------------- */
.app-shell {
    display: grid;
    grid-template-columns: var(--ts-sidebar-width) minmax(0, 1fr);
    grid-template-rows: var(--ts-header-height) 1fr;
    grid-template-areas:
        "header header"
        "sidebar main";
    min-height: 100vh;
    background: var(--ts-surface-page);
    color: var(--ts-text);
    font-family: var(--ts-font-family);
}

.app-header {
    grid-area: header;
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: var(--ts-space-3);
    padding: 0 var(--ts-space-4);
    background: var(--ts-surface);
    border-bottom: 1px solid var(--ts-border);
}

.app-header__toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 0;
    border: 0;
    border-radius: var(--ts-radius-sm);
    background: transparent;
    color: var(--ts-text);
    font-size: 1.25rem;
    cursor: pointer;
}

.app-header__toggle:hover { background: var(--ts-hover); }

.app-header__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--ts-text);
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
}

.app-header__brand:hover { color: var(--ts-text); text-decoration: none; }

/* Second half of the brand: "Customer Portal" / "Service Desk". */
.app-header__portal {
    font-weight: 400;
    color: var(--ts-text-muted);
    padding-left: 10px;
    border-left: 1px solid var(--ts-border);
    white-space: nowrap;
}

.app-header__user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--ts-space-3);
    min-width: 0;
    color: var(--ts-text-muted);
}

.app-header__user-name {
    font-weight: 600;
    color: var(--ts-text);
    white-space: nowrap;
    text-decoration: none;
}

a.app-header__user-name:hover { color: var(--ts-accent-text); text-decoration: underline; }

.app-header__user-company {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.app-header__signout-form { margin: 0; }

.app-header__signout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    margin: 0;
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-radius-sm);
    background: transparent;
    color: var(--ts-text);
    font: inherit;
    cursor: pointer;
}

.app-header__signout:hover { background: var(--ts-hover); }

/* Navigation pane. The aside stretches the full content height (its background and border never stop
   short); the nav inside it is sticky and scrolls on its own. */
.app-sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    background: var(--ts-surface-subtle);
    border-right: 1px solid var(--ts-border);
}

.app-sidebar__nav {
    position: sticky;
    top: var(--ts-header-height);
    max-height: calc(100vh - var(--ts-header-height));
    overflow-y: auto;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--ts-space-3) 8px;
}

/* Section label between groups of links (staff navigation groups). */
.app-sidebar__section {
    margin: var(--ts-space-3) 12px 4px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ts-text-muted);
}

.app-sidebar__section:first-child { margin-top: 4px; }

.app-sidebar__nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--ts-radius-sm);
    border-left: 3px solid transparent;
    color: var(--ts-text);
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
}

.app-sidebar__nav-link i { width: 18px; text-align: center; font-size: 1rem; color: var(--ts-text-muted); }

.app-sidebar__nav-link:hover {
    background: var(--ts-hover);
    color: var(--ts-text);
    text-decoration: none;
}

.app-sidebar__nav-link.active {
    background: var(--ts-accent-soft);
    border-left-color: var(--ts-accent);
    color: var(--ts-accent-text);
    font-weight: 600;
}

.app-sidebar__nav-link.active i { color: var(--ts-accent-text); }

.app-sidebar__nav-link.disabled { opacity: 0.55; pointer-events: none; }

.app-main {
    grid-area: main;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-main__inner {
    flex: 1;
    width: 100%;
    max-width: var(--ts-content-max-width);
    margin: 0 auto;
    padding: var(--ts-space-5);
    box-sizing: border-box;
}

.app-footer {
    display: flex;
    justify-content: space-between;
    gap: var(--ts-space-3);
    padding: var(--ts-space-3) var(--ts-space-5);
    border-top: 1px solid var(--ts-border);
    color: var(--ts-text-muted);
    font-size: 0.8rem;
}

.app-backdrop { display: none; }

/* ---------- responsive: tablet / phone ---------------------------------- */
@media (max-width: 767.98px) {
    .app-shell {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "header"
            "main";
    }

    .app-header { padding: 0 8px; gap: 8px; }
    .app-header__toggle { display: inline-flex; }
    .app-header__portal,
    .app-header__user-name,
    .app-header__user-company,
    .app-header__signout span { display: none; }

    .app-sidebar {
        position: fixed;
        top: var(--ts-header-height);
        left: 0;
        bottom: 0;
        height: auto;
        width: min(280px, 85vw);
        z-index: 40;
        transform: translateX(-100%);
        transition: transform 180ms ease;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    }

    .app-shell.is-nav-open .app-sidebar { transform: translateX(0); }

    .app-backdrop {
        display: block;
        position: fixed;
        inset: var(--ts-header-height) 0 0 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 35;
    }

    .app-main__inner { padding: var(--ts-space-4) 12px; }
    .app-footer { padding: var(--ts-space-3) 12px; flex-direction: column; gap: 2px; }
}

/* =========================================================================
   Sign-in page: plain page with a centred card (portal /login, staff LoginPage).
   ========================================================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--ts-space-5) var(--ts-space-4);
    box-sizing: border-box;
    background: var(--ts-surface-page);
    color: var(--ts-text);
    font-family: var(--ts-font-family);
}

.login-shell { width: 100%; max-width: 420px; }

.login-card {
    background: var(--ts-surface);
    border: 1px solid var(--ts-border);
    border-radius: var(--ts-radius-md);
    padding: var(--ts-space-6);
    box-shadow: var(--ts-shadow-raised);
}

.login-card__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--ts-space-5);
    font-weight: 600;
    font-size: 1rem;
}

.login-card__brand-portal {
    font-weight: 400;
    color: var(--ts-text-muted);
    padding-left: 10px;
    border-left: 1px solid var(--ts-border);
}

.login-card h1 { font-size: 1.35rem; font-weight: 600; margin: 0 0 6px 0; }
.login-card .lead { font-size: 0.95rem; font-weight: 400; color: var(--ts-text-muted); margin: 0 0 var(--ts-space-5) 0; }
.login-card__note { margin: var(--ts-space-4) 0 0; font-size: 0.8125rem; color: var(--ts-text-muted); }

@media (max-width: 575.98px) {
    .login-card { padding: var(--ts-space-5) var(--ts-space-4); }
}
