:root {
    --fs-sidebar-expanded: 280px;
    --fs-sidebar-collapsed: 64px;
    --fs-logo-size: 40px;
    --fs-topbar-h: 56px;
    --fs-mobile-drawer-w: clamp(260px, 85vw, 320px);
}

html, body {
    font-family: 'Inter', sans-serif;
    height: 100%;
}

body {
    height: 100vh;
    overflow: hidden;
}

h1:focus {
    outline: none;
}

[data-bs-theme="dark"] .visible-light-mode {
    display: none;
}
[data-bs-theme="light"] .visible-dark-mode {
    display: none;
}

.fs-shell {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* ========================================================================== 
   Section: Sidebar
   ========================================================================== */
.fs-sidebar {
    background: #ffffff;
    border-right: 1px solid var(--bs-border-color);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: width .5s ease, transform .5s ease;
    width: var(--fs-sidebar-expanded);
    z-index: 1050; /* Above main/topnav. */
}

@media (max-width: 767px) {
    .fs-sidebar {
        z-index: 1100; /* Above main/topnav and modals. */
    }
}

[data-bs-theme="dark"] .fs-sidebar {
    background: #151a24;
}

.fs-logo {
    height: var(--fs-topbar-h);
    padding: 8px .75rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex: 0 0 auto;
}

    .fs-logo img.logo {
        width: var(--fs-logo-size);
        height: var(--fs-logo-size);
        object-fit: contain;
    }

.fs-sidebar-scroll {
    box-sizing: border-box;
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: .5rem;
}

/* Hide sidebar entirely (affects both desktop and mobile) */
.fs-sidebar-hidden .fs-sidebar {
    display: none !important;
}

.fs-sidebar-hidden .fs-main {
    margin-left: 0 !important;
    transform: none !important; /* prevent mobile shift when hidden */
}

.fs-nav {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

    .fs-nav .nav-link {
        align-items: center;
        border-radius: .5rem;
        color: #374151;
        display: flex;
        gap: 0.75rem;
        padding: 0.75rem;
        text-decoration: none;
    }

        .fs-nav .nav-link:hover {
            background: rgba(0,0,0,.04);
            color: #111827;
        }

/* Ensure nav text (e.g., chat names) truncates with ellipsis on one line */
.fs-nav .nav-link .nav-text {
    flex: 1 1 auto;
    min-width: 0; /* Allow flex item to shrink for ellipsis */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.fs-collapsed .fs-nav .nav-link {
    padding: 1rem 0.75rem;
}

[data-bs-theme="dark"] .fs-nav .nav-link {
    color: #fff;
}

    [data-bs-theme="dark"] .fs-nav .nav-link:hover {
        color: #fff;
        background: rgba(255, 255, 255, 0.1) !important;
    }

.fs-nav .profile-image {
    margin-left: -0.25rem;
    margin-right: 0.25rem;
}
    .fs-nav .profile-image img {
        max-width: 1.75rem;
    }

/* Reusable collapsible sidebar sections (e.g., Recent Chats) */
.fs-section-collapsible {
    /* Large max-height to allow content; override with inline style if needed. */
    --fs-section-max-height: 1200px;
    max-height: var(--fs-section-max-height);
    overflow: hidden;
    opacity: 1;
    transform: scale(1);
    transform-origin: top left;
    transition: max-height .35s ease, opacity .25s ease, transform .35s ease;
    will-change: max-height, opacity, transform;
}

/* Collapsed state animation */
@media (min-width: 768px) {
    .fs-collapsed .fs-section-collapsible {
        max-height: 0 !important;
        opacity: 0;
        transform: scale(.92);
        pointer-events: none; /* Prevent focus while hidden. */
    }
}

/* Optional heading inside a collapsible section */
.fs-section-heading {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .05em;
    margin: 0 0 .25rem .75rem;
    opacity: .75;
    text-transform: uppercase;
    transition: opacity .25s ease;
}

/* Main column (independent scrollbar) */
.fs-main {
    flex: 1 1 auto;
    min-width: 0;
    height: 100vh;
    /* Make main layout a column so topnav stays at top and <main> fills the rest. */
    display: flex;
    flex-direction: column;
    /* Prevent double scrolling; let child <main> handle overflow. */
    overflow: hidden;
    background: transparent;
    transition: transform .25s ease;
}

/* Ensure the <main> element fills remaining height under the sticky topnav and scrolls when needed. */
.fs-main > main {
    flex: 1 1 auto;
    min-height: 0; /* Required for proper flexbox scrolling children */
    overflow-y: auto;
}

/* Sticky top bar INSIDE main column only (not over sidebar) */
.fs-topnav {
    align-items: center;
    backdrop-filter: saturate(120%) blur(8px);
    background: transparent;
    border-bottom: solid 1px var(--bs-border-color);
    display: flex;
    flex-shrink: 0;
    height: var(--fs-topbar-h);
    padding: 0 .5rem;
    position: sticky;
    top: 0;
    z-index: 5; /* below sidebar */
}

/* Collapse rules (md+) */
@media (min-width: 768px) {
    .fs-collapsed .fs-sidebar {
        width: var(--fs-sidebar-collapsed);
    }

    .fs-collapsed .fs-nav .nav-text {
        display: none;
    }

    .fs-collapsed .fs-collapse-btn {
        display: none !important;
    }

    .fs-collapsed .fs-logo img.logo {
        cursor: pointer;
    }

    .fs-collapsed .fs-nav .nav-link {
        justify-content: center;
    }
}

/* Mobile drawer + overlay + content slide */
@media (max-width: 767.98px) {
    .fs-sidebar {
        bottom: 0;
        left: 0;
        position: fixed;
        top: 0;
        transform: translateX(-100%);
        width: var(--fs-mobile-drawer-w);
        z-index: 1100; /* Ensure sidebar is above the overlay and modals. */
    }

    .fs-mobile-open .fs-sidebar {
        transform: translateX(0);
    }

    .fs-mobile-open .fs-main {
        transform: translateX(var(--fs-mobile-drawer-w));
    }

    .fs-overlay {
        background: rgba(0, 0, 0, 0.35);
        inset: 0;
        opacity: 0;
        pointer-events: none;
        position: fixed;
        transition: opacity 0.2s ease;
        z-index: 1040; /* Below the sidebar. */
    }

    .fs-mobile-open .fs-overlay {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ========================================================================== 
   Section: Page Container
   ========================================================================== */
.app-page--pad {
    padding-top: 1.25rem;
}

@media (min-width: 768px) {
    .app-page--pad {
        padding-top: 2rem;
    }

    .page-content > .container-fluid {
        --bs-gutter-x: 3.5rem;
    }
}

.app-page--pad-none {
    padding-top: 0;
}

.app-page {
    /* Make each page fill the full height of <main>. */
    min-height: 100%;
}


/* ========================================================================== 
   Section: Miscellaneous
   ========================================================================== */

.home-logo h1 {
    font-family: Poppins, sans-serif;
    letter-spacing: -2px;
}

[data-bs-theme="light"] .home-logo h1 {
    color: #018deb;
    text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5), 0px 8px 14px rgba(0, 0, 0, 0.1);
}

#layout-system-notification-container {
    left: 50%;
    max-width: 600px;
    min-width: 300px;
    position: fixed;
    top: 20px;
    transform: translateX(-50%);
    z-index: 9999;
}

    #layout-system-notification-container .alert {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        margin: 0;
        opacity: 0;
        transition: all 0.5s ease-in-out;
    }

        #layout-system-notification-container .alert.show {
            animation: fadeInDown 0.5s ease-in-out;
            opacity: 1;
        }

.invalid {
    border-color: var(--bs-danger) !important;
}

.validation-errors .validation-message {
    font-size: .875rem;
}

.validation-message {
    color: var(--bs-danger) !important;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.help-alert .icon {
    margin-right: 0.7rem;
}

.help-alert .content {
    font-size: 0.875rem;
    padding-bottom: 0.15rem;
    padding-top: 0.15rem;
}

[data-bs-theme="light"] .tooltip-help {
    color: var(--bs-gray-600);
    cursor: help;
}

.grid {
    font-size: 0.875rem;
}

.grid .dropdown-item {
    font-size: 0.875rem;
}

.skeleton {
    background: #e0e0e0;
    border-radius: 4px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

/* ========================================================================== 
   Section: Page Loader
   ========================================================================== */
.page-loader {
    height: 100%;
    position: relative;
}

.page-loading-spinner {
    align-items: center;
    display: flex;
    inset: 0;
    justify-content: center;
    opacity: 1;
    pointer-events: auto;
    position: absolute;
    transition: opacity 300ms ease;
    z-index: 4;
}

.page-content {
    height: 100%;
    opacity: 0;
    transition: opacity 300ms ease;
}

.loaded .page-loading-spinner {
    opacity: 0;
    pointer-events: none;
}

.loaded .page-content {
    opacity: 1;
}

/*#region FluentUI */

/* Allow Bootstrap menus to appear within data grids. */
.fluent-data-grid-row td, .multiline-text {
    overflow: visible !important;
}

/*#endregion*/

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    color: #111;
    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;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA9NC42NzgyIDI5MSA9Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

/*#region BOOTSTRAP OVERRIDES */

/* Form Switch */
.form-switch {
    padding-left: 4.5rem;
}

    .form-switch .form-check-input {
        cursor: pointer;
        height: 2rem;
        margin-left: -4.5rem;
        margin-right: 0.5rem;
        width: 3.5rem;
    }

        .form-switch .form-check-input:checked {
            background-position: right;
        }

        .form-switch .form-check-input::before {
            width: calc(2rem - 4px);
            height: calc(2rem - 4px);
            border-radius: 50%;
        }

/* Modal */
.modal .modal-body {
    min-height: 6rem;
}

/*#endregion*/

/*#region Typing Indicator */

.typing-container {
    align-items: center;
    display: flex;
    justify-content: center;
}

.typing-indicator {
    height: 30px;
    position: relative;
    width: 60px;
    z-index: 4;
}

.typing-circle {
    animation: typing-circle7124 0.5s alternate infinite ease;
    background-color: #000;
    border-radius: 50%;
    height: 8px;
    left: 15%;
    position: absolute;
    transform-origin: 50%;
    width: 8px;
}

[data-bs-theme="dark"] .typing-circle {
    background-color: #fff;
}

@keyframes typing-circle7124 {
    0% {
        border-radius: 50px 50px 25px 25px;
        height: 5px;
        top: 20px;
        transform: scaleX(1.7);
    }

    40% {
        border-radius: 50%;
        height: 8px;
        transform: scaleX(1);
    }

    100% {
        top: 0%;
    }
}

.typing-circle:nth-child(2) {
    left: 45%;
    animation-delay: 0.2s;
}

.typing-circle:nth-child(3) {
    left: auto;
    right: 15%;
    animation-delay: 0.3s;
}

.typing-shadow {
    width: 5px;
    height: 4px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.2);
    position: absolute;
    top: 30px;
    transform-origin: 50%;
    z-index: 3;
    left: 15%;
    filter: blur(1px);
    animation: typing-shadow046 0.5s alternate infinite ease;
}

@keyframes typing-shadow046 {
    0% {
        transform: scaleX(1.5);
    }

    40% {
        transform: scaleX(1);
        opacity: 0.7;
    }

    100% {
        transform: scaleX(0.2);
        opacity: 0.4;
    }
}

.typing-shadow:nth-child(4) {
    left: 45%;
    animation-delay: 0.2s;
}

.typing-shadow:nth-child(5) {
    left: auto;
    right: 15%;
    animation-delay: 0.3s;
}

/*#endregion*/