/* Closed left overlay. The .open class is still added by each page script. */

body:has(.side-nav) {
    padding-left: 0;
}

body .side-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    width: var(--sidebar-width-drawer);
    height: 100dvh;
    max-height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: var(--bg-nav);
    border-left: none;
    border-right: 1px solid var(--border-color);
    box-shadow: none;
    z-index: var(--z-sidebar);
}

body .side-nav.open {
    right: auto;
    left: 0;
    transform: translateX(0);
    box-shadow: var(--shadow-md);
}

/* Sidebar scroll chrome — overrides styles.css .side-nav scrollbar (higher specificity). */
body .side-nav {
    scrollbar-width: thin;
    scrollbar-color: rgba(124, 58, 237, 0.38) transparent;
}

body.light-mode .side-nav {
    scrollbar-color: rgba(124, 58, 237, 0.32) transparent;
}

body .side-nav::-webkit-scrollbar {
    width: 6px;
}

body .side-nav::-webkit-scrollbar-track {
    background: transparent;
}

body .side-nav::-webkit-scrollbar-thumb {
    background-color: rgba(124, 58, 237, 0.38);
    border-radius: 999px;
    border: 1px solid transparent;
    background-clip: padding-box;
}

body .side-nav::-webkit-scrollbar-thumb:hover {
    background-color: rgba(124, 58, 237, 0.58);
}

body.light-mode .side-nav::-webkit-scrollbar-thumb {
    background-color: rgba(124, 58, 237, 0.32);
}

body.light-mode .side-nav::-webkit-scrollbar-thumb:hover {
    background-color: rgba(124, 58, 237, 0.5);
}

body .side-nav::-webkit-scrollbar-button {
    display: none;
    height: 0;
    width: 0;
}

body .side-nav::-webkit-scrollbar-button:single-button {
    display: none;
    height: 0;
    width: 0;
}

body .side-nav::-webkit-scrollbar-corner {
    background: transparent;
}

body #menuToggleBtn,
body .menu-toggle-btn {
    position: static;
    left: auto;
    right: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    min-width: 40px;
    min-height: 40px;
}

.em-nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(6, 11, 20, 0.46);
}

.em-nav-backdrop[hidden] {
    display: none;
}

body .side-nav .em-nav-head {
    display: grid;
    grid-template-columns: minmax(0, max-content) minmax(72px, 1fr) auto;
    align-items: center;
    column-gap: 20px;
    row-gap: 16px;
    margin: 0 0 8px;
    min-width: 0;
}

body .side-nav .em-nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    grid-column: 1;
    flex: 0 1 auto;
}

body .side-nav-brand {
    margin: 0;
    padding-left: 0;
    display: block;
    flex-shrink: 0;
    overflow: visible;
    text-overflow: clip;
    white-space: nowrap;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

body .em-beta {
    flex: 0 0 auto;
    align-self: center;
    padding: 2px 7px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.16);
    color: var(--text-muted);
    font-size: 12.1px;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.4;
}

body .side-nav .close-nav-btn {
    position: static;
    top: auto;
    right: auto;
    grid-column: 3;
    justify-self: end;
    width: 36px;
    min-width: 36px;
    height: 36px;
    margin: 0;
    padding-inline-end: 2px;
    margin-left: 12px;
    padding: 0;
    color: var(--text-muted);
    background: transparent;
    overflow: visible;
    transform: none;
    filter: none;
    box-shadow: none;
    transition: color 0.2s ease, background-color 0.2s ease;
}

body .side-nav .close-nav-btn .em-ui-icon,
body #menuToggleBtn .em-ui-icon,
body #toggleChatSidebarBtn .em-ui-icon {
    width: 18px;
    height: 18px;
    min-width: 18px;
    flex: 0 0 18px;
    stroke: currentColor;
    stroke-width: 2;
    display: block;
}

body #menuToggleBtn .em-ui-icon {
    pointer-events: none;
}

body .side-nav .close-nav-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.12);
    transform: none;
    filter: none;
    box-shadow: none;
}

body .header,
body .top-header,
body .chat-header,
body .store-header,
body .em-app-header {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

body .chat-header {
    height: auto;
    min-height: 70px;
}

body .store-header {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    text-align: center;
}

body .store-header #menuToggleBtn {
    grid-column: 1;
    justify-self: start;
}

body .store-header .store-header-content {
    grid-column: 2;
    text-align: center;
}

body .store-header .store-header-actions {
    grid-column: 3;
    justify-self: end;
    margin-left: 0;
}

body .em-header-left,
body .header-left,
body .chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}

body .header-actions,
body .header-right,
body .chat-header-right,
body .store-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    width: auto;
    margin-left: auto;
}

body .header h1.em-page-title,
body h1.em-page-title {
    margin: 0;
    width: auto;
    color: var(--text-main);
    background: none;
    -webkit-text-fill-color: currentColor;
    background-clip: border-box;
    text-shadow: none;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
    text-align: left;
    order: 0;
}

body .chat-sidebar {
    left: auto;
    right: -300px;
    border-right: none;
    border-left: 1px solid var(--border-color);
    box-shadow: none;
    transition: right 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

body .chat-sidebar.open {
    left: auto;
    right: 0;
}

body .chat-container {
    width: 100%;
    max-width: 100%;
}

body .nav-item {
    border-radius: var(--radius-sm);
    min-height: 44px;
    gap: 10px;
}

body .nav-item .em-ui-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    stroke: currentColor;
}

body .nav-item:hover:not(.active) {
    background-color: rgba(148, 163, 184, 0.08);
    border-color: transparent;
    color: var(--text-main);
    box-shadow: none;
}

body .nav-item.active,
body .nav-item + .nav-item.active {
    background-color: rgba(18, 16, 32, 0.92);
    background-clip: border-box;
    border-color: rgba(124, 58, 237, 0.45);
    color: var(--text-main);
    box-shadow: 0 0 16px rgba(124, 58, 237, 0.16);
    font-weight: 600;
}

body .nav-item.active .em-ui-icon {
    color: #7c3aed;
    stroke: #7c3aed;
}

body.light-mode .nav-item.active,
body.light-mode .nav-item + .nav-item.active {
    background-color: rgba(124, 58, 237, 0.08);
    color: var(--text-main);
    border-color: rgba(124, 58, 237, 0.45);
}

body .side-nav-brand .brand-mind,
body:not(.light-mode) .side-nav-brand .brand-mind,
body .side-nav h2 span {
    text-shadow: none;
}

.chat-sidebar .close-nav-btn {
    position: static;
}

@media (max-width: 768px) {
    body h1.em-page-title,
    body .header h1.em-page-title {
        font-size: 18px;
    }

    body .store-header {
        display: flex;
        flex-direction: column;
        grid-template-columns: unset;
    }

    body .header-actions,
    body .chat-header-right,
    body .store-header-actions {
        gap: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body .side-nav,
    body .chat-sidebar,
    body .side-nav .close-nav-btn {
        transition: none;
    }
}
