/* ============================================================
   ADVANCED SEARCH FILTERS - RESPONSIVE DESIGN
   Production-ready styling for filter panel
   ============================================================ */

/* Filters Sidebar */
.filters-sidebar {
    width: 280px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: fit-content;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    position: relative;
}

/* Header */
.filters-header {
    padding: 16px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border-radius: 8px 8px 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.filters-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #2196F3;
}

.filters-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    display: none;
    padding: 0;
    width: 30px;
    height: 30px;
}

.filters-close-btn:hover {
    color: #000;
}

/* Content Area */
.filters-content {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}

/* Filter Group */
.filter-group {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.filter-group:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}

.filter-label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    color: #333;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Select/Input Elements */
.filter-select,
.filter-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.filter-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 20px;
    padding-right: 32px;
}

/* Checkboxes */
.filter-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-checkboxes label {
    display: flex;
    align-items: center;
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    margin: 0;
}

.filter-checkboxes input[type="checkbox"],
.filter-checkboxes input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
    width: 16px;
    height: 16px;
    accent-color: #2196F3;
}

/* Salary Range */
.salary-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.salary-inputs input {
    flex: 1;
}

.salary-separator {
    color: #999;
    flex-shrink: 0;
}

.salary-slider-container {
    margin-top: 8px;
}

.salary-slider {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.salary-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
}

.salary-slider::-webkit-slider-thumb:hover {
    width: 18px;
    height: 18px;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.5);
}

.salary-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
}

.salary-slider::-moz-range-thumb:hover {
    width: 18px;
    height: 18px;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.5);
}

/* Skills Tags */
.skills-input-container {
    position: relative;
    margin-bottom: 8px;
}

.selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.skill-tag {
    background: #2196F3;
    color: white;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    animation: slideIn 0.2s ease;
}

.skill-tag .remove-tag {
    cursor: pointer;
    background: none;
    border: none;
    color: white;
    padding: 0;
    font-size: 14px;
    line-height: 1;
}

.skill-tag .remove-tag:hover {
    opacity: 0.8;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Suggestions List */
.suggestions-list {
    list-style: none;
    margin: 4px 0 0 0;
    padding: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 150px;
    overflow-y: auto;
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
}

.suggestions-list.active {
    display: block;
}

.suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    transition: background 0.2s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: #f5f5f5;
}

/* Footer */
.filters-footer {
    padding: 16px;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 8px;
    background: white;
    border-radius: 0 0 8px 8px;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.filters-footer button {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-primary {
    background: #2196F3;
    color: white;
}

.btn-primary:hover {
    background: #1976D2;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e8e8e8;
}

/* Filter Count Badge */
.filter-count-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #f44336;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    z-index: 20;
}

.filter-count-badge.active {
    display: flex;
}

/* Presets List */
.presets-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 120px;
    overflow-y: auto;
}

