/**
 * Homepage Styles
 * 
 * CSS for the wallpaper theme homepage
 *
 * @package Wallpaper
 * @since 1.0.0
 */

/* -----------------------------------------------------------------------------
 * Layout & Container
 * -------------------------------------------------------------------------- */
.wallpaper-container {
    width: 100%;
    margin-right: auto;
    margin-left: auto;
    padding-right: 20px;
    padding-left: 20px;
    box-sizing: border-box;
    display: flex;
    gap: 24px;
}

/* Advanced Search Sidebar */
.advanced-search-sidebar {
    width: 300px;
    min-width: 300px;
    position: sticky;
    top: 100px; /* Adjusted to account for header height */
    height: calc(100vh - 120px);
    max-height: calc(100vh - 120px); /* Ensure it doesn't grow beyond viewport */
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #ddd #f5f5f5;
    transition: all 0.3s ease;
    z-index: 10; /* Lower than header z-index */
    align-self: flex-start; /* Ensure the sidebar doesn't stretch */
    position: -webkit-sticky; /* Safari support */
    position: sticky;
}

.advanced-search-sidebar:hover {
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

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

.advanced-search-sidebar::-webkit-scrollbar-track {
    background: #f5f5f5;
    border-radius: 10px;
}

.advanced-search-sidebar::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 10px;
}

.advanced-search-sidebar::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

.sidebar-heading {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 24px;
    color: #333;
    position: relative;
    padding-bottom: 12px;
}

.sidebar-heading::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    border-radius: 3px;
}

.search-section {
    margin-bottom: 24px;
}

.search-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #666;
    margin: 0 0 12px;
}

.search-input-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    padding-left: 40px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: #f9fafb;
}

.search-input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background: #fff;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
}

.filter-group {
    margin-bottom: 20px;
}

.filter-option {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    cursor: pointer;
}

.filter-checkbox {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    margin-right: 10px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-checkbox:checked {
    background: #4f46e5;
    border-color: #4f46e5;
}

.filter-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.filter-checkbox:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.filter-label {
    font-size: 14px;
    color: #4b5563;
    user-select: none;
}

.filter-count {
    margin-left: auto;
    font-size: 12px;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 12px;
}

.range-slider {
    width: 100%;
    margin: 10px 0;
}

.range-slider-wrapper {
    position: relative;
    height: 30px;
    display: flex;
    align-items: center;
}

.range-slider-track {
    position: absolute;
    height: 4px;
    background: #e5e7eb;
    width: 100%;
    border-radius: 4px;
}

.range-slider-fill {
    position: absolute;
    height: 4px;
    background: #4f46e5;
    border-radius: 4px;
}

.range-slider-input {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: transparent;
    position: absolute;
    pointer-events: none;
}

.range-slider-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #4f46e5;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.range-slider-input::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #4f46e5;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.range-values {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: #6b7280;
}

.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #6b7280;
    pointer-events: none;
}

.custom-select {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: #f9fafb;
    cursor: pointer;
    color: #4b5563;
}

.custom-select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    background: #fff;
}

