/* ── SignalCraft Sidebar ── */

.sc-sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    height: calc(100vh - 60px);
    width: 300px;
    background: rgba(255, 255, 255, 0.98);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 1000;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Mono', 'Monaco', monospace;
}

.sc-sidebar.collapsed {
    width: 56px;
}

/* ── Header ── */

.sc-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    min-height: 48px;
    max-height: 48px;
    box-sizing: border-box;
}

.sc-sidebar-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #000;
    white-space: nowrap;
    overflow: hidden;
}

.sc-sidebar-indicator {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    flex-shrink: 0;
    animation: sc-pulse 2s infinite;
}

@keyframes sc-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.sc-sidebar.collapsed .sc-sidebar-header-title span {
    display: none;
}

.sc-sidebar.collapsed .sc-sidebar-header {
    justify-content: center;
    padding: 16px 0;
}

/* ── Toggle Button ── */

.sc-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    cursor: pointer;
    border: none;
    background: none;
    color: rgba(0, 0, 0, 0.4);
    transition: color 0.2s;
    flex-shrink: 0;
}

.sc-sidebar-toggle:hover {
    color: #000;
}

.sc-sidebar-toggle svg {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.sc-sidebar.collapsed .sc-sidebar-toggle svg {
    transform: rotate(180deg);
}

/* ── Navigation ── */

.sc-sidebar-nav {
    flex-shrink: 0;
    padding: 0 0 8px 0;
}

.sc-sidebar-lane-gap {
    height: 1px;
    margin: 8px 12px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.08), transparent);
}

.sc-sidebar.collapsed .sc-sidebar-lane-gap {
    display: none;
}

.sc-sidebar-section {
    margin-bottom: 2px;
}

.sc-sidebar-section-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    text-decoration: none;
    color: rgba(0, 0, 0, 0.55);
    transition: color 0.2s, background 0.2s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    position: relative;
}

.sc-sidebar-section-header-text {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.sc-sidebar-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.3;
}

.sc-sidebar-section-subtitle {
    font-size: 11px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: rgba(0, 0, 0, 0.45);
    margin-top: 4px;
    line-height: 1.35;
    white-space: normal;
}

.sc-sidebar-section-header:hover {
    color: #000;
    background: rgba(0, 0, 0, 0.03);
}

.sc-sidebar-section-header.active {
    color: #8b5cf6;
}

.sc-sidebar-section-header.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: #8b5cf6;
    border-radius: 0 2px 2px 0;
}

.sc-sidebar-section-header svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

.sc-sidebar.collapsed .sc-sidebar-section-header .sc-sidebar-section-header-text {
    display: none;
}

.sc-sidebar.collapsed .sc-sidebar-section-header {
    justify-content: center;
    padding: 12px 0;
}

.sc-sidebar.collapsed .sc-sidebar-section-header.active::before {
    top: 6px;
    bottom: 6px;
}

/* ── Sub-links ── */

.sc-sidebar-sublinks {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease;
}

.sc-sidebar-section.expanded .sc-sidebar-sublinks {
    max-height: 280px;
}

.sc-sidebar.collapsed .sc-sidebar-sublinks {
    display: none;
}

.sc-sidebar-sublink {
    display: block;
    padding: 6px 16px 6px 46px;
    color: rgba(0, 0, 0, 0.45);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: color 0.2s, background 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sc-sidebar-sublink:hover {
    color: #000;
    background: rgba(0, 0, 0, 0.03);
}

.sc-sidebar-sublink.active {
    color: #8b5cf6;
    font-weight: 600;
}

/* ── Divider ── */

.sc-sidebar-divider {
    height: 1px;
    background: rgba(0, 0, 0, 0.06);
    margin: 4px 16px;
    flex-shrink: 0;
}

.sc-sidebar.collapsed .sc-sidebar-divider {
    margin: 4px 10px;
}

/* ── Recent Reports ── */

.sc-sidebar-recent {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0 16px 0;
    min-height: 0;
}

.sc-sidebar-recent-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px 6px;
    color: rgba(0, 0, 0, 0.35);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.sc-sidebar.collapsed .sc-sidebar-recent-header span {
    display: none;
}

.sc-sidebar.collapsed .sc-sidebar-recent-header {
    justify-content: center;
    padding: 10px 0 6px;
    cursor: pointer;
}

.sc-sidebar.collapsed .sc-sidebar-recent-header:hover svg {
    color: #8b5cf6;
}

.sc-sidebar-recent-header svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.sc-sidebar-report-item {
    display: block;
    padding: 7px 16px 7px 46px;
    text-decoration: none;
    color: rgba(0, 0, 0, 0.55);
    font-size: 12px;
    transition: color 0.2s, background 0.2s;
    overflow: hidden;
}

.sc-sidebar-report-item:hover {
    color: #000;
    background: rgba(0, 0, 0, 0.03);
}

.sc-sidebar-report-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sc-sidebar-report-date {
    font-size: 10px;
    color: rgba(0, 0, 0, 0.3);
    margin-top: 1px;
}

.sc-sidebar.collapsed .sc-sidebar-report-item {
    display: none;
}

.sc-sidebar-empty {
    padding: 8px 16px 8px 46px;
    color: rgba(0, 0, 0, 0.25);
    font-size: 11px;
}

/* ── Tooltips (collapsed state) ── */

.sc-sidebar.collapsed .sc-sidebar-section-header::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
    margin-left: 8px;
    z-index: 1001;
    text-transform: none;
    letter-spacing: 0;
}

.sc-sidebar.collapsed .sc-sidebar-section-header:hover::after {
    opacity: 1;
}

/* ── Content Margin Adjustments ── */

.sidebar-expanded {
    margin-left: 300px !important;
    transition: margin-left 0.3s ease, margin-right 0.3s ease !important;
}

.sidebar-collapsed {
    margin-left: 56px !important;
    transition: margin-left 0.3s ease, margin-right 0.3s ease !important;
}

/* ── Scrollbar ── */

.sc-sidebar-recent::-webkit-scrollbar {
    width: 3px;
}

.sc-sidebar-recent::-webkit-scrollbar-track {
    background: transparent;
}

.sc-sidebar-recent::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.08);
    border-radius: 2px;
}

.sc-sidebar-recent::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* ── Assistant overrides ── */

.ai-chat-rail .chat-messages {
    padding-top: 1rem !important;
}

/* ── Assistant header override (match sidebar header) ── */

.ai-chat-rail .chat-header {
    padding: 12px 16px !important;
    min-height: 48px !important;
    max-height: 48px !important;
    box-sizing: border-box !important;
}

.ai-chat-rail .chat-title {
    font-size: 14px !important;
    font-weight: 600 !important;
    gap: 8px !important;
}

.ai-chat-rail .chat-close {
    font-size: 16px !important;
    padding: 2px 4px !important;
    line-height: 1 !important;
}

.ai-chat-rail .chat-action-btn {
    font-size: 11px !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
}

/* ── Responsive: hide sidebar on small screens ── */

@media (max-width: 1100px) {
    .sc-sidebar {
        display: none;
    }

    .sidebar-expanded,
    .sidebar-collapsed {
        margin-left: 0 !important;
    }
}
