/**
 * SP Product Gallery - Frontend Styles
 *
 * @package SP_Product_Gallery
 */

/* Gallery Container */
.sp-product-gallery {
    max-width: 100%;
    margin: 0 auto;
}

/* Main Image Wrapper */
.sp-product-gallery__main-wrapper {
    margin-bottom: 15px;
}

.sp-product-gallery__main-image {
    width: 100%;
    background-color: #f8f8f8;
    overflow: hidden;
}

.sp-product-gallery__main-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: opacity 0.3s ease;
    box-sizing: border-box;
}

.sp-product-gallery__main-image img.loading {
    opacity: 0.5;
}

/* Thumbnails Carousel Wrapper */
.sp-product-gallery__thumbnails-wrapper {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

/* Thumbnails Container (scrollable area) */
.sp-product-gallery__thumbnails-container {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.sp-product-gallery__thumbnails {
    display: flex;
    flex-wrap: nowrap;
    margin: 0;
    padding: 0;
    list-style: none;
    transition: transform 0.3s ease;
}

/* Navigation Buttons */
.sp-product-gallery__nav {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    color: #333;
    z-index: 10;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-appearance: none;
    appearance: none;
}

.sp-product-gallery__nav:hover,
.sp-product-gallery__nav:focus,
.sp-product-gallery__nav:active {
    background: inherit;
    border-color: inherit;
    color: inherit;
    outline: none;
    box-shadow: none;
}

.sp-product-gallery__nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.sp-product-gallery__nav svg {
    width: 20px;
    height: 20px;
}

/* Individual Thumbnail */
.sp-product-gallery__thumbnail {
    flex-shrink: 0;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-sizing: border-box;
}

.sp-product-gallery__thumbnail:hover {
    opacity: 0.85;
}

.sp-product-gallery__thumbnail-inner {
    width: 100%;
    overflow: hidden;
    background-color: #f8f8f8;
}

.sp-product-gallery__thumbnail-inner img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.2s ease;
    box-sizing: border-box;
}

.sp-product-gallery__thumbnail:hover .sp-product-gallery__thumbnail-inner img {
    transform: scale(1.05);
}

.sp-product-gallery__thumbnail.active {
    opacity: 1;
}

.sp-product-gallery__thumbnail.active .sp-product-gallery__thumbnail-inner img {
    transform: scale(1);
}

/* Error Message */
.sp-product-gallery-error {
    padding: 20px;
    text-align: center;
    color: #666;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Loading State */
.sp-product-gallery.is-loading .sp-product-gallery__main-image {
    position: relative;
}

.sp-product-gallery.is-loading .sp-product-gallery__main-image::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: #333;
    border-radius: 50%;
    animation: sp-gallery-spin 1s linear infinite;
}

@keyframes sp-gallery-spin {
    to {
        transform: rotate(360deg);
    }
}

/* RTL Support */
[dir="rtl"] .sp-product-gallery__thumbnails {
    direction: rtl;
}

/* RTL Arrow Rotation */
[dir="rtl"] .sp-product-gallery__nav--prev svg,
[dir="rtl"] .sp-product-gallery__nav--prev img {
    transform: rotate(180deg);
}

[dir="rtl"] .sp-product-gallery__nav--next svg,
[dir="rtl"] .sp-product-gallery__nav--next img {
    transform: rotate(180deg);
}

/* High DPI Images */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .sp-product-gallery__main-image img,
    .sp-product-gallery__thumbnail-inner img {
        image-rendering: -webkit-optimize-contrast;
    }
}

.sp-product-variations {
    width: 100%;
    margin: 0 auto;
}

