/*
 * Fanxing Chat sidebar — reference-matched local redesign
 *
 * The measurements and surface treatment in this layer intentionally follow
 * the supplied workbench reference. Existing model data and click hooks stay
 * unchanged.
 */

body.chat-shell {
    --fx-reference-sidebar-width: 267px;
    --fx-reference-bg: rgba(13, 14, 21, 0.95);
    --fx-reference-line: rgba(255, 255, 255, 0.08);
    --fx-reference-panel: #212223;
    --fx-reference-text: rgba(247, 242, 234, 0.98);
    --fx-reference-muted: #b6bbc2;
    --fx-brand-accent: #7c6cff;
    --fx-brand-accent-soft: rgba(124, 108, 255, 0.13);
    --fx-brand-accent-card: #24203f;
    --fx-brand-accent-glow: rgba(124, 108, 255, 0.34);
}

body.chat-shell .sidebar {
    width: var(--fx-reference-sidebar-width);
    flex: 0 0 var(--fx-reference-sidebar-width);
    min-width: 0;
    overflow: hidden;
    color: #fff;
    background: var(--fx-reference-bg);
    border-right: 1px solid var(--fx-reference-line);
    box-shadow: none;
    backdrop-filter: blur(20px);
}

body.chat-shell .sidebar-header {
    position: relative;
    display: flex;
    flex: 0 0 86px;
    justify-content: center;
    align-items: center;
    min-height: 86px;
    box-sizing: border-box;
    padding: 0;
    background: transparent;
    border: 0;
}

body.chat-shell .sidebar-header::after {
    display: none;
}

body.chat-shell .nav-logo {
    display: flex;
    width: max-content;
    max-width: calc(100% - 24px);
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 0;
    text-decoration: none;
    transition: transform 300ms ease;
}

body.chat-shell .nav-logo:hover {
    transform: scale(1.02);
}

body.chat-shell .logo-mark-shell {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: #030305;
    box-shadow: none;
    overflow: hidden;
}

body.chat-shell .logo-img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    border: 0;
    border-radius: inherit;
    object-fit: cover;
    filter: drop-shadow(0 0 10px rgba(124, 108, 255, 0.38));
}

body.chat-shell .logo-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    gap: 5px;
}

body.chat-shell .logo-text {
    width: fit-content;
    margin: 0;
    color: transparent;
    background: linear-gradient(135deg, #fff 0%, #a99fff 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.5px;
    white-space: nowrap;
}

body.chat-shell .logo-subtitle {
    overflow: hidden;
    max-width: 150px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The reference keeps its desktop navigator permanently visible. The close
   affordance is retained only for the mobile drawer. */
body.chat-shell .toggle-sidebar {
    display: none;
}

body.chat-shell .sidebar-mode-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex: 0 0 auto;
    gap: 10px;
    margin: 0;
    padding: 8px 10px 16px;
    border-bottom: 1px solid rgba(56, 56, 56, 0.66);
}

body.chat-shell .sidebar-mode-tab {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 51px;
    box-sizing: border-box;
    gap: 8px;
    padding: 14px 0;
    border: 0;
    border-radius: 6px;
    color: #b6bbc2;
    background: var(--fx-reference-panel);
    box-shadow: inset 8px 5px 12.6px #323437, inset -5px -5px 15.7px #323437;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    overflow: hidden;
    transition: color 150ms ease, background-color 150ms ease;
}

body.chat-shell .sidebar-mode-tab:not([aria-disabled="true"]):hover {
    color: #fff;
    background: #292a2c;
    transform: none;
}

body.chat-shell .sidebar-mode-tab.active {
    color: #fff;
    border: 1px solid var(--fx-brand-accent);
    background: var(--fx-brand-accent-soft);
    box-shadow: inset 3px 4px 16.9px rgba(108, 92, 231, 0.56), inset -6px -6px 20.1px rgba(124, 108, 255, 0.2);
    font-weight: 600;
}

body.chat-shell .sidebar-mode-tab.active::after {
    content: "";
    position: absolute;
    bottom: -4px;
    left: 50%;
    width: 17px;
    height: 6px;
    border-radius: 50%;
    background: #b8b0ff;
    filter: blur(2px);
    transform: translateX(-50%);
    box-shadow: 0 7px 12px 8px rgba(124, 108, 255, 0.54);
}

body.chat-shell .sidebar-mode-tab-wide {
    grid-column: 1 / -1;
    min-height: 48px;
    color: #b6bbc2;
    opacity: 1;
    cursor: default;
}

body.chat-shell .sidebar-mode-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
}

