/**
 * Sidebar Styles
 * ==============
 * Single sidebar panel with tabs attached to its right edge.
 * Tabs slide out with the panel; clicking a tab switches content.
 * Updated to use CSS variables from the new design system.
 */

.sidebar-toggle-input { display: none; }

/* Container that slides - starts below floating logo */
.sidebar-container {
    position: fixed;
    top: 3.25rem;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width, 300px);
    z-index: 1020; /* Below floating brand (1030) */
    transform: translateX(calc(-1 * var(--sidebar-width, 300px)));
    transition: transform var(--transition-slow, 0.3s ease);
}

/* Show when any sidebar is open */
#sidebar-conversations:checked ~ .sidebar-container,
#sidebar-files:checked ~ .sidebar-container {
    transform: translateX(0);
}

/* Tabs on right edge of container */
.sidebar-tabs {
    position: absolute;
    top: 0.5rem;
    right: -32px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-tab {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    padding: 0.75rem 0.5rem;
    background: var(--accent-primary, #284139);
    color: var(--color-porcelain, #F3F4F1);
    border: none;
    border-radius: 0 var(--border-radius-md, 0.5rem) var(--border-radius-md, 0.5rem) 0;
    font-size: 0.8125rem;
    font-weight: var(--font-weight-medium, 500);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 
        2px 2px 6px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: 
        background-color var(--transition-fast, 0.15s ease),
        box-shadow var(--transition-fast);
}

.sidebar-tab:hover { 
    background: var(--accent-primary-hover, #1e332c);
    box-shadow: 
        3px 3px 8px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* Active tab styling */
#sidebar-conversations:checked ~ .sidebar-container .sidebar-tab[data-sidebar="conversations"],
#sidebar-files:checked ~ .sidebar-container .sidebar-tab[data-sidebar="files"] {
    background: var(--bg-s0);
    color: var(--text-strong, #111A19);
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
    border-left: 3px solid var(--accent-highlight);
}

/* Sidebar panels (stacked, only one visible) */
.sidebar {
    position: absolute;
    inset: 0;
    background: var(--bg-s0);
    border-right: 1px solid var(--border-default);
    border-top-right-radius: var(--border-radius-lg);
    box-shadow: 
        4px 0 16px rgba(0, 0, 0, 0.1),
        8px 0 24px rgba(0, 0, 0, 0.05);
    display: none;
    flex-direction: column;
    color: var(--text-default);
}

/* Dark mode fixes for sidebar */
[data-bs-theme="dark"] .sidebar {
    background: var(--bg-s0);
    border-right-color: var(--border-default);
}

[data-bs-theme="dark"] .sidebar__title,
[data-bs-theme="dark"] .sidebar .conversation-item,
[data-bs-theme="dark"] .sidebar .conversation-item__title,
[data-bs-theme="dark"] .sidebar .conversation-item__preview,
[data-bs-theme="dark"] .sidebar .conversation-item__date,
[data-bs-theme="dark"] .sidebar__placeholder {
    color: var(--text-default);
}

[data-bs-theme="dark"] .sidebar .conversation-item__date {
    color: var(--text-muted);
}

[data-bs-theme="dark"] .sidebar .conversation-item:hover {
    color: var(--text-strong);
}

#sidebar-conversations:checked ~ .sidebar-container .sidebar[data-sidebar="conversations"],
#sidebar-files:checked ~ .sidebar-container .sidebar[data-sidebar="files"] {
    display: flex;
}

/* Header */
.sidebar__header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-default, #C9D2C5);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar__title {
    margin: 0;
    font-size: 1rem;
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-strong);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar__close {
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    border-radius: var(--border-radius-sm, 0.375rem);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidebar__close:hover { 
    background: var(--accent-primary-light); 
    color: var(--text-strong);
}

/* Body */
.sidebar__body {
    flex: 1;
    padding: 0.5rem;
    overflow-y: auto;
}

.sidebar__placeholder {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* Backdrop - covers full screen including top */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1010; /* Below sidebar container */
    cursor: pointer;
}

#sidebar-conversations:checked ~ .sidebar-backdrop,
#sidebar-files:checked ~ .sidebar-backdrop {
    display: block;
}
