/**
 * Amazon-Style Left Sidebar Layout CSS
 * Sticky sidebar with filters, results toolbar, and responsive behavior
 */

/* ===== LAYOUT STRUCTURE ===== */

.cpsc-layout {
    display: flex;
    gap: 0;
    max-width: 1920px;
    margin: 0 auto;
    position: relative;
}

/* ===== LEFT SIDEBAR ===== */

.filter-sidebar {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    flex-shrink: 0;
    background: var(--bg-card, #fff);
    border-right: 1px solid var(--border, #e0e0e0);
    height: calc(100vh - 76px); /* Account for header height */
    position: sticky;
    top: 76px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    box-sizing: border-box;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border, #e0e0e0);
    position: sticky;
    top: 0;
    background: var(--bg-card, #fff);
    z-index: 10;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
    margin: 0;
}

.btn-text-small {
    background: none;
    border: none;
    color: var(--primary, #007bff);
    font-size: 0.875rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    /* Global transitions from transitions.css apply */
}

.btn-text-small:hover {
    background: var(--bg-hover, #f5f5f5);
}

.sidebar-content {
    padding: 0 0 20px 0;
}

/* ===== SIDEBAR FILTER GROUPS ===== */

.sidebar-filter-group {
    padding: 16px;
    border-bottom: 1px solid var(--border, #e0e0e0);
}

.sidebar-filter-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
    margin-bottom: 12px;
}

.label-icon {
    opacity: 0.6;
}

.filter-count {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary, #666);
}

.sidebar-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.btn-text-mini {
    background: none;
    border: none;
    color: var(--primary, #007bff);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 6px;
}

.btn-text-mini:hover {
    text-decoration: underline;
}

/* ===== SIDEBAR INPUTS ===== */

.sidebar-input,
.sidebar-search {
    width: 100%;
    max-width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border, #ddd);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #1a1a1a);
    /* Global transitions from transitions.css apply */
    box-sizing: border-box;
}

.sidebar-input:focus,
.sidebar-search:focus {
    outline: none;
    border-color: var(--primary, #007bff);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* ===== RADIO BUTTONS ===== */

.sidebar-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.sidebar-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    /* Global transitions from transitions.css apply */
}

.sidebar-radio:hover {
    background: var(--bg-hover, #f5f5f5);
}

.sidebar-radio input[type="radio"] {
    cursor: pointer;
}

.sidebar-radio span {
    font-size: 0.875rem;
    color: var(--text-primary, #1a1a1a);
    word-break: break-word;
}

/* ===== DATE INPUTS ===== */

.sidebar-date-inputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-input-date {
    width: 100%;
    max-width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border, #ddd);
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #1a1a1a);
    box-sizing: border-box;
}

.sidebar-input-date:focus {
    outline: none;
    border-color: var(--primary, #007bff);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.date-separator {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary, #666);
}

/* ===== DROPDOWN ===== */

.sidebar-filter-box {
    position: relative;
    max-width: 100%;
}

.sidebar-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #ddd);
    border-radius: 6px;
    margin-top: 4px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    box-sizing: border-box;
}

.dropdown-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    /* Global transitions from transitions.css apply */
}

.dropdown-option:hover {
    background: var(--bg-hover, #f5f5f5);
}

.dropdown-option input[type="checkbox"] {
    cursor: pointer;
}

.dropdown-option span {
    font-size: 0.875rem;
    color: var(--text-primary, #1a1a1a);
    word-break: break-word;
    flex: 1;
}

/* ===== SELECTED PILLS ===== */

.sidebar-selected-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    max-width: 100%;
}

.sidebar-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-secondary, #f5f5f5);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-primary, #1a1a1a);
    max-width: 100%;
    box-sizing: border-box;
}

.sidebar-pill span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-pill button {
    background: none;
    border: none;
    color: var(--text-secondary, #666);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0 0 4px;
    flex-shrink: 0;
}

.sidebar-pill button:hover {
    color: var(--error, #d32f2f);
}

/* ===== APPLY BUTTON (mobile only) ===== */

.sidebar-actions {
    padding: 16px 20px 0;
    display: none; /* Hidden on desktop */
}

.sidebar-apply-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary, #007bff);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    /* Global transitions from transitions.css apply */
}

.sidebar-apply-btn:hover {
    background: var(--primary-dark, #0056b3);
}

/* ===== MAIN CONTENT AREA ===== */

.content-area {
    flex: 1;
    min-width: 0; /* Prevent flex item from overflowing */
    padding: 20px;
    background: var(--bg-primary, #fafafa);
}

/* ===== RESULTS TOOLBAR ===== */

.results-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 8px;
    margin-bottom: 16px;
}

.results-info {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.results-count {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary, #1a1a1a);
    white-space: nowrap;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-label {
    font-size: 0.9rem;
    color: var(--text-secondary, #666);
    white-space: nowrap;
}

.sort-select {
    padding: 6px 28px 6px 10px;
    border: 1px solid var(--border, #ddd);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #1a1a1a);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

.sort-select:focus {
    outline: none;
    border-color: var(--primary, #007bff);
}

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

.view-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-secondary, #f5f5f5);
    padding: 4px;
    border-radius: 8px;
}

.view-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--text-secondary, #666);
    cursor: pointer;
    /* Global transitions from transitions.css apply */
    white-space: nowrap;
}

.view-btn:hover {
    background: var(--bg-hover, #e0e0e0);
}

.view-btn.active {
    background: var(--bg-card, #fff);
    color: var(--text-primary, #1a1a1a);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.view-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ===== ACTIVE FILTERS CHIPS ===== */

.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border, #e0e0e0);
    border-radius: 8px;
    margin-bottom: 16px;
}

.filters-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary, #666);
    white-space: nowrap;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 0.8rem;
    /* Global transitions from transitions.css apply */
}

.filter-chip:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.chip-label {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-primary, #1a1a1a);
}

.chip-icon {
    width: 12px;
    height: 12px;
    opacity: 0.7;
    flex-shrink: 0;
}

.chip-remove {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-secondary, #888);
    display: flex;
    align-items: center;
    /* Global transitions from transitions.css apply */
    flex-shrink: 0;
}

.chip-remove:hover {
    color: var(--error, #d32f2f);
    transform: scale(1.1);
}

.chip-remove:focus {
    outline: 2px solid var(--primary, #007bff);
    outline-offset: 2px;
    border-radius: 2px;
}

.chip-remove svg {
    width: 14px;
    height: 14px;
}

/* ===== MOBILE FILTER TOGGLE ===== */

.mobile-filter-toggle {
    display: none;
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

.mobile-filter-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--primary, #007bff);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    /* Theme transitions from global, plus specific interactive transitions */
    transition:
        background-color var(--transition-theme),
        transform var(--transition-slow),
        box-shadow var(--transition-slow);
}

.mobile-filter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.mobile-filter-btn .icon {
    width: 20px;
    height: 20px;
}

.filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: white;
    color: var(--primary, #007bff);
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ===== RESPONSIVE: TABLET (≤1023px) ===== */

@media (max-width: 1023px) {
    .filter-sidebar {
        position: fixed;
        left: -280px;
        top: 76px;
        height: calc(100vh - 76px);
        transition: left 0.3s ease;
        z-index: 1001;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }

    .filter-sidebar.mobile-open {
        left: 0;
    }

    .mobile-filter-toggle {
        display: block;
    }

    .sidebar-actions {
        display: block;
    }

    .content-area {
        padding: 16px;
    }

    /* Overlay when sidebar is open */
    body.sidebar-open::after {
        content: '';
        position: fixed;
        top: 76px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1000;
    }
}

/* ===== RESPONSIVE: MOBILE (≤768px) ===== */

@media (max-width: 768px) {
    .results-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .results-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .toolbar-actions {
        justify-content: space-between;
    }

    .view-btn span {
        display: none;
    }

    .active-filters {
        padding: 12px;
    }

    .filter-chip {
        font-size: 0.8rem;
        padding: 6px 10px;
    }
}

/* ===== SCROLLBAR STYLING ===== */

.filter-sidebar::-webkit-scrollbar {
    width: 8px;
}

.filter-sidebar::-webkit-scrollbar-track {
    background: var(--bg-secondary, #f5f5f5);
}

.filter-sidebar::-webkit-scrollbar-thumb {
    background: var(--border, #ddd);
    border-radius: 4px;
}

.filter-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary, #999);
}

.sidebar-dropdown::-webkit-scrollbar {
    width: 6px;
}

.sidebar-dropdown::-webkit-scrollbar-track {
    background: var(--bg-secondary, #f5f5f5);
}

.sidebar-dropdown::-webkit-scrollbar-thumb {
    background: var(--border, #ddd);
    border-radius: 3px;
}
