/* --- Loader Overlay --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--purple-dark) 0%, #3d0070 100%);
    z-index: 5000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s, visibility 0.5s;
    color: white;
    flex-direction: column;
}
.loading-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.luxury-loader {
    text-align: center;
    padding: 30px;
}
.luxury-loader p {
    font-size: 1.2rem;
    font-weight: 300;
    margin-top: 20px;
    letter-spacing: 1px;
}

/* Luxury Spinner design */
.spinner {
    width: 80px;
    height: 80px;
    border: 8px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffd700; /* Gold color for luxury */
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
    margin: 0 auto;
}

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

/* --- Full Page View for Collections --- */
.full-page-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 1000;
    padding-top: 0; 
    overflow-y: auto;
    display: none; 
}
.full-page-view.active {
    display: block;
}

/* Back button adjustment */
.full-page-view .back-btn {
    position: absolute; 
    top: 20px;
    left: 20px;
    z-index: 1010; 
    padding: 8px 15px;
    font-size: 14px;
}

/* Adjust page title margin since controls are below */
.full-page-view .page-title {
    text-align: center;
    font-size: 32px;
    margin: 20px 0 10px; 
    color: var(--purple-dark);
}

/* NEW: Product Controls (Search and Sort) */
.product-controls {
    position: sticky;
    top: 0; 
    z-index: 1004;
    padding: 10px 18px;
    background: #fff;
    border-bottom: 1px solid var(--accent);
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.03);
}

.search-bar {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 8px 12px;
}
.search-bar i {
    color: var(--muted);
    margin-right: 8px;
}
.search-bar input {
    flex-grow: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    padding: 0;
}

.control-group {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.sort-dropdown-wrapper label {
    font-size: 14px;
    color: var(--muted);
    margin-right: 8px;
    font-weight: 400;
}
.sort-dropdown-wrapper select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--accent);
    background: white;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    outline: none;
}

/* Filter sections below controls */
.filter-container {
    padding: 10px 0;
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
}

.filter-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--purple-dark);
    margin: 0 18px 8px;
}

/* Unified style for scrollable filter rows */
.filter-scroll-row {
    padding: 0 18px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

/* Filter button styling (generic) */
.filter-btn {
    border: 1px solid var(--accent);
    background: white;
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    margin: 0; 
}
.filter-btn:hover {
    border-color: var(--purple);
}
.filter-btn.active {
    background: var(--purple);
    color: white;
    border-color: var(--purple);
    font-weight: 600;
}


/* Specific styling for the generated collections structure */
.collection-section {
    padding: 18px;
    margin-bottom: 40px;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}
.collection-section h2 {
    font-size: 28px;
    color: var(--purple);
    border-bottom: 2px solid var(--accent);
    padding-bottom: 10px;
    margin-bottom: 20px;
}
.products-grid-lg {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}

/* Ensure product styling looks good in the large grid context */
.products-grid-lg .product {
    padding: 15px;
}
.products-grid-lg .product .thumb {
    height: 180px; /* Larger thumbnail */
}
.products-grid-lg .product .name { 
    font-size: 16px; 
}
.products-grid-lg .product .add-btn {
    padding: 8px;
}

.no-results {
    text-align: center;
    padding: 50px 0;
    font-size: 18px;
    color: var(--muted);
}

/* Responsive adjustments */
@media(max-width:400px) {
    .products-grid-lg {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media(min-width:700px){
  /* NEW: Collections Page Responsive Controls */
    .product-controls {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        max-width: 1200px;
        margin: 0 auto;
        padding: 10px 0;
    }
    .search-bar {
        flex-basis: 60%;
        max-width: 500px;
    }
    .control-group {
        flex-basis: 30%;
        justify-content: flex-end;
    }
    
    .filter-container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 10px 0;
    }
    /* Remove padding on filter rows/titles since container is centered */
    .filter-title {
        margin-left: 0; 
        padding-left: 0;
    }
    .filter-scroll-row {
        padding-left: 0;
        padding-right: 0;
    }
}