/* ===================================================================== */
/* PRODUCT VIEW SWITCHER STYLES                                         */
/* ===================================================================== */

/* Main View Switcher Container */
.product-view-switcher {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 2rem 0;
    padding: 1rem;
    background: var(--bg-secondary, #ffffff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
    position: relative;
    z-index: 10;
}

.view-switcher-label {
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    font-size: 0.9rem;
    white-space: nowrap;
}

.view-switcher-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.view-switcher-info {
    margin-left: auto;
    color: var(--text-secondary, #6b7280);
    font-size: 0.875rem;
    display: none; /* Hidden by default, show on larger screens */
}

/* View Buttons */
.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 2px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #374151);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    min-width: 3rem;
}

.view-btn:hover {
    background: var(--bg-tertiary, #f9fafb);
    border-color: var(--accent-primary, #3b82f6);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.view-btn:focus {
    outline: none;
    border-color: var(--accent-primary, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.view-btn:active {
    transform: translateY(0);
}

.view-btn.active {
    background: var(--accent-primary, #3b82f6);
    border-color: var(--accent-primary, #3b82f6);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.view-btn.active:hover {
    background: var(--accent-secondary, #2563eb);
    transform: translateY(-1px);
}

.view-btn i {
    font-size: 1.1rem;
    transition: transform 0.2s ease;
}

.view-btn:hover i {
    transform: scale(1.1);
}

/* Hide text labels, keep only icons */
.view-name {
    display: none !important;
}

/* Screen reader only class for accessibility */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Responsive View Button Behavior */
@media (max-width: 640px) {
    .view-btn {
        min-width: 2.8rem;
        padding: 0.8rem;
    }
    
    .view-switcher-info {
        display: block;
        margin-left: 0;
        margin-top: 0.5rem;
        flex-basis: 100%;
        text-align: center;
    }
}

@media (min-width: 768px) {
    .view-switcher-info {
        display: block;
    }
}

/* ===================================================================== */
/* GRID LAYOUTS                                                          */
/* ===================================================================== */

/* Base Grid Container */
.products-grid,
.masonry-grid {
    transition: all 0.3s ease;
    position: relative;
}

.products-grid.view-transitioning,
.masonry-grid.view-transitioning {
    opacity: 0.7;
    pointer-events: none;
}

/* Standard Grid View */
.products-grid.grid-view,
.masonry-grid.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    align-items: start;
}

/* Masonry View */
.products-grid.masonry-view,
.masonry-grid.masonry-view {
    column-count: var(--grid-columns, 3);
    column-gap: 2rem;
    column-fill: balance;
}

.masonry-view .product-card,
.masonry-view .masonry-item {
    break-inside: avoid;
    margin-bottom: 2rem;
    display: block;
    width: 100%;
}

/* Instagram Square Grid View */
.products-grid.instagram-view,
.masonry-grid.instagram-view {
    display: grid;
    grid-template-columns: repeat(var(--grid-columns, 4), 1fr);
    gap: 1rem;
}

.instagram-view .product-card,
.instagram-view .masonry-item {
    aspect-ratio: 1/1;
    overflow: hidden;
}

.instagram-view .product-image,
.instagram-view .masonry-product-image {
    aspect-ratio: 1/1;
    height: 100%;
}

.instagram-view .product-image img,
.instagram-view .masonry-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.instagram-view .product-info,
.instagram-view .masonry-product-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    padding: 1rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.instagram-view .product-card:hover .product-info,
.instagram-view .masonry-item:hover .masonry-product-content {
    transform: translateY(0);
}



/* ===================================================================== */
/* RESPONSIVE BREAKPOINTS                                               */
/* ===================================================================== */

/* Mobile (up to 768px) */
@media (max-width: 767px) {
    .product-view-switcher {
        margin: 1rem 0;
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .products-grid.grid-view,
    .masonry-grid.grid-view {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .products-grid.masonry-view,
    .masonry-grid.masonry-view {
        column-count: 1;
    }
    
    .products-grid.instagram-view,
    .masonry-grid.instagram-view {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

/* Tablet (768px to 1024px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .products-grid.grid-view,
    .masonry-grid.grid-view {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
    
    .products-grid.masonry-view,
    .masonry-grid.masonry-view {
        column-count: 2;
    }
    
    .products-grid.instagram-view,
    .masonry-grid.instagram-view {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Desktop (1024px and up) */
@media (min-width: 1024px) {
    .products-grid.grid-view,
    .masonry-grid.grid-view {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        gap: 2rem;
    }
    
    .products-grid.masonry-view,
    .masonry-grid.masonry-view {
        column-count: 3;
    }
    
    .products-grid.instagram-view,
    .masonry-grid.instagram-view {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }
}

/* Large Desktop (1400px and up) */
@media (min-width: 1400px) {
    .products-grid.instagram-view,
    .masonry-grid.instagram-view {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ===================================================================== */
/* LOADING AND ANIMATION STATES                                         */
/* ===================================================================== */

/* Loading State */
.products-grid.loading,
.masonry-grid.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.products-grid.loading::after,
.masonry-grid.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--border-color, #e5e7eb);
    border-top: 2px solid var(--accent-primary, #3b82f6);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Fade in animation for products */
.product-card,
.masonry-item {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger animation for multiple products */
.product-card:nth-child(1),
.masonry-item:nth-child(1) { animation-delay: 0.05s; }
.product-card:nth-child(2),
.masonry-item:nth-child(2) { animation-delay: 0.1s; }
.product-card:nth-child(3),
.masonry-item:nth-child(3) { animation-delay: 0.15s; }
.product-card:nth-child(4),
.masonry-item:nth-child(4) { animation-delay: 0.2s; }
.product-card:nth-child(5),
.masonry-item:nth-child(5) { animation-delay: 0.25s; }
.product-card:nth-child(6),
.masonry-item:nth-child(6) { animation-delay: 0.3s; }

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .product-view-switcher,
    .products-grid,
    .masonry-grid,
    .product-card,
    .masonry-item,
    .view-btn {
        transition: none;
        animation: none;
    }
    
    .view-btn:hover {
        transform: none;
    }
    
    .products-grid.view-transitioning,
    .masonry-grid.view-transitioning {
        opacity: 1;
    }
}

/* ===================================================================== */
/* ACCESSIBILITY IMPROVEMENTS                                           */
/* ===================================================================== */

/* Focus styles */
.view-btn:focus-visible {
    outline: 2px solid var(--accent-primary, #3b82f6);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .product-view-switcher {
        border-width: 2px;
        border-color: var(--text-primary, #000000);
    }
    
    .view-btn {
        border-width: 2px;
    }
    
    .view-btn.active {
        background: var(--text-primary, #000000);
        color: var(--bg-primary, #ffffff);
    }
}

/* ===================================================================== */
/* THEME COMPATIBILITY                                                  */
/* ===================================================================== */

/* Dark theme support */
[data-theme="dark"] .product-view-switcher {
    background: var(--bg-secondary, #1f2937);
    border-color: var(--border-color, #374151);
}

[data-theme="dark"] .view-btn {
    background: var(--bg-primary, #111827);
    border-color: var(--border-color, #374151);
    color: var(--text-primary, #f9fafb);
}

[data-theme="dark"] .view-btn:hover {
    background: var(--bg-tertiary, #374151);
}

/* WooCommerce integration */
.woocommerce .product-view-switcher {
    margin-bottom: 2rem;
}

.woocommerce .products.grid-view {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    gap: 2rem !important;
}

/* ===================================================================== */
/* UTILITY CLASSES                                                      */
/* ===================================================================== */

.view-switcher-hidden {
    display: none !important;
}

.view-switcher-loading {
    opacity: 0.5;
    pointer-events: none;
}

.view-switcher-compact .view-name {
    display: none;
}

.view-switcher-compact .view-btn {
    min-width: 2.5rem;
    padding: 0.75rem;
}