.sp-product-variations__form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 28px;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.sp-product-variations__native {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sp-product-variations__groups {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sp-product-variations__group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sp-product-variations__group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sp-product-variations__group-label {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}

.sp-product-variations__group-value {
    font-size: 14px;
    color: #374151;
    font-weight: 600;
}

.sp-product-variations__options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.sp-product-variations__option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 100px;
    padding: 12px;
    border: 1px solid #d6dbe4;
    border-radius: 16px;
    background: linear-gradient(145deg, #ffffff 0%, #fbfcfd 100%);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.sp-product-variations__option:hover {
    border-color: #94a3b8;
    box-shadow: 0 12px 24px rgba(17, 24, 39, 0.08), 0 3px 8px rgba(17, 24, 39, 0.04);
    transform: translateY(-2px) scale(1.01);
}

.sp-product-variations__option.is-active {
    border-color: #0f172a;
    background: linear-gradient(145deg, #ffffff 0%, #ecf5ff 100%);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.16), 0 14px 28px rgba(15, 23, 42, 0.12), 0 4px 10px rgba(15, 23, 42, 0.06);
    transform: translateY(-1px) scale(1.01);
}

.sp-product-variations__option.is-active::after {
    content: '✓';
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #0f172a;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 8px 16px rgba(15, 23, 42, 0.18);
}

.sp-product-variations__option.is-active .sp-product-variations__option-image {
    box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.08);
}

.sp-product-variations__option.is-active .sp-product-variations__option-label {
    color: #0f172a;
    font-weight: 700;
}

.sp-product-variations__option.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    filter: grayscale(0.8);
}

.sp-product-variations__option-image {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 12px;
    background: #f3f4f6;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.sp-product-variations__option-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

.sp-product-variations__option.is-text {
    min-height: 72px;
    justify-content: center;
}

.sp-product-variations__option-label {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    line-height: 1.2;
    letter-spacing: 0;
}

.sp-product-variations__wrap {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.sp-product-variations .single_variation {
    margin: 0;
    display: none !important;
}

.sp-product-variations__summary {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 180px;
    flex-shrink: 0;
    align-self: center;
}

.sp-product-variations__summary-price {
    font-size: 34px;
    font-weight: 800;
    color: #16a34a;
    line-height: 1.05;
    letter-spacing: -0.01em;
}

.sp-product-variations__summary-price .price {
    color: inherit;
}

.sp-product-variations__summary-price del {
    opacity: 0.55;
    font-size: 0.8em;
    margin-inline-start: 6px;
}

.sp-product-variations__summary-price ins {
    text-decoration: none;
}

.sp-product-variations__summary-availability {
    font-size: 14px;
    color: #6b7280;
}

.sp-product-variations__summary-availability .stock {
    margin: 0;
}

.sp-product-variations__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding-top: 6px;
}

.sp-product-variations__reset {
    align-self: flex-start;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    text-decoration: none;
}

.sp-product-variations__quantity {
    display: inline-flex;
    align-items: center;
    border: 1px solid #dbe1ea;
    border-radius: 18px;
    overflow: hidden;
    background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04);
}

.sp-product-variations__quantity .quantity {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    width: 100%;
}

.sp-product-variations__qty-button {
    width: 48px;
    height: 60px;
    border: 0;
    background: transparent;
    color: #334155;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sp-product-variations__qty-button:hover {
    background: rgba(255, 255, 255, 0.6);
    color: #1e293b;
}

.sp-product-variations__quantity .quantity {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    width: 100%;
}

.sp-product-variations__quantity .qty,
.sp-product-variations__qty-input {
    width: 100%;
    min-width: 60px;
    height: 60px;
    border: 0;
    padding: 0 8px;
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    background: transparent;
    box-shadow: none;
}

.sp-product-variations__quantity .screen-reader-text {
    display: none;
}

.sp-product-variations__submit {
    flex: 1;
    max-width: 280px;
    min-height: 60px;
    border: 0;
    border-radius: 18px;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 40%, #334155 100%);
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 16px 32px rgba(30, 41, 59, 0.22), 0 4px 12px rgba(30, 41, 59, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    text-transform: none;
    font-family: inherit;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 24px;
    white-space: nowrap;
}

.sp-product-variations__submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: left 0.6s ease;
}

.sp-product-variations__submit:hover::before {
    left: 100%;
}

.sp-product-variations__submit:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 20px 40px rgba(30, 41, 59, 0.28), 0 6px 16px rgba(30, 41, 59, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 35%, #475569 100%);
    color: #ffffff;
    letter-spacing: 0.04em;
}

.sp-product-variations__submit:active {
    transform: translateY(0) scale(0.99);
    box-shadow: 0 8px 20px rgba(30, 41, 59, 0.2), 0 2px 8px rgba(30, 41, 59, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.1s ease;
}

.sp-product-variations__submit.disabled,
.sp-product-variations__submit:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: 0 8px 16px rgba(30, 41, 59, 0.1);
    background: linear-gradient(135deg, #64748b 0%, #94a3b8 100%) !important;
    letter-spacing: 0.02em;
}

.sp-product-variations__submit.disabled::before,
.sp-product-variations__submit:disabled::before {
    display: none;
}

.sp-product-variations__reset:hover {
    color: #111827;
}

[dir="rtl"] .sp-product-variations__group-header,
[dir="rtl"] .sp-product-variations__actions {
    direction: rtl;
}

[dir="rtl"] .sp-product-variations__group-header {
    text-align: right;
}

[dir="rtl"] .sp-product-variations__summary,
[dir="rtl"] .sp-product-variations__option,
[dir="rtl"] .sp-product-variations__reset {
    text-align: right;
}

[dir="rtl"] .sp-product-variations__option {
    align-items: stretch;
}

[dir="rtl"] .sp-product-variations__option-label {
    text-align: center;
}

[dir="rtl"] .sp-product-variations__submit {
    font-size: 17px;
    letter-spacing: 0.01em;
}

@media (max-width: 767px) {
    .sp-product-variations__form {
        padding: 18px;
        gap: 18px;
        border-radius: 20px;
    }

    .sp-product-variations__options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .sp-product-variations__option {
        min-height: 88px;
        padding: 8px;
    }

    .sp-product-variations__summary {
        flex: 0 0 100%;
        min-width: 100%;
        max-width: 100%;
        text-align: center;
        margin-bottom: 4px;
        align-self: stretch;
        order: 1;
    }

    .sp-product-variations__summary-price {
        font-size: 28px;
    }

    .sp-product-variations__actions {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: stretch;
        gap: 12px;
        justify-content: flex-start;
    }

    .sp-product-variations__quantity {
        order: 2;
        flex: 0 0 132px;
        min-width: 132px;
        max-width: 132px;
        display: inline-flex !important;
        align-items: center !important;
    }

    .sp-product-variations__quantity .quantity {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 !important;
        width: 100% !important;
    }

    .sp-product-variations__quantity .qty,
    .sp-product-variations__qty-input {
        width: 100% !important;
        min-width: 50px !important;
        height: 50px !important;
        font-size: 18px !important;
    }

    .sp-product-variations__submit {
        order: 3;
        flex: 1 1 calc(100% - 144px);
        min-width: 0;
        min-height: 50px;
        font-size: 15px;
        max-width: none;
        padding: 0 16px;
        white-space: normal;
    }

    [dir="rtl"] .sp-product-variations__submit {
        font-size: 16px;
    }
}