body.chat-shell .sidebar-mode-tab.active .sidebar-mode-icon {
    color: #a99fff;
}

body.chat-shell .model-tabs {
    position: relative;
    display: flex;
    flex: 0 0 40px;
    justify-content: space-between;
    min-height: 40px;
    height: 40px;
    box-sizing: border-box;
    gap: 2px;
    margin: 12px 10px 0;
    padding: 3px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(18, 20, 28, 0.7);
    box-shadow: none;
    backdrop-filter: blur(8px);
}

body.chat-shell .model-tabs .model-type-tab {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 32px;
    box-sizing: border-box;
    padding: 5px 0;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #94a3b8;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    line-height: 20px;
    text-align: center;
    transition: color 250ms ease, background 250ms ease, border-color 250ms ease, box-shadow 250ms ease;
}

body.chat-shell .model-tabs .model-type-tab:hover {
    color: rgba(255, 255, 255, 0.6);
    background: transparent;
}

body.chat-shell .model-tabs .model-type-tab.active {
    color: #a99fff;
    border-color: rgba(124, 108, 255, 0.46);
    background: linear-gradient(135deg, rgba(124, 108, 255, 0.19) 0%, rgba(77, 141, 255, 0.12) 100%);
    box-shadow: 0 0 12px rgba(124, 108, 255, 0.2);
    font-weight: 600;
}

/* The reference navigator goes directly from type tabs to models. */
body.chat-shell .model-search-wrap,
body.chat-shell .sidebar .model-search-wrap {
    display: none !important;
}

body.chat-shell .model-list {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    gap: 2px;
    margin-top: 10px;
    padding: 8px 6px 18px 10px;
    overflow-y: auto;
    scrollbar-color: rgba(148, 163, 184, 0.26) transparent;
    scrollbar-gutter: auto;
    overscroll-behavior: contain;
}

body.chat-shell .model-list::-webkit-scrollbar {
    width: 4px;
}

body.chat-shell .model-list::-webkit-scrollbar-track {
    background: transparent;
}

body.chat-shell .model-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.26);
}

body.chat-shell .model-item {
    position: relative;
    display: flex;
    flex: 0 0 81px;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    height: 81px;
    min-height: 81px;
    box-sizing: border-box;
    gap: 8px;
    margin: 0 0 6px;
    padding: 8px 10px 10px;
    border: 0;
    border-radius: 6px;
    color: inherit;
    background: transparent;
    overflow: visible;
    cursor: pointer;
    transform: none;
    transition: background-color 150ms ease;
}

