/* Affiliate Product Showcase Styles (Premium UI) */

.aps-wrapper {
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    padding: 0 1.25rem;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.aps-wrapper>*:last-child {
    margin-bottom: 0 !important;
}

/* --- Filter Bar --- */
.aps-filters {
    margin-bottom: 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* 1. Top Search Row */
.aps-search-row {
    width: 100%;
    margin-top: 30px;
    /* Gap above search box as requested */
}

.aps-search-row input {
    width: 100%;
    padding: 12px 20px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 50px;
    /* Rounded search bar */
    outline: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.aps-search-row input:focus {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    /* Highlight focus */
    border-color: #bbb;
}

/* 2. Filter Controls Row (Brands + Dropdowns) */
.aps-filter-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* Left Side: Brand Pills */
.aps-brands-section {
    display: flex;
    flex: 1;
    /* Take remaining space */
    min-width: 300px;
    /* Prevent squishing */
    gap: 12px;
    align-items: center;
}

.aps-pills-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 5px;
    /* Space for scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-grow: 0;
    /* Do not force grow, keeps button nearby */
    max-width: 100%;
    /* Let flexbox handle sizing */
    align-items: center;
}

.aps-pills-scroll::-webkit-scrollbar {
    display: none;
}

.aps-pill {
    background: #f1f3f5;
    border: none;
    padding: 10px 24px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex-shrink: 0;
    /* Don't shrink pills */
}

.aps-pill:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

.aps-pill.active {
    background: #000;
    color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Dropdown */
.aps-brand-dropdown-wrapper {
    position: relative;
    display: inline-block;
}

.aps-brand-dropdown-btn .dashicons {
    font-size: 14px;
    height: 14px;
    width: 14px;
    margin-left: 5px;
    line-height: 1.5;
}

.aps-brand-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 12px;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.15);
    z-index: 100;
    min-width: 200px;
    padding: 10px;
    margin-top: 5px;
    display: none;
    /* Hidden by default */
}

.aps-brand-dropdown.show {
    display: block;
}

.aps-brand-search {
    width: 100%;
    border: 1px solid #eee;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 8px;
    box-sizing: border-box;
}

.aps-brand-list {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.aps-brand-item {
    background: none;
    border: none;
    text-align: left;
    padding: 8px 12px;
    font-size: 14px;
    color: #555;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.aps-brand-item:hover {
    background: #f8f9fa;
}

.aps-brand-item.selected {
    background: #f1f3f5;
    font-weight: 600;
    color: #000;
}


/* Right Side: Dropdowns */
.aps-dropdown-group {
    display: flex;
    gap: 15px;
    flex-shrink: 0;
    /* Keep size stable */
    align-items: center;
}

.aps-dropdown-group select {
    padding: 10px 16px;
    border: 1px solid #eee;
    background: #f9f9f9;
    font-size: 14px;
    border-radius: 12px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
}

.aps-dropdown-group select:hover {
    background: #f1f1f1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .aps-filter-controls {
        flex-direction: column-reverse;
        /* Dropdowns on top on mobile, or bottom? User asked for Brand Below Search. */
        align-items: flex-start;
    }

    .aps-brands-section {
        width: 100%;
        /* removed overflow-x: auto to fix dropdown clipping */
        flex-wrap: wrap;
        /* Allow wrapping if needed */
    }

    .aps-pills-scroll {
        max-width: 100%;
    }

    .aps-dropdown-group {
        width: 100%;
        justify-content: space-between;
    }

    .aps-dropdown-group select {
        flex: 1;
    }

    /* Fix dropdown position on mobile to prevent off-screen */
    .aps-brand-dropdown {
        left: auto;
        right: 0;
        min-width: 180px;
    }
}


/* --- Grid --- */
.aps-grid {
    display: grid;
    /* Default Desktop */
    grid-template-columns: repeat(var(--aps-cols-desktop, 4), minmax(0, 1fr));
    gap: 30px;
    transition: opacity 0.3s ease;
}

/* Tablet Breakpoint */
@media (max-width: 1023px) {
    .aps-grid {
        grid-template-columns: repeat(var(--aps-cols-tablet, 2), 1fr);
    }
}

/* Mobile Breakpoint */
@media (max-width: 767px) {
    .aps-grid {
        grid-template-columns: repeat(var(--aps-cols-mobile, 1), 1fr);
        gap: 20px;
        /* Smaller gap on mobile */
    }
}

.aps-grid.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* --- Premium Card --- */
.aps-card {
    background: #fff;
    border-radius: 24px;
    overflow: hidden;
    /* Soft premium shadow */
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.aps-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.12);
}

