.hw-shell {
    --hw-sideNav-current-w: var(--hw-sideNav-expanded-w, 200px);
    --hw-sideNav-bg: var(--hw-bg-base, #1c232d);
    --hw-sideNav-border: var(--hw-card-bg, rgb(44, 53, 68));
    --hw-transition-duration: 300ms;
    --hw-transition-ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);

    position: relative;
    display: flex !important;
    /* Force flex layout */
    flex-direction: row;
    /* Sidebar on left, main on right */
    align-items: stretch;
    width: 100%;
    min-height: calc(100vh - var(--hw-header-h, 72px));
}

.hw-shell.is-sideNavCollapsed {
    --hw-sideNav-current-w: var(--hw-sideNav-collapsed-w, 72px);
}

/* Body class for shell-aware pages */
body.hw-has-shell #content-container {
    width: 100% !important;
    max-width: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* =============================================================================
   SIDE NAVIGATION
   ============================================================================= */

.hw-sideNav {
    display: flex !important;
    position: sticky;
    top: var(--hw-header-h, 72px);
    align-self: flex-start;
    flex: 0 0 var(--hw-sideNav-current-w);
    width: var(--hw-sideNav-current-w);
    height: calc(100vh - var(--hw-header-h, 72px));
    background: var(--hw-sideNav-bg);
    border-right: 1px solid var(--hw-sideNav-border);
    overflow: hidden;
    z-index: 100 !important;
    will-change: width;
    transition: width var(--hw-transition-duration, 300ms) var(--hw-transition-ease, cubic-bezier(0.25, 0.46, 0.45, 0.94)),
        flex-basis var(--hw-transition-duration, 300ms) var(--hw-transition-ease, cubic-bezier(0.25, 0.46, 0.45, 0.94));
}

.hw-sideNav__inner {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 10px;
    box-sizing: border-box;
}

/* =============================================================================
   TOGGLE BUTTON
   ============================================================================= */

.hw-sideNav__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--hw-radius-sm, .5rem);
    background: transparent;
    border: 0;
    color: #fff;
    cursor: pointer;
    align-self: flex-end;
    margin-left: auto;
    margin-right: 0;
    transition: opacity 160ms ease,
        transform var(--hw-transition-duration, 300ms) var(--hw-transition-ease, cubic-bezier(0.25, 0.46, 0.45, 0.94));
}

.hw-sideNav__toggle:hover,
.hw-sideNav__toggle:focus {
    background: transparent;
    opacity: 0.82;
}

.hw-sideNav__toggle:focus-visible {
    outline: var(--hw-focus-ring, 2px solid rgba(39, 144, 236, 0.65));
    outline-offset: 2px;
}

.hw-sideNav__toggleIcon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    transition: transform var(--hw-transition-duration, 300ms) var(--hw-transition-ease, cubic-bezier(0.25, 0.46, 0.45, 0.94));
}

/* Rotate arrow when collapsed */
.hw-shell.is-sideNavCollapsed .hw-sideNav__toggleIcon {
    transform: rotate(180deg);
}

/* Hide the "Menu" label entirely */
.hw-sideNav__toggleLabel {
    display: none;
}

/* =============================================================================
   NAVIGATION ITEMS
   ============================================================================= */

.hw-sideNav__items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.hw-sideNav__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--hw-radius-sm, .5rem);
    text-decoration: none !important;
    color: var(--hw-text-primary, rgba(255, 255, 255, 0.92)) !important;
    border: 1px solid transparent;
    transition: background 120ms ease,
        border-color 120ms ease,
        padding var(--hw-transition-duration, 300ms) var(--hw-transition-ease, cubic-bezier(0.25, 0.46, 0.45, 0.94));
}

.hw-sideNav__item:hover,
.hw-sideNav__item:focus {
    background: var(--hw-surface-bg, rgba(30, 41, 59, 0.92));
    color: rgba(255, 255, 255, 0.98) !important;
    text-decoration: none !important;
}

.hw-sideNav__item:focus-visible {
    outline: var(--hw-focus-ring, 2px solid rgba(39, 144, 236, 0.65));
    outline-offset: 2px;
}

