/**
 * Shop Styles
 * Filters, skeletons, sorting, product cards, badges, layout for shop.php
 */

/* ==========================================================================
   Skeleton Loading Animation
   ========================================================================== */
@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite ease-in-out;
    border-radius: 4px;
}

.skeleton-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 16px;
}

.skeleton-image {
    aspect-ratio: 1;
    width: 100%;
}

.skeleton-content {
    padding: 12px;
}

.skeleton-title {
    height: 16px;
    margin-bottom: 12px;
    width: 80%;
}

.skeleton-price {
    height: 14px;
    width: 50%;
    margin-bottom: 16px;
}

.skeleton-button {
    height: 40px;
    border-radius: 20px;
    margin-bottom: 8px;
}

/* ==========================================================================
   Product Image Loading
   ========================================================================== */
.product-img-wrapper {
    position: relative;
    background: #f5f5f5;
}

.product-img-wrapper img {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.product-img-wrapper img.loaded {
    opacity: 1;
}

/* Fallback: show image after 2 seconds even if JS fails */
@keyframes show-image-fallback {
    to {
        opacity: 1;
    }
}

.product-img-wrapper img {
    animation: show-image-fallback 0.1s ease-in-out 2s forwards;
}

.product-img-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite ease-in-out;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

.product-img-placeholder svg {
    width: 48px;
    height: 48px;
    color: #ccc;
    animation: pulse-icon 1.5s infinite ease-in-out;
}

@keyframes pulse-icon {

    0%,
    100% {
        opacity: 0.4;
        transform: scale(1);
    }

    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

/* Hide placeholder when image is loaded */
.product-img-wrapper img.loaded~.product-img-placeholder,
.product-img-wrapper.image-loaded .product-img-placeholder {
    opacity: 0;
    visibility: hidden;
}

/* ==========================================================================
   Sorting Dropdown
   ========================================================================== */
.sort-dropdown {
    position: relative;
    display: inline-block;
}

.sort-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: #fff;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.sort-dropdown-btn:hover {
    border-color: #1C1C1C;
}

.sort-dropdown-btn i {
    font-size: 12px;
    transition: transform 0.2s;
}

.sort-dropdown.open .sort-dropdown-btn i.fa-chevron-down {
    transform: rotate(180deg);
}

.sort-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 180px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.sort-dropdown.open .sort-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.sort-dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #f0f0f0;
}

.sort-dropdown-item:last-child {
    border-bottom: none;
}

.sort-dropdown-item:hover {
    background: #f8f8f8;
}

.sort-dropdown-item.active {
    color: #D19C97;
    font-weight: 600;
}

.sort-dropdown-item.active::after {
    content: '✓';
    font-weight: bold;
}

/* ==========================================================================
   Loading States
   ========================================================================== */
#loading-indicator {
    display: none;
    text-align: center;
    padding: 24px;
    width: 100%;
}

.loading-spinner {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.loading-spinner-dots {
    display: flex;
    gap: 6px;
}

.loading-spinner-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #D19C97;
    animation: loading-bounce 1.4s infinite ease-in-out both;
}

.loading-spinner-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-spinner-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.loading-spinner-dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes loading-bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.loading-text {
    font-size: 13px;
    color: #666;
}

/* End of results message */
.end-of-results {
    text-align: center;
    padding: 32px 16px;
    color: #888;
}

.end-of-results i {
    font-size: 32px;
    margin-bottom: 12px;
    color: #D19C97;
}

/* ==========================================================================
   Mobile-First Optimizations
   ========================================================================== */
