/* Products Gallery Styles - Minimalist Design */

/* Contenidor principal de productes */
.products-container {
    max-width: 1400px;
    margin: 80px auto;
    padding: 40px;
}

/* Ajustar padding responsive del contenidor principal */
@container device (max-width: 768px) {
    .products-container {
        padding: 0 !important;
        margin: 30px auto !important;
    }

    div#page .block {
        padding: 0 !important;
    }
}

@container device (max-width: 480px) {
    .products-container {
        padding: 0 !important;
        margin: 20px auto !important;
    }

    div#page .block {
        padding: 0 !important;
    }
}

/* Search Box */
.products-search-container {
    max-width: 600px;
    margin: 0 auto 60px auto;
    position: relative;
}

.products-search-input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    font-size: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-family: inherit;
    transition: all 0.3s ease;
    background: #fafafa;
}

.products-search-input:focus {
    outline: none;
    border-color: #2c2c2c;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.products-search-input::placeholder {
    color: #999;
}

.products-search-icon {
    position: absolute;
    right: 18px;
    top: 38%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
}

.products-search-clear {
    position: absolute;
    right: 45px;
    top: 25%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 5px;
    display: none;
    transition: color 0.2s;
}

.products-search-clear:hover {
    color: #333;
}

.products-search-clear.visible {
    display: block;
}

.products-search-results {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
    font-size: 14px;
}

/* Gallery Grid - 3 columns */
.product-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    padding: 0;
    max-width: 1400px;
    margin: 0 auto;
}

.product-item {
    position: relative;
}

.product-item a {
    display: block;
    text-decoration: none;
    color: inherit;
}

.product-item .image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4/5;
    overflow: hidden;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.product-item .image-wrapper.loaded {
    background: none;
    animation: none;
}

.product-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.4s ease-in;
}

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

.product-info {
    margin-top: 15px;
    text-align: left;
}

.product-name {
    font-size: 15px;
    font-weight: 400;
    color: #2c2c2c;
    margin-bottom: 5px;
}

.product-category {
    font-size: 13px;
    color: #6b6b6b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.product-ref {
    font-size: 12px;
    color: #999;
    margin-top: 3px;
}

/* Product Detail Page */
.product-detail-container {
    max-width: 1200px;
    margin: 80px auto;
    padding: 40px;
}

.product-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
}

.product-gallery-container {
    position: sticky;
    top: 100px;
}

.product-main-image {
    width: 100%;
    height: 500px;
    background: #fafafa;
    overflow: hidden;
    margin-bottom: 20px;
}

.product-main-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
}

.product-thumbnail {
    width: 100%;
    height: 80px;
    background: #fafafa;
    border: 1px solid #e5e5e5;
    cursor: pointer;
    overflow: hidden;
}

.product-thumbnail:hover,
.product-thumbnail.active {
    border-color: #2c2c2c;
}

.product-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-details h1 {
    font-size: 32px;
    margin: 0 0 10px 0;
}

.product-details .product-ref {
    font-size: 16px;
    color: #666;
    margin-bottom: 30px;
}

.product-description {
    font-size: 16px;
    line-height: 1.6;
    color: #444;
    margin-bottom: 30px;
}

.product-meta {
    border-top: 1px solid #e5e5e5;
    padding-top: 20px;
}

.product-meta-item {
    margin-bottom: 15px;
}

.product-meta-item strong {
    display: inline-block;
    width: 120px;
    color: #333;
}

/* Loading Indicator - Skeleton Style */
.loading-indicator {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    padding: 0;
    margin: 20px 0;
}

.loading-skeleton {
    width: 100%;
    animation: fadeIn 0.3s ease-in;
    position: relative;
}

.loading-skeleton-image {
    width: 100%;
    aspect-ratio: 4/5;
    background: linear-gradient(90deg, #e8e8e8 25%, #d0d0d0 50%, #e8e8e8 75%);
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

/* Efecte de pols animat al centre */
.loading-skeleton-image::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #b0b0b0;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-skeleton-info {
    margin-top: 15px;
}

.loading-skeleton-text {
    height: 15px;
    background: linear-gradient(90deg, #e8e8e8 25%, #d0d0d0 50%, #e8e8e8 75%);
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: 3px;
    width: 85%;
    margin-bottom: 8px;
}

.loading-skeleton-text-small {
    height: 13px;
    background: linear-gradient(90deg, #e8e8e8 25%, #d0d0d0 50%, #e8e8e8 75%);
    background-size: 200% 100%;
    animation: shimmer 1.8s ease-in-out infinite;
    border-radius: 3px;
    width: 65%;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

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

/* Animació per als nous productes */
.product-item {
    animation: fadeIn 0.5s ease-out;
}

/* Responsive loading skeletons */
@media (max-width: 1024px) {
    .loading-indicator {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }

    /* Ocultar alguns skeletons en tablet */
    .loading-skeleton:nth-child(n+5) {
        display: none;
    }
}

@media (max-width: 768px) {
    .loading-indicator {
        grid-template-columns: 1fr;
        gap: 40px;
        padding: 0 20px;
    }

    /* Mostrar menys skeletons en mòbil */
    .loading-skeleton:nth-child(n+4) {
        display: none;
    }
}

/* Responsive Design basat en l'ample del #device-wrapper */

/* Tablet - quan device-wrapper té entre 768px i 1024px */
@container device (max-width: 1024px) {
    .products-search-container {
        max-width: 90%;
        margin-bottom: 40px;
    }

    .product-gallery {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 30px;
        padding: 0 20px;
    }

    .product-detail-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .product-gallery-container {
        position: static;
    }
}

/* Mobile - quan device-wrapper té menys de 768px */
@container device (max-width: 768px) {
    .product-detail-container {
        padding: 0 !important;
        margin: 30px auto !important;
    }

    .products-search-container {
        max-width: 100%;
        margin: 0 0 30px 0;
        padding: 0;
    }

    .products-search-input {
        padding: 12px 45px 12px 15px;
        font-size: 15px;
    }

    .products-search-icon {
        font-size: 14px;
        right: 15px;
    }

    .products-search-clear {
        font-size: 14px;
        right: 40px;
        top: 22%;
    }

    .product-gallery {
        grid-template-columns: 1fr !important;
        gap: 25px;
        padding: 0;
        margin-top: 0;
    }

    .product-item {
        max-width: 100%;
    }

    .product-info {
        margin-top: 12px;
    }

    .product-name {
        font-size: 14px;
    }

    .product-category {
        font-size: 12px;
    }
}

/* Extra small - quan device-wrapper té menys de 480px */
@container device (max-width: 480px) {
    .product-gallery {
        gap: 20px;
        padding: 0;
    }

    .products-search-container {
        margin: 0;
        padding: 0 0 15px 0;
    }

    .products-search-input {
        font-size: 14px;
        padding: 10px 40px 10px 12px;
    }

    .products-search-icon {
        top: 50%;
        right: 12px;
    }

    .products-search-clear {
        right: 35px;
        top: 22%;
    }

    .product-name {
        font-size: 13px;
    }

    .product-category {
        font-size: 11px;
    }
}