.columns-selector {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.column-option {
    flex: 1;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.column-option:hover {
    background: #f9fafb;
}

.column-option.active {
    border-color: #4f46e5;
    background: rgba(79, 70, 229, 0.05);
}

.column-icon {
    display: flex;
    gap: 2px;
    margin-bottom: 4px;
}

.column-icon span {
    width: 4px;
    height: 12px;
    background: #d1d5db;
    border-radius: 2px;
}

.column-option.active .column-icon span {
    background: #4f46e5;
}

.column-option[data-columns="3"] .column-icon span {
    width: 6px;
}

.column-option[data-columns="4"] .column-icon span {
    width: 4px;
}

.column-option[data-columns="5"] .column-icon span {
    width: 3px;
}

.column-option[data-columns="6"] .column-icon span {
    width: 2px;
}

.column-label {
    font-size: 10px;
    color: #6b7280;
}

.column-option.active .column-label {
    color: #4f46e5;
    font-weight: 500;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.tag {
    padding: 6px 12px;
    background: #f3f4f6;
    border-radius: 20px;
    font-size: 12px;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tag:hover {
    background: #e5e7eb;
}

.tag.active {
    background: #4f46e5;
    color: white;
}

.search-button {
    margin-top: auto;
    padding: 12px 16px;
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.search-button:hover {
    background: linear-gradient(90deg, #4338ca, #6d28d9);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.search-button:active {
    transform: translateY(0);
}

.search-button i {
    font-size: 16px;
}

.reset-filters {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
    color: #6b7280;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
}

.reset-filters:hover {
    color: #4f46e5;
    text-decoration: underline;
}

/* Wallpaper Grid */
.wallpaper-grid-container {
    flex: 1;
    padding-top: 0; /* Remove top padding as header spacing is handled globally */
    overflow: hidden;
    width: calc(100% - 324px); /* Account for sidebar width + gap */
}

.wallpaper-grid {
    width: 100%;
    margin: 0 auto;
    position: relative; /* Required for masonry layout */
    padding: 0; /* Remove padding as container already has padding */
}

/* Clear fix for masonry layout */
.wallpaper-grid:after {
    content: '';
    display: block;
    clear: both;
}

.wallpaper-item {
    position: relative;
    width: calc(16.666% - 13.334px);
    border-radius: 16px;
    overflow: hidden;
    background-color: #f0f0f0;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, opacity 0.3s ease;
    cursor: zoom-in;
    opacity: 0;
    line-height: 0;
    font-size: 0;
    margin-bottom: 16px;
    display: block;
    /* Better masonry handling */
    float: left; /* This helps with masonry layout */
}

.wallpaper-item:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1;
}

.wallpaper-item img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 16px;
    transition: filter 0.3s ease;
    vertical-align: top;
    object-fit: cover;
    margin: 0;
    padding: 0;
}

.wallpaper-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(0deg, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0) 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border-radius: 16px;
}

.wallpaper-item:hover::after {
    opacity: 1;
}

.wallpaper-item.loading {
    animation: pulse 1.5s infinite;
    min-height: 100px;
}

.wallpaper-item.loading::before {
    content: '';
    display: block;
    padding-top: 75%;
}

@keyframes pulse {
    0% { background-color: #f0f0f0; }
    50% { background-color: #e0e0e0; }
    100% { background-color: #f0f0f0; }
}

/* Responsive adjustments for grid items */
@media (max-width: 1600px) {
    .wallpaper-item {
        width: calc(20% - 12.8px);
    }
}

@media (max-width: 1200px) {
    .wallpaper-item {
        width: calc(25% - 12px);
    }
}

@media (max-width: 992px) {
    .wallpaper-container {
        flex-direction: column;
    }
    
    .wallpaper-grid-container {
        width: 100%;
    }
    
    .advanced-search-sidebar {
        width: 100%;
        min-width: 100%;
        position: relative;
        top: 0;
        height: auto;
        max-height: none;
        margin-bottom: 20px;
        border-radius: 16px;
        transition: max-height 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
        overflow: hidden;
        transform: translateY(0);
    }
    
    .filter-toggle-btn {
        display: flex;
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 50;
    }
    
    .advanced-search-sidebar.collapsed {
        max-height: 0;
        padding: 0;
        margin: 0;
        opacity: 0;
        transform: translateY(-20px);
        overflow: hidden;
        pointer-events: none;
    }
}

@media (max-width: 768px) {
    .wallpaper-container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .wallpaper-item {
        width: calc(33.333% - 8px);
    }
    
    .wallpaper-item-info {
        padding: 8px;
    }
    
    .wallpaper-item-info h3 {
        font-size: 14px;
    }
    
    .wallpaper-dimensions {
        font-size: 12px;
    }
    
    .wallpaper-download {
        padding: 6px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .wallpaper-container {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .wallpaper-item {
        width: calc(50% - 6px);
    }
}

/* -----------------------------------------------------------------------------
 * Wallpaper Item Info
 * -------------------------------------------------------------------------- */
.wallpaper-item-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(0deg, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0) 100%);
    padding: 16px;
    color: white;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    border-radius: 0 0 16px 16px;
    pointer-events: none;
}

.wallpaper-item:hover .wallpaper-item-info {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.wallpaper-item-info h3 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.wallpaper-dimensions {
    display: inline-block;
    font-size: 13px;
    opacity: 0.8;
    margin-bottom: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 4px;
}

.wallpaper-meta {
    display: flex;
    gap: 12px;
    font-size: 13px;
    opacity: 0.9;
}

.wallpaper-downloads, 
.wallpaper-likes {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* -----------------------------------------------------------------------------
 * No Wallpapers Message
 * -------------------------------------------------------------------------- */
.no-wallpapers {
    text-align: center;
    padding: 50px 30px;
    background: #f9fafb;
    border-radius: 16px;
    margin: 30px auto;
    width: 100%;
    max-width: 600px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.no-wallpapers p {
    font-size: 18px;
    color: #6b7280;
    margin-bottom: 15px;
}

.no-wallpapers .retry-search {
    display: inline-block;
    padding: 10px 20px;
    background: #4f46e5;
    color: white;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.no-wallpapers .retry-search:hover {
    background: #4338ca;
    transform: translateY(-2px);
}

/* -----------------------------------------------------------------------------
 * Responsive Adjustments
 * -------------------------------------------------------------------------- */
@media (max-width: 1400px) {
    .wallpaper-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1200px) {
    .wallpaper-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .wallpaper-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .wallpaper-grid {
        grid-template-columns: 1fr;
    }
    
    .wallpaper-item img {
        height: auto;
    }
}

/* -----------------------------------------------------------------------------
 * Loading States & Error Messages
 * -------------------------------------------------------------------------- */
.grid-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    text-align: center;
    min-width: 200px;
}

.loader-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(79, 70, 229, 0.2);
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

.loader-text {
    font-size: 16px;
    color: #4b5563;
    font-weight: 500;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.wallpaper-grid.loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.wallpaper-grid.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.5);
    z-index: 10;
}

.filter-error {
    background: #fee2e2;
    color: #b91c1c;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    font-weight: 500;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile filter toggle button */
.filter-toggle-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: #4caf50;
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(76, 175, 80, 0.4);
    transition: all 0.3s ease;
    z-index: 50;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.filter-toggle-btn:hover {
    background-color: #2c3e50;
    box-shadow: 0 6px 15px rgba(44, 62, 80, 0.3);
    transform: translateY(-3px);
}

/* Search in progress indicator */
.search-button.searching {
    background: #6b46c1;
    cursor: wait;
    position: relative;
    pointer-events: none;
}

.search-button.searching::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    margin-top: -10px;
    right: 15px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: search-spin 0.8s linear infinite;
}

@keyframes search-spin {
    to { transform: rotate(360deg); }
}

/* Filtered items transition */
.wallpaper-item {
    transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.wallpaper-item.filtered-visible {
    transition-delay: 0.1s;
}

/* Pagination Styles */
.wallpaper-pagination {
    margin-top: 40px;
    text-align: center;
    font-family: 'Nunito', sans-serif;
    color: #4b5563;
}

.wallpaper-pagination ul {
    display: inline-flex;
    list-style: none;
    margin: 0;
    padding: 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.wallpaper-pagination ul li {
    display: inline-block;
    margin: 0;
}

.wallpaper-pagination ul li a,
.wallpaper-pagination ul li span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    background-color: #ffffff;
    color: #4b5563;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.wallpaper-pagination ul li:not(:last-child) a,
.wallpaper-pagination ul li:not(:last-child) span {
    border-right: none;
}

.wallpaper-pagination ul li a:hover {
    background-color: #f9fafb;
    color: #4f46e5;
}

.wallpaper-pagination ul li span.current {
    background-color: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
}

.wallpaper-pagination .pagination-info {
    margin-top: 15px;
    font-size: 14px;
    color: #6b7280;
}

/* Make pagination responsive */
@media screen and (max-width: 576px) {
    .wallpaper-pagination ul li.page-numbers:not(.prev):not(.next):not(.current) {
        display: none;
    }
    
    .wallpaper-pagination ul li.page-numbers.dots {
        display: inline-block;
    }
} 