/* Active state */
.hw-sideNav__item.is-active,
.hw-sideNav__item[aria-current="page"] {
    background: var(--hw-surface-bg, rgba(30, 41, 59, 0.92));
    color: rgba(0, 176, 235, 1) !important;
}

.hw-sideNav__item.is-active .hw-sideNav__icon,
.hw-sideNav__item[aria-current="page"] .hw-sideNav__icon {
    color: rgba(0, 176, 235, 1);
}

/* Icon and label */
.hw-sideNav__icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    opacity: 0.92;
}

.hw-sideNav__label {
    font-family: var(--hw-font-family, 'Segoe UI', sans-serif);
    font-size: var(--hw-font-size-base, 14px);
    font-weight: 600;
    line-height: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    will-change: opacity, transform;
    transform: translateX(0);
    transition: opacity var(--hw-transition-duration, 300ms) var(--hw-transition-ease, cubic-bezier(0.25, 0.46, 0.45, 0.94)),
        max-width var(--hw-transition-duration, 300ms) var(--hw-transition-ease, cubic-bezier(0.25, 0.46, 0.45, 0.94)),
        transform var(--hw-transition-duration, 300ms) var(--hw-transition-ease, cubic-bezier(0.25, 0.46, 0.45, 0.94));
}

/* =============================================================================
   SIGN-OUT SECTION
   ============================================================================= */

.hw-sideNav__signout {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--hw-border-default, rgba(255, 255, 255, 0.10));
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hw-sideNav__signoutBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    border-radius: var(--hw-radius-sm, .5rem);
    background: var(--hw-surface-bg, rgba(30, 41, 59, 0.92));
    color: var(--hw-text-primary, rgba(255, 255, 255, 0.92));
    font-family: var(--hw-font-family, 'Segoe UI', sans-serif);
    font-size: var(--hw-font-size-base, 14px);
    font-weight: 600;
    text-decoration: none !important;
    cursor: pointer;
    transition: background 120ms ease,
        border-color 120ms ease,
        padding var(--hw-transition-duration, 300ms) var(--hw-transition-ease, cubic-bezier(0.25, 0.46, 0.45, 0.94));
}

/* Profile button active state */
.hw-sideNav__signoutBtn.hw-sideNav__profileBtn.is-active,
.hw-sideNav__signoutBtn.hw-sideNav__profileBtn[aria-current="page"] {
    background: rgba(0, 176, 235, 0.15);
    color: rgba(0, 176, 235, 1);
}

.hw-sideNav__signoutBtn:hover,
.hw-sideNav__signoutBtn:focus {
    background: var(--hw-surface-bg-hover, rgb(27 38 54 / 98%));
    text-decoration: none !important;
}

.hw-sideNav__signoutBtn:focus-visible {
    outline: var(--hw-focus-ring-danger, 2px solid rgba(220, 38, 38, 0.5));
    outline-offset: 2px;
}

.hw-sideNav__profileBtn:focus-visible {
    outline: 2px solid rgba(0, 176, 235, 0.5);
}