body.chat-shell .model-item::before {
    content: "";
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    border: 0;
    padding: 1px;
    border-radius: 6px;
    background: conic-gradient(
        from 90deg,
        rgba(132, 119, 255, 0.2) -35.62deg,
        #8f82ff 29.96deg,
        rgba(124, 108, 255, 0.05) 66.7deg,
        rgba(106, 144, 255, 0.38) 122.78deg,
        #b39cff 221.23deg,
        rgba(124, 108, 255, 0.26) 266.6deg,
        rgba(132, 119, 255, 0.2) 324.38deg,
        #8f82ff 389.96deg
    );
    opacity: 0;
    transform: none;
    pointer-events: none;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

body.chat-shell .model-item:hover {
    border: 0;
    background: rgba(255, 255, 255, 0.05);
    transform: none;
}

body.chat-shell .model-item.active {
    border: 0;
    border-radius: 6px;
    background: var(--fx-brand-accent-card);
    box-shadow: none;
    transform: none;
}

body.chat-shell .model-item.active::before {
    opacity: 1;
    transform: none;
}

body.chat-shell .model-icon-small {
    position: relative;
    display: flex;
    flex: 0 0 36px;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
}

body.chat-shell .model-icon-img {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 0;
    object-fit: contain;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4)) drop-shadow(0 0 10px rgba(124, 108, 255, 0.22));
    transition: filter 300ms cubic-bezier(0.4, 0, 0.2, 1), transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

body.chat-shell .model-icon-img.is-openai-white {
    filter: brightness(0) invert(1) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4)) drop-shadow(0 0 10px rgba(124, 108, 255, 0.22));
}

body.chat-shell .model-item:hover .model-icon-img {
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 14px rgba(124, 108, 255, 0.46));
    transform: scale(1.08) translateY(-1px);
}

body.chat-shell .model-item:hover .model-icon-img.is-openai-white {
    filter: brightness(0) invert(1) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 14px rgba(124, 108, 255, 0.46));
}

body.chat-shell .model-item.active .model-icon-small {
    border: 0;
    background: transparent;
    box-shadow: none;
}

body.chat-shell .model-item.active .model-icon-img {
    filter: drop-shadow(0 0 16px rgba(169, 159, 255, 0.6)) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
    transform: scale(1.05);
}

body.chat-shell .model-item.active .model-icon-img.is-openai-white {
    filter: brightness(0) invert(1) drop-shadow(0 0 16px rgba(169, 159, 255, 0.6)) drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

body.chat-shell .model-info {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    width: 80%;
    min-width: 0;
    gap: 0;
}

body.chat-shell .model-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
    gap: 6px;
}

