/* LLM Studio - Sidebar & Navigation Drawer */

.sidebar {
    width: 300px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 18px;
    gap: 16px;
    transition: margin-left 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s ease;
    z-index: 20;
    box-shadow: var(--shadow-sm);
    min-height: 0;
    overflow-y: hidden;
    overflow-x: hidden;
}

.sidebar.collapsed {
    margin-left: -300px;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 0 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.qwen-mark {
    padding: 6px;
}

.brand-icon.qwen-mark {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.qwen-logo-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.history-section {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    /* Let the history scroller reach the sidebar edge while the header/new-chat stay fixed. */
    margin-right: -18px;
    padding-right: 18px;
    scrollbar-gutter: stable;
}

.history-list {
    min-height: 0;
    flex: 0 0 auto;
}

.brand-text h2 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.brand-text .badge {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--accent-teal);
    background: rgba(13, 148, 136, 0.12);
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid rgba(13, 148, 136, 0.25);
    display: inline-block;
}

.btn {
    padding: 11px 16px;
    border-radius: var(--radius-md);
    border: none;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: var(--shadow-glow);
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 0 0 auto;
    min-height: 0;
    overflow: visible;
}

.history-section {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow-y: auto;
    overflow-x: hidden;
    margin-right: -18px;
    padding-right: 18px;
    scrollbar-gutter: stable;
}

.history-section::-webkit-scrollbar {
    width: 10px;
}

.history-section::-webkit-scrollbar-track {
    background: transparent;
}

.history-section::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.48);
    border: 3px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

.history-section::-webkit-scrollbar-thumb:hover {
    background: rgba(79, 70, 229, 0.7);
    border: 2px solid transparent;
    background-clip: padding-box;
}

.section-title {
    font-size: 11.5px;
    text-transform: uppercase;
    color: var(--text-subtle);
    font-weight: 700;
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item {
    min-height: 74px;
    flex: 0 0 auto;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-item:hover, .history-item.active {
    background: rgba(99, 102, 241, 0.08);
    color: var(--primary);
    font-weight: 500;
}

.settings-section {
    flex: 0 0 auto;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
    gap: 12px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.setting-item label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.label-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 500;
}

.setting-item textarea, .setting-item input[type="range"] {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12px;
    resize: none;
}

.setting-item textarea:focus {
    border-color: var(--primary);
    outline: none;
}

.server-status-card {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
    flex-shrink: 0;
}

.status-indicator.online {
    background: #10b981;
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.7);
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.8; }
}

.status-title {
    font-size: 12px;
    font-weight: 600;
}

.status-sub {
    font-size: 10.5px;
    color: var(--text-muted);
}

/* Mobile Sidebar Backdrop Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 19;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