.hw-sideNav__signoutIcon {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

/* =============================================================================
   COLLAPSED STATE
   ============================================================================= */

.hw-shell.is-sideNavCollapsed .hw-sideNav__item {
    padding: 12px;
    justify-content: center;
}

.hw-shell.is-sideNavCollapsed .hw-sideNav__icon {
    margin: 0 auto;
}

.hw-shell.is-sideNavCollapsed .hw-sideNav__toggle {
    justify-content: center;
    margin-left: auto;
    margin-right: auto;
    align-self: center;
}

.hw-shell.is-sideNavCollapsed .hw-sideNav__label,
.hw-shell.is-sideNavCollapsed .hw-sideNav__toggleLabel {
    max-width: 0px;
    opacity: 0;
    overflow: hidden;
    transform: translateX(-6px);
}

/* Sign-out button when collapsed */
.hw-shell.is-sideNavCollapsed .hw-sideNav__signoutBtn {
    justify-content: center;
    padding: 12px 10px;
}

.hw-shell.is-sideNavCollapsed .hw-sideNav__signoutBtn span {
    display: none;
}

/* =============================================================================
   MAIN CONTENT AREA
   ============================================================================= */

.hw-shell__main {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: hidden;
    z-index: 1;
    /* Below sidebar but above background */
    transition: margin-left var(--hw-transition-duration, 300ms) var(--hw-transition-ease, cubic-bezier(0.25, 0.46, 0.45, 0.94));
}

/* Bootstrap container fix for shell pages */
.hw-shell__main .container {
    width: 100% !important;
}

/* =============================================================================
   RESPONSIVE BEHAVIOR
   ============================================================================= */

/* =============================================================================
   BOTTOM TAB BAR (Mobile < 768px)
   Replaces the sidebar on small screens with an iOS/Android-style tab bar
   pinned to the bottom of the viewport.
   Reasoning:
   - Bottom tabs keep nav always visible without consuming horizontal space.
   - Thumb-reachable on modern phones (Fitts's law).
   - The sidebar is hidden because a 200px rail is too wide for 320px screens.
   ============================================================================= */

/* Hide sidebar on mobile */
@media screen and (max-width: 767px) {
    .hw-sideNav {
        display: none !important;
    }

    .hw-shell {
        --hw-sideNav-current-w: 0px;
        /* Reserve space for the bottom tab bar so page content isn't hidden behind it */
        padding-bottom: var(--hw-tabbar-h, 60px);
    }

    /* Let main content take full width on mobile */
    .hw-shell__main {
        width: 100%;
    }

    /* Bottom tab bar container */
    .hw-tabBar {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        height: var(--hw-tabbar-h, 60px);
        background: var(--hw-bg-base, #1c232d);
        border-top: 1px solid var(--hw-border-default, rgba(255, 255, 255, 0.10));
        align-items: stretch;
        justify-content: space-around;
        padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    }

    /* Individual tab item */
    .hw-tabBar__item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        flex: 1 1 0%;
        min-width: 0;
        padding: 6px 4px;
        text-decoration: none !important;
        color: var(--hw-text-muted, rgba(247, 247, 247, 0.75)) !important;
        font-family: var(--hw-font-family, 'Segoe UI', sans-serif);
        font-size: 11px;
        font-weight: 600;
        line-height: 14px;
        letter-spacing: 0.01em;
        transition: color var(--hw-transition-fast, 120ms ease);
        -webkit-tap-highlight-color: transparent;
    }

    .hw-tabBar__item:hover,
    .hw-tabBar__item:focus {
        color: var(--hw-text-primary, rgba(255, 255, 255, 0.92)) !important;
        text-decoration: none !important;
    }

    .hw-tabBar__item:focus-visible {
        outline: var(--hw-focus-ring, 2px solid rgba(39, 144, 236, 0.65));
        outline-offset: -2px;
    }

    /* Active tab */
    .hw-tabBar__item.is-active,
    .hw-tabBar__item[aria-current="page"] {
        color: var(--hw-accent-secondary, #00B0EB) !important;
    }

    .hw-tabBar__icon {
        width: 22px;
        height: 22px;
        flex: 0 0 auto;
    }

    .hw-tabBar__label {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
}

/* Hide tab bar on desktop (should never be visible when sidebar is shown) */
@media screen and (min-width: 768px) {
    .hw-tabBar {
        display: none !important;
    }
}

/* Ensure side nav doesn't overflow into header */
@media screen and (min-width: 768px) {
    .hw-sideNav {
        display: flex !important;
        position: sticky;
        top: var(--hw-header-h, 72px);
        max-height: calc(100vh - var(--hw-header-h, 72px));
        overflow-y: auto;
        overflow-x: hidden;
    }
}

/* =============================================================================
   PAGE-SPECIFIC SHELL MODIFIERS
   ============================================================================= */

/* Home page shell */
.hw-shell--home {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}

/* Cases page shell */
.hw-shell--cases {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}

/* FAQ page shell */
.hw-shell--faq {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}

/* Profile page shell */
.hw-shell--profile {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}

/* Create Case page shell — no sidebar */
.hw-shell--create-case {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}

.hw-shell--create-case > .hw-sideNav {
    display: none !important;
}

/* Edit Case page shell — no sidebar */
.hw-shell--edit-case {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
}

.hw-shell--edit-case > .hw-sideNav {
    display: none !important;
}