/**
 * Product Design Gallery
 * Inherits: Elementor typography, global colors, spacing
 * Contains: Product-page-specific styles + lightbox
 * Version: 15.0.0
 */

/* Container */
.snapskins-design-gallery {
    margin: 30px 0;
}

/* Header */
.design-gallery-header {
    margin-bottom: 32px;
}

.design-gallery-header .design-gallery-title {
    font-size: 26px;
}

.design-gallery-subtitle {
    color: var(--e-global-color-ff9a990);
}

/* Loading spinner */
.design-gallery-loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--e-global-color-ff9a990);
    font-size: 15px;
}

.design-gallery-loading .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--e-global-color-f29c2c5);
    border-top: 2px solid var(--e-global-color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Cart thumbnails */
.woocommerce-cart-form .cart_item img,
.woocommerce-mini-cart .cart_item img {
    border-radius: 6px;
    border: 1px solid var(--e-global-color-f29c2c5);
    max-width: 80px;
    height: auto;
    object-fit: cover;
}

/* Accordion */
.design-expander {
    border-bottom: 1px solid var(--e-global-color-f29c2c5);
    overflow: hidden;
    transition: all 0.2s ease;
}

.design-expander:last-child {
    border-bottom: none;
}

.expander-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 20px 0;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.expander-header:hover .expander-title,
.expander-header:hover .expander-icon {
    color: var(--e-global-color-primary);
}

.expander-title {
    flex: 0 0 auto;
    transition: color 0.2s ease;
}

.expander-icon {
    font-size: 20px;
    color: var(--e-global-color-ff9a990);
    transition: all 0.2s ease;
    order: 2;
}

.design-count {
    font-size: 14px;
    color: var(--e-global-color-ff9a990);
    font-weight: 500;
    order: 3;
}

.design-expander.open .expander-icon {
    transform: rotate(180deg);
    color: var(--e-global-color-primary);
}

.expander-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.design-expander.open .expander-content {
    max-height: 3000px;
}

/* Design grid */
.design-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    padding: 0 0 24px 0;
}

/* Design items */
.design-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.design-item:hover .design-image-wrapper {
    border-color: var(--e-global-color-cc9769a);
}

.design-item.selected .design-image-wrapper {
    border-color: var(--e-global-color-primary);
}

.design-image-wrapper {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 15px;
    cursor: pointer;
}

.design-image {
    width: 100%;
    max-height: 100%;
    object-fit: contain;
    padding: 5% 0;
}

.design-image.lazyload {
    opacity: 0;
}

.design-image.lazyloaded {
    opacity: 1;
}

.design-name {
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    color: var(--e-global-color-text);
}

.design-item.selected .design-name {
    color: var(--e-global-color-primary);
}

/* Magnifier icon - hidden by default (desktop) */
.magnifier-icon {
    display: none;
}

/* Error state */
.design-error {
    padding: 40px;
    text-align: center;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 8px;
}

.design-error p {
    margin: 0 0 16px 0;
    color: var(--e-global-color-ff9a990);
    font-size: 15px;
    line-height: 1.6;
}

.retry-button {
    background: var(--e-global-color-primary);
    color: var(--e-global-color-3e47553);
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}

.retry-button:hover {
    background: var(--e-global-color-secondary);
}

.no-designs {
    padding: 60px 20px;
    text-align: center;
    color: var(--e-global-color-ff9a990);
    font-size: 15px;
    line-height: 1.6;
}

/* Universal Mockup Notice */
.universal-mockup-notice {
    margin-top: 20px;
    padding: 16px 20px;
    background: rgba(220, 38, 38, 0.08);
    border: 2px solid #dc2626;
    border-radius: 12px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.universal-mockup-notice .notice-text {
    flex: 1;
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: #991b1b;
}

.universal-mockup-notice .notice-text strong {
    color: #dc2626;
    font-weight: 700;
}

/* ===================================
   LIGHTBOX (hidden by default)
   =================================== */

.design-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.design-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.lightbox-content {
    position: relative;
    z-index: 1;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.lightbox-image {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.lightbox-title {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin: 0;
}

.design-lightbox .lightbox-close {
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    color: var(--e-global-color-cc9769a, #B8B3C1) !important;
    width: 50px;
    height: 50px;
    cursor: pointer;
    font-size: 50px;
    padding: 0;
    box-shadow: none;
}

.design-lightbox .lightbox-close:hover {
    background:none;
    box-shadow:none;
    transform: scale(1.2);
}

body.lightbox-open {
    overflow: hidden;
}

/* ===================================
   MOBILE STYLES
   =================================== */

@media (max-width: 768px) {
    .woocommerce-product-gallery {
        display: none !important;
    }

    .design-gallery-header .design-gallery-title {
        margin-bottom: 8px;
        text-align: center;
        font-size: 22px;
    }

    .design-gallery-subtitle {
        text-align: center;
    }

    .design-gallery-header {
        margin-bottom: 28px;
    }

    .expander-header {
        padding: 12px 0;
        gap: 10px;
    }

    .design-count {
        font-size: 12px;
    }

    .expander-icon {
        font-size: 15px;
    }

    .design-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 16px;
        padding: 16px;
    }

    .design-item {
        gap: 6px;
    }

    .design-name {
        font-size: 13px;
        min-height: 36px;
    }

    .universal-mockup-notice {
        padding: 14px 16px;
        gap: 12px;
        margin-top: 16px;
    }

    .universal-mockup-notice .notice-text {
        font-size: 14px;
        line-height: 1.5;
    }

    /* Magnifier icon - show on mobile */
    .magnifier-icon {
        position: absolute;
        top: 0;
        left: 0;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        pointer-events: auto;
        cursor: pointer;
        z-index: 2;
        opacity: 1;
        background: transparent;
    }

    .magnifier-icon::before {
        content: '';
        width: 32px;
        height: 32px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23B8B3C1' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='11' y1='8' x2='11' y2='14'/%3E%3Cline x1='8' y1='11' x2='14' y2='11'/%3E%3Cline x1='16' y1='16' x2='19' y2='19'/%3E%3C/svg%3E");
        background-size: contain;
        background-repeat: no-repeat;
    }

    .design-item.selected .magnifier-icon::before {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236C3BFF' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cline x1='11' y1='8' x2='11' y2='14'/%3E%3Cline x1='8' y1='11' x2='14' y2='11'/%3E%3Cline x1='16' y1='16' x2='19' y2='19'/%3E%3C/svg%3E");
    }

    /* Lightbox - show on mobile */
    .design-lightbox {
        display: flex;
    }

    .lightbox-content {
        max-width: 95%;
        max-height: 95%;
        gap: 16px;
    }

    .lightbox-image {
        max-height: 75vh;
        border-radius: 8px;
    }

    .lightbox-title {
        font-size: 15px;
        padding: 10px 20px;
    }
}

@media (max-width: 480px) {
    .design-gallery-subtitle {
        font-size: 13px;
    }

    .universal-mockup-notice {
        padding: 12px 14px;
        gap: 10px;
        border-radius: 10px;
    }

    .universal-mockup-notice .notice-text {
        font-size: 13px;
    }

    .design-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
        padding: 14px;
    }

    .design-item {
        gap: 6px;
    }

    .design-name {
        font-size: 12px;
        min-height: 32px;
    }

    .expander-header {
        padding: 12px 0;
        gap: 8px;
    }

    .magnifier-icon {
        width: 36px;
        height: 36px;
    }

    .magnifier-icon::before {
        width: 28px;
        height: 28px;
    }

    .lightbox-title {
        font-size: 14px;
        padding: 8px 16px;
    }

}