.aps-card-image {
    height: auto;
    aspect-ratio: 16 / 9;
    background: #f8f9fa;
    /* Pastel placeholder */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    justify-content: center;
    overflow: hidden;
    margin: var(--aps-img-margin, 10px);
    border-radius: 18px;
    /* Inner rounded corners similar to App Store */
}

.aps-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.aps-card:hover .aps-card-image img {
    transform: scale(1.05);
}

.aps-card-body {
    padding: 15px 25px 25px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    text-align: center;
}

.aps-title {
    font-size: 1.125rem;
    font-weight: 800;
    margin: 0 0 5px;
    color: #1a1a1a;
    letter-spacing: -0.02em;
    /* Clamped Lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
    min-height: 2.6em;
    /* Reserve height for 2 lines */
}

.aps-excerpt {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #666;
    margin-bottom: 20px;
    /* Clamped Lines */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 4.5em;
    /* Explicit height for 3 lines */
}

.aps-pricing-container {
    margin-bottom: 10px;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    /* Centered for card view */
}

.aps-mrp {
    text-decoration: line-through;
    color: #999;
    font-size: 0.9em;
    font-weight: 500;
}

.aps-price {
    font-weight: 700;
    color: #000;
    font-size: 16px;
    display: inline-block;
}

.aps-rating {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-bottom: 15px;
}

.aps-star {
    position: relative;
    display: inline-block;
    width: 20px;
    height: 20px;
    font-size: 20px;
    line-height: 1;
}

.aps-star .dashicons {
    width: 20px;
    height: 20px;
    font-size: 20px;
    margin: 0;
    padding: 0;
}

.aps-star .dashicons-star-empty {
    color: #e2e2e2;
    /* Light gray for empty */
}

.aps-star .dashicons-star-filled {
    position: absolute;
    top: 0;
    left: 0;
    color: #ffb900;
    overflow: hidden;
    white-space: nowrap;
    width: 0%;
    /* Default to 0, controlled inline */
    z-index: 1;
}

/* Actions Container */
.aps-actions {
    margin-top: auto;
    display: flex;
    gap: 10px;
}

/* Primary Button (Buy Now) */
.aps-btn-primary {
    display: block;
    flex: 1;
    background: #000;
    color: #fff;
    padding: 12px 0;
    border-radius: 50px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s;
    text-align: center;
    border: 1px solid #000;
}

.aps-btn-primary:hover {
    background: #333;
    border-color: #333;
    color: #fff;
}

/* Secondary Button (Read More) */
.aps-btn-secondary {
    display: block;
    flex: 1;
    background: transparent;
    color: #000;
    padding: 12px 0;
    border-radius: 50px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s;
    text-align: center;
    border: 1px solid #eee;
}

.aps-btn-secondary:hover {
    border-color: #000;
    background: #fff;
    color: #000;
}

/* Pagination */
.aps-pagination {
    margin-top: 40px;
    border-top: none;
    gap: 10px;
}

.aps-pagination a,
.aps-pagination span {
    border: none;
    background: #f1f3f5;
    border-radius: 50%;
    /* Circles */
    width: 40px;
    height: 40px;
    font-weight: 600;
}

.aps-pagination span.current {
    background: #000;
    color: #fff;
}

@media (max-width: 600px) {
    .aps-card-image {
        height: 180px;
    }
}