@media (max-width: 576px) {
    .filter-controls {
        flex-wrap: wrap;
        gap: 8px;
    }

    .btn-filter {
        padding: 8px 12px;
        font-size: 12px;
    }

    .sort-dropdown-btn {
        padding: 8px 10px;
        font-size: 12px;
    }

    .sort-dropdown-btn span {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sort-dropdown-menu {
        min-width: 160px;
        right: 0;
    }

    .sort-dropdown-item {
        padding: 10px 12px;
        font-size: 12px;
    }

    .results-info {
        width: 100%;
        order: 3;
    }

    .skeleton-card {
        margin-bottom: 12px;
    }

    .loading-spinner-dot {
        width: 8px;
        height: 8px;
    }
}

/* Smooth page transitions */
.page-loading #product-container {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* Product card animation */
.product-card-wrapper {
    animation: fadeInUp 0.4s ease forwards;
    opacity: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation for initial load */
.product-card-wrapper:nth-child(1) {
    animation-delay: 0.05s;
}

.product-card-wrapper:nth-child(2) {
    animation-delay: 0.1s;
}

.product-card-wrapper:nth-child(3) {
    animation-delay: 0.15s;
}

.product-card-wrapper:nth-child(4) {
    animation-delay: 0.2s;
}

.product-card-wrapper:nth-child(5) {
    animation-delay: 0.25s;
}

.product-card-wrapper:nth-child(6) {
    animation-delay: 0.3s;
}

.product-card-wrapper:nth-child(7) {
    animation-delay: 0.35s;
}

.product-card-wrapper:nth-child(8) {
    animation-delay: 0.4s;
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .sort-dropdown-item:hover {
        background: transparent;
    }

    .sort-dropdown-item:active {
        background: #f0f0f0;
    }

    .btn-filter:hover {
        background: #1C1C1C;
    }

    .btn-filter:active {
        background: #333;
    }
}

/* ==========================================================================
   Announcement Strip
   ========================================================================== */
.announcement-strip {
    background: #1C1C1C;
    color: #fff;
    padding: 10px 15px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
}

.announcement-strip.blink .announcement-text {
    animation: blink 1.5s ease-in-out infinite;
}

.announcement-strip.marquee .announcement-text {
    display: inline-block;
    animation: marquee 15s linear infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes marquee {
    0% {
        transform: translateX(100%);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* ==========================================================================
   Filter Button & Controls
   ========================================================================== */
.filter-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: #fff;
    border-bottom: 1px solid #eee;
    gap: 10px;
}

.btn-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #1C1C1C;
    color: #fff;
    border: none;
    border-radius: 25px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-filter:hover {
    background: #333;
}

.btn-filter i {
    font-size: 16px;
}

.active-filters-count {
    background: #ff6b6b;
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    margin-left: 5px;
}

.active-filters-count.hidden {
    display: none;
}

/* Sticky Filter Icon (Mobile) */
.sticky-filter-icon {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1100;
    background: #1C1C1C;
    color: #fff;
    padding: 12px 10px;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.sticky-filter-icon span {
    font-size: 10px;
    font-weight: 600;
}

.sticky-filter-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff6b6b;
    color: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
}

.sticky-filter-badge.hidden {
    display: none;
}

/* ==========================================================================
   Filter Drawer Overlay
   ========================================================================== */
.filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1300;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.filter-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Filter Drawer */
.filter-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 320px;
    max-width: 85vw;
    height: 100%;
    background: #fff;
    z-index: 1301;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.filter-drawer.active {
    transform: translateX(0);
}

.filter-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.filter-drawer-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1C1C1C;
}

.filter-drawer-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 5px;
}

.filter-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.filter-section {
    border-bottom: 1px solid #eee;
}

.filter-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    cursor: pointer;
    user-select: none;
}

.filter-section-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1C1C1C;
}

.filter-section-header i {
    transition: transform 0.2s;
    color: #666;
}

.filter-section.collapsed .filter-section-header i {
    transform: rotate(-180deg);
}

.filter-section-content {
    padding: 0 20px 18px;
}

.filter-section.collapsed .filter-section-content {
    display: none;
}

/* Discount Checkboxes */
.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    cursor: pointer;
}

.filter-checkbox input {
    width: 20px;
    height: 20px;
    accent-color: #1C1C1C;
    cursor: pointer;
}

