/* The signed-in shell (Components/Layout/MainLayout.razor + NavMenu.razor): a sidebar with the brand bar and the
   nav, and an account row over the content. The two top bars only line up while they
   agree on a height, so both read --topbar-height (nocturne.css). */

.page {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    min-width: 0;
}

/* ---- brand: the Stoma32 Hub logo (Shared/BrandLogo) ----
   Two files, the colour one and the white one for a dark ground; the theme shows one. The
   logo keeps its proportions (height set, width follows) and has no shadow or effect; under
   190px wide it would be too small to read, which the heights below respect. */

.brand-lockup {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    min-width: 0;
}

.brand-logo {
    display: inline-flex;
    line-height: 0;
}

.brand-logo img {
    display: block;
    width: auto;
    height: 2.4rem;   /* 200px wide */
}

.brand-logo .brand-logo-dark { display: none; }
:root[data-theme="dark"] .brand-logo:not(.on-dark) .brand-logo-light { display: none; }
:root[data-theme="dark"] .brand-logo:not(.on-dark) .brand-logo-dark { display: block; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .brand-logo:not(.on-dark) .brand-logo-light { display: none; }
    :root:not([data-theme="light"]) .brand-logo:not(.on-dark) .brand-logo-dark { display: block; }
}

/* ---- theme toggle: round, icon-only ---- */

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: var(--color-text);
    background-color: color-mix(in srgb, var(--color-text) 6%, var(--color-surface));
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.theme-toggle:hover {
    background-color: color-mix(in srgb, var(--color-text) 11%, var(--color-surface));
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

/* Same three states as nocturne.css: an explicit data-theme wins; with none, the OS
   preference decides. */
.theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: block; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-icon-sun { display: none; }
    :root:not([data-theme="light"]) .theme-icon-moon { display: block; }
}

/* ---- sidebar ---- */

.sidebar {
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-divider);
}

.sidebar .top-row {
    position: relative;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding-left: 1.25rem;
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-divider);
}

/* The phone menu button, round like the theme toggle. It is a checkbox with
   appearance:none, so it can't hold an inline <svg> — the icon is a background image,
   and a data-URI SVG can't use currentColor, hence one image per theme. */
.navbar-toggler {
    appearance: none;
    cursor: pointer;
    width: 2.75rem;
    height: 2.75rem;
    position: absolute;
    top: calc((var(--topbar-height) - 2.75rem) / 2);
    right: 1rem;
    border: 0;
    border-radius: 50%;
    background-color: color-mix(in srgb, var(--color-text) 6%, var(--color-surface));
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath fill='none' stroke='%23202837' stroke-linecap='round' stroke-width='2' d='M4.5 7h15M4.5 12h15M4.5 17h15'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 1.25rem;
    transition: background-color 0.15s ease;
}

.navbar-toggler:hover,
.navbar-toggler:checked {
    background-color: color-mix(in srgb, var(--color-text) 11%, var(--color-surface));
}

.navbar-toggler:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

:root[data-theme="dark"] .navbar-toggler {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath fill='none' stroke='%23e8edf2' stroke-linecap='round' stroke-width='2' d='M4.5 7h15M4.5 12h15M4.5 17h15'/%3e%3c/svg%3e");
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .navbar-toggler {
        background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3e%3cpath fill='none' stroke='%23e8edf2' stroke-linecap='round' stroke-width='2' d='M4.5 7h15M4.5 12h15M4.5 17h15'/%3e%3c/svg%3e");
    }
}

.nav-scrollable {
    display: none;
    background: var(--color-surface);
    padding: 0.75rem 0.5rem 1rem;
}

.navbar-toggler:checked ~ .nav-scrollable {
    display: block;
}

.sidebar .nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
}

.sidebar .nav-item {
    padding-bottom: 0.35rem;
    width: 100%;
}

.sidebar .nav-item:first-of-type { padding-top: 1.25rem; }
.sidebar .nav-item:last-of-type { padding-bottom: 1.25rem; }

.sidebar .nav-link {
    box-sizing: border-box;
    color: var(--color-muted);
    background: transparent;
    border: 0;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    line-height: 1.4;
    padding: 0.65rem 1rem;
    margin: 0.125rem 0.75rem;
    font-weight: 500;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: calc(100% - 1.5rem);
    transition: background 0.15s ease, color 0.15s ease;
}

/* The icons take the link's colour: grey at rest, teal where you are. */
.sidebar .nav-link svg {
    flex: none;
    width: 1.2rem;
    height: 1.2rem;
    color: inherit;
}

.sidebar .nav-link:hover {
    background: color-mix(in srgb, var(--color-text) 5%, transparent);
    color: var(--color-text);
}

/* Where you are: mint, with the darker teal that holds on it. After :hover, so it stays. */
.sidebar .nav-link.active {
    background: var(--color-active-bg);
    color: var(--color-active-text);
    font-weight: 600;
}

.sidebar .nav-link:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

/* ---- account row over the content ---- */

main > .top-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    height: var(--topbar-height);
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-divider);
}

.top-row-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-left: auto;
    flex-shrink: 0;
}

.top-row-divider {
    width: 1px;
    height: 1.5rem;
    background-color: var(--color-divider);
}

.top-row-form {
    display: flex;
    margin: 0;
}

.top-row-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0;
    border: 0;
    background: none;
    color: var(--color-muted);
    font: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.top-row-link:hover { color: var(--color-link-hover); }

.top-row-link:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.top-row-link svg { flex-shrink: 0; }

.top-row-link.active {
    color: var(--color-accent);
    font-weight: 600;
}

.top-row-link.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -0.3rem;
    height: 3px;
    border-radius: 3px;
    background-color: var(--color-accent);
}

.content {
    padding-top: 1.1rem;
    padding-bottom: 2rem;
}

@media (max-width: 480px) {
    .theme-toggle { width: 2.25rem; height: 2.25rem; }
    .theme-icon { width: 18px; height: 18px; }

    .top-row-actions { gap: 0.75rem; }
    .top-row-divider { display: none; }

    /* Icons only on phones. Visually hidden, not display:none, so "My profile" and
       "Log out" stay the accessible names of their controls. */
    .top-row-label {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

@media (min-width: 641px) {
    .page { flex-direction: row; }

    .sidebar {
        width: 272px;
        max-width: 100%;
        height: 100vh;
        position: sticky;
        top: 0;
    }

    .navbar-toggler { display: none; }

    .nav-scrollable {
        display: block;
        height: calc(100vh - var(--topbar-height));
        overflow-y: auto;
    }

    main > .top-row {
        position: sticky;
        top: 0;
        z-index: 1;
    }

    main > .top-row, .content {
        padding-left: 2rem !important;
        padding-right: 1.5rem !important;
    }
}

/* Blazor's "unhandled error" bar (MainLayout); blazor.web.js shows it. */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}
