/* Sidebar Layout Styles */

/* Content Wrapper - Main layout container */
.content-wrapper {
    display: flex;
    gap: 0;
    width: 100%;
    position: relative;
    height: 100%; /* Full height of parent */
    min-height: 0; /* Allow children to size and scroll */
    overflow: hidden; /* Only child areas should scroll */
    /* No margin or padding - parent handles spacing */
}

/* Ensure content wrapper always takes full height regardless of loading state */
.main-content.visible .content-wrapper {
    height: calc(100vh - var(--header-height, 80px) - 48px); /* Full viewport minus header and padding */
}

/* Align main content flush with header and left edge */
.main-content {
    /* Padding handled by sticky-fix.css */
    padding-left: 0 !important;
    padding-right: 0 !important; /* Ensure no right-side offset affects sticky alignment */
    margin: 0 !important; /* Remove any margin that might conflict */
}

/* Left Sidebar for Filters */
.filters-sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-secondary, #141414);
    border-right: 1px solid var(--border, #2a2a2a);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: sticky;
    top: 0; /* Stick to top within content-wrapper (which sits below header) */
    height: 100%;
    overflow-y: auto;
    z-index: 40; /* Below timeline (50) and header (100), but above content */
}

/* Collapsed sidebar state */
.filters-sidebar.collapsed {
    width: 50px;
    min-width: 50px;
}

.filters-sidebar.collapsed .sidebar-content,
.filters-sidebar.collapsed .sidebar-header h3 {
    display: none;
}

/* Sidebar Header */
.sidebar-header {
    padding: 16px;
    /* Removed border-bottom for cleaner look */
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Removed background color - inherit from parent */
    position: sticky;
    top: 0; /* Stick within sidebar container */
    z-index: 1;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.filters-sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Sidebar Content */
.sidebar-content {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

.filter-section {
    margin-bottom: 20px;
}

.filter-section label {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-section input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
}

.filter-section input:focus {
    outline: none;
    border-color: var(--accent-blue, #4a9eff);
    background: var(--bg-tertiary);
}

.date-range-hint {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* Filter Actions */
.filter-actions {
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-actions button {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: var(--accent-blue, #4a9eff);
    color: white;
    border-color: var(--accent-blue, #4a9eff);
}

.btn-primary:hover {
    background: #5ba5ff;
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-import, .btn-export {
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
}

.btn-import:hover, .btn-export:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.export-buttons {
    display: flex;
    gap: 4px;
}

.btn-export {
    flex: 1;
    padding: 8px;
}

/* Results Area */
.results-area {
    flex: 1;
    position: relative;
    overflow: auto; /* Make only the content scrollable */
    padding: 0 20px 20px 20px; /* Remove top padding so sticky timeline sits at top of scroll */
    background: var(--bg-primary);
    height: 100%;
    min-height: 0; /* Enable proper overflow */
    display: flex;
    flex-direction: column;
}

/* Floating View Controls */
.floating-view-controls {
    position: fixed;
    top: calc(var(--header-height, 80px) + 170px);
    left: 300px; /* Sidebar width + gap */
    z-index: 10;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Adjust when sidebar is collapsed */
.filters-sidebar.collapsed ~ .results-area .floating-view-controls {
    left: 70px;
}

/* View controls toggle button */
.view-controls-toggle {
    width: 48px;
    height: 48px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.view-controls-toggle:hover {
    background: var(--bg-secondary);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* View controls panel */
.view-controls-panel {
    position: absolute;
    top: 0;
    left: 56px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    display: none;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    min-width: 200px;
}

.floating-view-controls.expanded .view-controls-panel {
    display: flex;
}

.floating-view-controls.expanded .view-controls-toggle {
    background: var(--bg-secondary);
}

/* Sidebar-integrated view controls */
.floating-view-controls[data-integrated="true"] {
    position: static;
    top: auto;
    left: auto;
    z-index: auto;
    width: 100%;
    margin-bottom: 16px;
}

.floating-view-controls[data-integrated="true"] .view-controls-toggle {
    display: none;
}

.floating-view-controls[data-integrated="true"] .view-controls-panel {
    position: static;
    left: auto;
    display: flex;
    width: 100%;
    box-shadow: none;
}

/* Prevent overflow within sidebar for card size control */
.floating-view-controls[data-integrated="true"] .card-size-control {
    display: grid;
    grid-template-columns: 16px 1fr 16px auto;
    align-items: center;
    column-gap: 8px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.floating-view-controls[data-integrated="true"] .card-size-slider {
    width: 100%;
    min-width: 0;
}

.floating-view-controls[data-integrated="true"] .card-size-value {
    white-space: nowrap;
    text-align: right;
}

/* View mode buttons */
.view-mode-buttons {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-primary);
    border-radius: 6px;
}

.view-mode-btn {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.view-mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.view-mode-btn.active {
    background: var(--accent-blue, #4a9eff);
    color: white;
}

/* Card size control in floating panel */
.view-controls-panel .card-size-control {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 6px;
}

.card-size-icon {
    width: 16px;
    height: 16px;
    opacity: 0.5;
}

.card-size-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

.card-size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-blue, #4a9eff);
    border-radius: 50%;
    cursor: pointer;
}

.card-size-value {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: right;
}

/* Timeline mode selector in floating panel */
.view-controls-panel .timeline-mode-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-primary);
    border-radius: 6px;
}

.timeline-mode-nav {
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.timeline-mode-nav:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.timeline-mode-label {
    flex: 1;
    text-align: center;
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .filters-sidebar {
        width: 240px;
        min-width: 240px;
    }
    
    .floating-view-controls {
        left: 260px;
    }
}

@media (max-width: 968px) {
    /* Hide sidebar on tablets and mobile */
    .filters-sidebar {
        display: none;
    }
    
    .results-area {
        padding: 10px;
    }
    
    /* Move floating controls to a more accessible position */
    .floating-view-controls {
        left: 20px !important;
        top: calc(var(--header-height, 80px) + 160px);
    }
}

@media (max-width: 480px) {
    .floating-view-controls {
        left: 10px !important;
        top: calc(var(--header-height, 60px) + 140px);
    }
    
    .view-controls-toggle {
        width: 40px;
        height: 40px;
    }
    
    .view-controls-panel {
        left: 48px;
        min-width: 160px;
        padding: 8px;
    }
}

/* Hide legacy elements - but only in main app, not instances */
.main-content .search-filters {
    display: none !important;
}

/* Instance mode adjustments */
.instance-mode .filters-sidebar {
    display: none !important;
}

.instance-mode .results-area {
    width: 100%;
}

.instance-mode .floating-view-controls {
    display: none !important;
}