.preset-item {
    padding: 8px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-item:hover {
    background: #f5f5f5;
    border-color: #2196F3;
}

.preset-item button {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preset-item button:hover {
    color: #f44336;
}

/* Mobile Toggle Button */
.toggle-filters-btn {
    display: none;
    background: #2196F3;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    gap: 8px;
    align-items: center;
    position: relative;
    margin-bottom: 12px;
}

.toggle-filters-btn:hover {
    background: #1976D2;
}

.filter-badge {
    background: #f44336;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
}

/* Search Results Container */
.job-search-container {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

.job-search-filters {
    flex-shrink: 0;
}

.job-search-main {
    flex: 1;
}

.search-header {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.search-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.search-input:focus {
    outline: none;
    border-color: #2196F3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.jobs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.job-card {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 16px;
    transition: all 0.2s;
    cursor: pointer;
}

.job-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.no-results i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-results h3 {
    margin: 16px 0 8px 0;
    color: #666;
}

/* Responsive Design */
@media (max-width: 992px) {
    .job-search-container {
        flex-direction: column;
    }

    .job-search-filters {
        width: 100%;
    }

    .filters-sidebar {
        width: 100%;
        max-height: none;
    }

    .toggle-filters-btn {
        display: flex;
    }

    .filters-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .filters-sidebar.active {
        transform: translateX(0);
    }

    .filters-close-btn {
        display: block;
    }

    .filters-content {
        height: calc(100vh - 140px);
    }

    .jobs-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 576px) {
    .search-header {
        flex-direction: column;
    }

    .toggle-filters-btn {
        width: 100%;
        justify-content: center;
    }

    .filters-sidebar {
        width: 100%;
    }

    .filters-content {
        padding: 12px;
    }

    .job-card {
        padding: 12px;
    }
}

/* Scrollbar Styling */
.filters-content::-webkit-scrollbar,
.presets-list::-webkit-scrollbar,
.suggestions-list::-webkit-scrollbar {
    width: 6px;
}

.filters-content::-webkit-scrollbar-track,
.presets-list::-webkit-scrollbar-track,
.suggestions-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.filters-content::-webkit-scrollbar-thumb,
.presets-list::-webkit-scrollbar-thumb,
.suggestions-list::-webkit-scrollbar-thumb {
    background: #bbb;
    border-radius: 3px;
}

.filters-content::-webkit-scrollbar-thumb:hover,
.presets-list::-webkit-scrollbar-thumb:hover,
.suggestions-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Print Styles */
@media print {
    .filters-sidebar,
    .toggle-filters-btn {
        display: none;
    }

    .job-search-container {
        flex-direction: column;
    }

    .job-search-main {
        width: 100%;
    }
}

/* Mobile Responsive Styles */
@media (max-width: 991.98px) {
    .filters-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 300px;
        height: 100vh;
        z-index: 1050;
        transition: left 0.3s ease;
        border-radius: 0;
        box-shadow: 2px 0 8px rgba(0,0,0,0.3);
    }

    .filters-sidebar.mobile-open {
        left: 0;
    }

    .filters-sidebar.active {
        left: 0;
    }

    /* Overlay for mobile */
    .filters-sidebar::before {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: -1;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .filters-sidebar.mobile-open::before,
    .filters-sidebar.active::before {
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 575.98px) {
    .filters-sidebar {
        width: 280px;
    }

    .filters-header h3 {
        font-size: 16px;
    }

    .filter-group {
        margin-bottom: 15px;
    }

    .filter-label {
        font-size: 14px;
        margin-bottom: 5px;
    }

    .filter-input,
    .filter-select {
        font-size: 14px;
        padding: 8px 12px;
    }

    .btn-primary,
    .btn-secondary {
        font-size: 14px;
        padding: 8px 16px;
    }
}

/* ============================================================
   INFINITE SCROLL STYLES
   Smooth scrolling and loading states
   ============================================================ */

/* Infinite Scroll Container */
#jobsContainer {
    position: relative;
    min-height: 400px;
}

.jobs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

/* Loading States */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    flex-direction: column;
    gap: 15px;
}

.loading-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-spinner .loading-text {
    color: #666;
    font-size: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Load More Button (Fallback) */
.load-more-container {
    text-align: center;
    margin: 30px 0;
    display: none; /* Hidden by default, shown if infinite scroll fails */
}

.load-more-btn {
    background: linear-gradient(135deg, #2196F3, #21CBF3);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.3);
}

.load-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4);
}

.load-more-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* No More Results */
.no-more-results {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 16px;
}

.no-more-results i {
    font-size: 48px;
    color: #ddd;
    margin-bottom: 15px;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Infinite Scroll Trigger */
.infinite-scroll-trigger {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.infinite-scroll-trigger.visible {
    opacity: 1;
}

/* Job Card Hover Effects for Infinite Scroll */
.job-card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.job-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

/* Performance Optimizations */
.jobs-grid .job-card {
    will-change: transform;
}

/* Mobile Infinite Scroll */
@media (max-width: 768px) {
    .infinite-scroll-trigger {
        height: 60px;
    }

    .loading-spinner {
        padding: 20px;
    }

    .loading-spinner .spinner {
        width: 30px;
        height: 30px;
        border-width: 3px;
    }
}