.filter-checkbox label {
    flex: 1;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
}

.filter-checkbox .count {
    color: #888;
    font-size: 13px;
}

/* Price Range Slider */
.price-range-container {
    padding: 10px 0;
}

.price-range-inputs {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.price-input-group {
    flex: 1;
}

.price-input-group label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 5px;
}

.price-input-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

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

.price-slider {
    width: 100%;
    height: 4px;
    background: #eee;
    border-radius: 2px;
    position: relative;
}

.price-slider-range {
    position: absolute;
    height: 100%;
    background: #1C1C1C;
    border-radius: 2px;
}

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

.price-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #1C1C1C;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.price-slider input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #1C1C1C;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Filter Drawer Footer */
.filter-drawer-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.btn-clear-filters {
    flex: 1;
    padding: 12px;
    background: #fff;
    border: 2px solid #1C1C1C;
    border-radius: 25px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    color: #1C1C1C;
}

.btn-apply-filters {
    flex: 1;
    padding: 12px;
    background: #1C1C1C;
    border: 2px solid #1C1C1C;
    border-radius: 25px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    color: #fff;
}

/* ==========================================================================
   Discount Badge & Pricing on Products
   ========================================================================== */
.discount-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ff6b6b;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    z-index: 2;
}

.discounted-price {
    color: #ff6b6b !important;
    font-weight: 600;
}

.product-price {
    color: #ff6b6b !important;
    font-weight: 600;
}

/* Results Info */
.results-info {
    padding: 10px 15px;
    background: #f8f8f8;
    font-size: 14px;
    color: #666;
}

.results-info strong {
    color: #1C1C1C;
}

/* ==========================================================================
   Filter Tip Banner
   ========================================================================== */
.filter-tip-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 12px;
    background: #1C1C1C;
    color: #fff;
    margin: 10px 0 12px;
}

.filter-tip-banner__arrow {
    flex: 0 0 auto;
    color: #fff;
}

.filter-tip-banner__title {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
}

.filter-tip-banner__subtitle {
    font-size: 12px;
    opacity: 0.85;
}

/* ==========================================================================
   No Results
   ========================================================================== */
.no-results {
    text-align: center;
    padding: 60px 20px;
    display: none;
}

.no-results.show {
    display: block;
}

.no-results i {
    font-size: 60px;
    color: #ddd;
    margin-bottom: 20px;
}

.no-results h4 {
    color: #666;
    margin-bottom: 10px;
}

.no-results p {
    color: #888;
}

/* ==========================================================================
   Active Filter Tags
   ========================================================================== */
.active-filters-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 15px 10px;
    flex-wrap: wrap;
}

.active-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    display: none;
}

.active-filter-tags.show {
    display: flex;
}

.btn-clear-all-inline {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.btn-clear-all-inline:hover {
    background: #e55555;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f0f0f0;
    border-radius: 20px;
    font-size: 12px;
    color: #333;
}

.filter-tag button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #888;
    font-size: 14px;
    line-height: 1;
}

.filter-tag button:hover {
    color: #ff6b6b;
}

/* Hide products that don't match filter */
.product-card-wrapper.filtered-out {
    display: none !important;
}

@media (max-width: 768px) {
    .filter-controls {
        padding: 10px;
    }

    .btn-filter {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* ==========================================================================
   Product Card Badges (NEW for arrivals, discount % for sales)
   ========================================================================== */
.product-img-wrapper .new-badge,
.product-img-wrapper .discount-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #e8673c;
    color: #fff;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    z-index: 20 !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    pointer-events: none;
    opacity: 1 !important;
    visibility: visible !important;
    display: inline-block !important;
}

.product-img-wrapper .new-badge {
    background: #28a745;
}

/* Ensure badge stays visible when image loads */
.product-img-wrapper.image-loaded .new-badge,
.product-img-wrapper.image-loaded .discount-badge {
    opacity: 1 !important;
    visibility: visible !important;
    display: inline-block !important;
}