body.chat-shell .model-name {
    flex: 0 1 140px;
    width: 140px;
    min-width: 0;
    overflow: hidden;
    color: var(--fx-reference-text);
    font-size: 14px;
    font-weight: 600;
    line-height: 18px;
    letter-spacing: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.chat-shell .model-desc {
    display: -webkit-box;
    width: 90%;
    margin: 4px 0 0;
    overflow: hidden;
    color: var(--fx-reference-muted);
    font-size: 11px;
    font-weight: 400;
    line-height: 14px;
    word-break: break-all;
    white-space: normal;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

body.chat-shell .model-type-badge {
    display: inline-flex;
    flex: 0 0 32px;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 20px;
    min-height: 20px;
    box-sizing: border-box;
    padding: 0;
    border: 1px solid currentColor;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 400;
    line-height: 18px;
    opacity: 1;
    text-align: center;
    white-space: nowrap;
}

body.chat-shell .model-type-chat {
    color: #55a7ff;
    border-color: #347fcf;
    background: #183659;
}

body.chat-shell .model-type-image {
    color: #b36cff;
    border-color: #7040a8;
    background: #342249;
}

body.chat-shell .model-type-video {
    color: #ff708d;
    border-color: #ad4059;
    background: #4a2230;
}

body.chat-shell .model-badge-compact {
    display: none !important;
}

@media (prefers-reduced-motion: reduce) {
    body.chat-shell .nav-logo,
    body.chat-shell .model-item,
    body.chat-shell .model-icon-img,
    body.chat-shell .model-tabs .model-type-tab {
        transition: none;
    }
}

@media (min-width: 769px) {
    /* Safety for users who previously stored the old collapsible state. */
    body.chat-shell.sidebar-collapsed .sidebar {
        width: var(--fx-reference-sidebar-width);
        flex: 0 0 var(--fx-reference-sidebar-width);
        overflow: hidden;
        border-right: 1px solid var(--fx-reference-line);
        background: var(--fx-reference-bg);
        backdrop-filter: blur(20px);
    }

    body.chat-shell.sidebar-collapsed .sidebar-header {
        display: flex;
        min-height: 86px;
        height: auto;
        padding: 0;
    }

    body.chat-shell.sidebar-collapsed .nav-logo {
        display: flex !important;
    }

    body.chat-shell.sidebar-collapsed .sidebar-mode-tabs {
        display: grid !important;
    }

    body.chat-shell.sidebar-collapsed .model-tabs,
    body.chat-shell.sidebar-collapsed .model-list,
    body.chat-shell.sidebar-collapsed .model-info {
        display: flex !important;
    }
}

@media (max-width: 768px) {
    body.chat-shell .sidebar {
        width: min(292px, 82vw);
        flex-basis: auto;
        max-width: 100vw;
        background: #070912;
        border-right: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 18px 0 40px rgba(0, 0, 0, 0.42);
    }

    body.chat-shell .sidebar-header {
        min-height: 86px;
    }

    body.chat-shell .toggle-sidebar {
        position: absolute;
        top: 22px;
        right: 14px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        padding: 0;
        border: 1px solid rgba(255, 255, 255, 0.14);
        border-radius: 8px;
        color: #fff;
        background: rgba(255, 255, 255, 0.08);
        box-shadow: none;
    }

    body.chat-shell .nav-logo {
        margin-right: 32px;
    }
}

/* Light mode is designed independently rather than mechanically inverting
   the dark palette. Layout remains identical in both themes. */
body.chat-shell.theme-light {
    --fx-reference-bg: rgba(246, 247, 251, 0.97);
    --fx-reference-line: rgba(33, 29, 54, 0.1);
    --fx-reference-panel: #ffffff;
    --fx-reference-text: #1d1b2e;
    --fx-reference-muted: #6f7180;
    --fx-brand-accent: #6657e8;
    --fx-brand-accent-soft: rgba(102, 87, 232, 0.1);
    --fx-brand-accent-card: #efedff;
    --fx-brand-accent-glow: rgba(102, 87, 232, 0.2);
}

body.chat-shell.theme-light .sidebar {
    color: #1d1b2e;
    background: var(--fx-reference-bg);
    border-right-color: var(--fx-reference-line);
    box-shadow: 8px 0 28px rgba(42, 38, 70, 0.045);
    backdrop-filter: blur(20px);
}

body.chat-shell.theme-light .logo-mark-shell {
    border: 1px solid rgba(102, 87, 232, 0.28);
    background: linear-gradient(145deg, #5144c9 0%, #7365ee 52%, #8e7cff 100%);
    box-shadow: 0 7px 18px rgba(76, 63, 176, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

body.chat-shell.theme-light .logo-img {
    mix-blend-mode: screen;
    filter: contrast(1.08);
}

body.chat-shell.theme-light .logo-text {
    color: transparent;
    background: linear-gradient(135deg, #242039 0%, #6657e8 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.chat-shell.theme-light .logo-subtitle {
    color: #747687;
}

body.chat-shell.theme-light .sidebar-mode-tabs {
    border-bottom-color: rgba(33, 29, 54, 0.1);
}

body.chat-shell.theme-light .sidebar-mode-tab {
    color: #555766;
    border: 1px solid rgba(33, 29, 54, 0.08);
    background: #ffffff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 3px 10px rgba(42, 38, 70, 0.055);
}

body.chat-shell.theme-light .sidebar-mode-tab:not([aria-disabled="true"]):hover {
    color: #29263e;
    background: #f3f2fb;
}

body.chat-shell.theme-light .sidebar-mode-tab.active {
    color: #4037b6;
    border-color: #6657e8;
    background: #efedff;
    box-shadow: inset 0 0 16px rgba(102, 87, 232, 0.1), 0 4px 12px rgba(102, 87, 232, 0.1);
}

body.chat-shell.theme-light .sidebar-mode-tab.active::after {
    background: #8f84ef;
    box-shadow: 0 7px 12px 7px rgba(102, 87, 232, 0.24);
}

body.chat-shell.theme-light .sidebar-mode-tab.active .sidebar-mode-icon {
    color: #6657e8;
}

body.chat-shell.theme-light .model-tabs {
    border-color: rgba(33, 29, 54, 0.11);
    background: rgba(232, 233, 242, 0.76);
    backdrop-filter: blur(8px);
}

body.chat-shell.theme-light .model-tabs .model-type-tab {
    color: #727483;
}

body.chat-shell.theme-light .model-tabs .model-type-tab:hover {
    color: #363249;
}

body.chat-shell.theme-light .model-tabs .model-type-tab.active {
    color: #5648d3;
    border-color: rgba(102, 87, 232, 0.36);
    background: linear-gradient(135deg, rgba(102, 87, 232, 0.12) 0%, rgba(77, 141, 255, 0.07) 100%);
    box-shadow: 0 2px 8px rgba(102, 87, 232, 0.09);
}

body.chat-shell.theme-light .model-list {
    scrollbar-color: rgba(78, 76, 96, 0.24) transparent;
}

body.chat-shell.theme-light .model-list::-webkit-scrollbar-thumb {
    background: rgba(78, 76, 96, 0.24);
}

body.chat-shell.theme-light .model-item:hover {
    background: rgba(72, 66, 108, 0.055);
}

body.chat-shell.theme-light .model-item.active {
    background: var(--fx-brand-accent-card);
}

body.chat-shell.theme-light .model-name {
    color: var(--fx-reference-text);
}

body.chat-shell.theme-light .model-desc {
    color: var(--fx-reference-muted);
}

body.chat-shell.theme-light .sidebar .model-icon-small {
    border: 0;
    background: transparent;
    box-shadow: none;
}

body.chat-shell.theme-light .model-icon-img {
    filter: drop-shadow(0 2px 5px rgba(42, 38, 70, 0.12)) drop-shadow(0 0 8px rgba(102, 87, 232, 0.08));
}

body.chat-shell.theme-light .model-icon-img.is-openai-white {
    filter: none;
}

body.chat-shell.theme-light .model-item:hover .model-icon-img {
    filter: drop-shadow(0 4px 8px rgba(42, 38, 70, 0.16)) drop-shadow(0 0 10px rgba(102, 87, 232, 0.16));
}

body.chat-shell.theme-light .model-item:hover .model-icon-img.is-openai-white {
    filter: drop-shadow(0 4px 8px rgba(42, 38, 70, 0.14));
}

body.chat-shell.theme-light .model-item.active .model-icon-img {
    filter: drop-shadow(0 0 12px rgba(102, 87, 232, 0.28)) drop-shadow(0 2px 5px rgba(42, 38, 70, 0.1));
}

body.chat-shell.theme-light .model-item.active .model-icon-img.is-openai-white {
    filter: drop-shadow(0 0 10px rgba(102, 87, 232, 0.2));
}

body.chat-shell.theme-light .model-type-chat {
    color: #286fc4;
    border-color: #93c5fd;
    background: #eaf4ff;
}

body.chat-shell.theme-light .model-type-image {
    color: #7c3aed;
    border-color: #c4b5fd;
    background: #f4efff;
}

body.chat-shell.theme-light .model-type-video {
    color: #c2415e;
    border-color: #fda4af;
    background: #fff0f3;
}

@media (max-width: 768px) {
    body.chat-shell.theme-light .sidebar {
        background: #f6f7fb;
        border-right-color: rgba(33, 29, 54, 0.1);
        box-shadow: 18px 0 40px rgba(42, 38, 70, 0.16);
    }

    body.chat-shell.theme-light .toggle-sidebar {
        color: #403b58;
        border-color: rgba(33, 29, 54, 0.12);
        background: rgba(255, 255, 255, 0.84);
    }
}