/* Load More Button */
.aps-load-more-wrapper {
    text-align: center;
    margin-top: 30px;
    clear: both;
    width: 100%;
    grid-column: 1 / -1;
    /* Force span across all columns */
}

.aps-load-more {
    display: inline-block;
    padding: 12px 24px;
    background-color: #f1f1f1;
    color: #333;
    border: 1px solid #ccc;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.3s ease;
}

.aps-load-more:hover {
    background-color: #e0e0e0;
    border-color: #bbb;
}


/* --- Multi-Image Slider --- */
.aps-card-slider {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* Hide scrollbar */
    display: flex;
    /* Horizontal Layout */
}

.aps-slide {
    min-width: 100%;
    /* Full Width */
    height: 100%;
    position: relative;
    /* Not absolute */
    opacity: 1;
    /* Always visible */
    transition: none;
    /* JS handles animation */
}

.aps-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* =========================================
   11. MOBILE APP POLISH (APS)
   ========================================= */
@media (max-width: 768px) {

    /* 1. Feed Layout */
    .aps-grid {
        grid-template-columns: 1fr !important;
        gap: 24px;
    }

    /* 2. Filters & Search */
    .aps-search-row {
        margin-top: 15px;
        margin-bottom: 15px;
    }

    .aps-filter-controls {
        gap: 15px;
    }

    .aps-brands-section {
        width: 100%;
        overflow-x: visible;
        /* No scroll */
        flex-wrap: wrap;
        /* Standard wrapping */
        padding-bottom: 0;
        justify-content: flex-start;
        /* or center? Start is safer */
    }

    .aps-pills-scroll {
        max-width: 100%;
        gap: 10px;
        flex-wrap: wrap;
        /* Wrap pills */
        overflow-x: visible;
        scrollbar-width: auto;
    }

    .aps-pill {
        padding: 8px 20px;
        font-size: 14px;
    }

    /* Dropdowns */
    .aps-dropdown-group {
        width: 100%;
        flex-direction: row;
        /* Keep side by side or stack? Row is better for space */
    }

    /* 3. Card "App" Feel (Standard Full Bleed) */
    .aps-card {
        border-radius: 20px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08) !important;
        /* Restored Shadow */
        margin-bottom: 24px;
        border: none;
        background: #fff;
    }

    .aps-card-image {
        border-radius: 18px;
        /* Uniform radius */
        margin: var(--aps-img-margin, 10px);
        /* Inset margin */
        width: auto;
        /* Allow flex/block sizing with margin */
        aspect-ratio: 16 / 10;
        /* Standard landscape/cinematic */
        background: #eee;
    }

    .aps-card-body {
        padding: 16px 20px 24px !important;
        text-align: left;
    }

    .aps-title {
        font-size: 19px;
        font-weight: 600;
        margin-bottom: 8px;
        font-family: var(--font-heading);
        line-height: 1.3;
    }

    .aps-excerpt {
        display: block;
        /* Show excerpt again */
        font-size: 14px;
        color: #777;
        margin-bottom: 12px;
        line-height: 1.5;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .aps-rating {
        display: flex;
        /* Show ratings */
        margin-bottom: 12px;
    }

    .aps-pricing-container {
        justify-content: flex-start;
        margin-bottom: 16px;
    }

    .aps-price {
        font-size: 18px;
        font-weight: 700;
        color: #000;
    }

    .aps-actions {
        flex-direction: row;
        gap: 12px;
        border: none;
    }

    /* Buttons Restored */
    .aps-btn-primary {
        background: #000;
        color: #fff;
        border-radius: 50px;
        /* Pill */
        font-weight: 600;
        font-size: 15px;
        text-transform: none;
        letter-spacing: 0;
        padding: 14px 24px;
        flex: 2;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    .aps-btn-secondary {
        display: inline-block;
        flex: 1;
        text-align: center;
        padding: 14px 0;
        font-size: 15px;
        color: #666;
        background: #f5f5f5;
        border-radius: 50px;
    }
}