/* Product detail modal — image left, RTL details right */

.product-modal {
    position: fixed !important;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.product-modal.is-open {
    display: flex;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.product-modal-backdrop {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: rgba(0, 0, 0, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.product-modal-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 980px;
    max-height: calc(100dvh - 2rem);
    max-height: calc(100vh - 2rem);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.product-modal-inner {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    min-height: min(420px, 85dvh);
    min-height: min(420px, 85vh);
    max-height: calc(100dvh - 2rem);
    max-height: calc(100vh - 2rem);
    background: linear-gradient(145deg, rgba(8, 18, 36, 0.97), rgba(6, 20, 46, 0.98));
    border: 1px solid rgba(126, 200, 255, 0.3);
    border-radius: 24px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.75), 0 0 40px rgba(77, 166, 255, 0.12);
    overflow: hidden;
    transform: scale(0.94) translateY(20px);
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.product-modal.is-open .product-modal-inner {
    transform: scale(1) translateY(0);
}

.product-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    left: auto;
    z-index: 10;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(126, 200, 255, 0.35);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease;
}

.product-modal-close:hover {
    background: #4da6ff;
    color: #000;
    transform: rotate(90deg);
}

.product-modal-loader {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: #94a8c4;
    font-weight: 700;
    background: inherit;
}

.product-modal-loader.is-active {
    display: flex;
}

.product-modal-content {
    position: relative;
    z-index: 1;
    display: none;
    direction: ltr;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    align-items: stretch;
    width: 100%;
    flex: 1;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}

.product-modal-content.is-active {
    display: grid;
}

.product-modal-gallery {
    order: 1;
    background: rgba(0, 0, 0, 0.35);
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
    overflow-y: auto;
    border-right: 1px solid rgba(126, 200, 255, 0.12);
}

.product-modal-info {
    order: 2;
    direction: rtl;
    text-align: right;
    padding: 3.25rem 1.75rem 1.75rem;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.25rem;
}

#productModalCartForm {
    margin-top: auto;
    padding-top: 0.75rem;
    flex-shrink: 0;
}

#productModalCartForm .btn {
    min-height: 48px;
}

.product-modal-main-img {
    flex: 1;
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(126, 200, 255, 0.22);
    background: rgba(0, 0, 0, 0.4);
}

.product-modal-main-img img {
    width: 100%;
    height: 100%;
    min-height: 240px;
    max-height: min(48vh, 420px);
    object-fit: cover;
}

.product-modal-thumbs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.product-modal-thumbs:empty {
    display: none;
}

.product-modal-thumb {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    background: none;
    flex-shrink: 0;
    transition: border-color 0.25s ease, transform 0.25s ease;
}

.product-modal-thumb.is-active,
.product-modal-thumb:hover {
    border-color: #4da6ff;
    transform: scale(1.05);
}

.product-modal-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-modal-info h2 {
    font-size: clamp(1.2rem, 3vw, 1.65rem);
    font-weight: 900;
    margin: 0.5rem 0 0.75rem;
    color: #fff;
    line-height: 1.35;
}

.product-modal-info .product-tag {
    display: inline-block;
    font-size: 0.72rem;
    background: rgba(77, 166, 255, 0.15);
    color: #7ec8ff;
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 700;
    border: 1px solid rgba(126, 200, 255, 0.28);
}

.product-modal-price {
    font-size: 1.45rem;
    font-weight: 900;
    color: #7ec8ff;
    margin-bottom: 0.75rem;
}

.product-modal-desc {
    color: #94a8c4;
    line-height: 1.85;
    font-size: 0.95rem;
    margin-bottom: 0;
    white-space: pre-wrap;
}

.product-modal-stock {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: #7ec8ff;
    font-weight: 700;
}

.product-modal-stock.is-out {
    color: #f87171;
}

.product-modal-sizes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    justify-content: flex-start;
}

.product-modal-sizes:empty {
    display: none;
}

.size-pill {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(126, 200, 255, 0.28);
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    background: rgba(77, 166, 255, 0.1);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.size-pill:hover:not(:disabled):not(.out) {
    border-color: rgba(126, 200, 255, 0.55);
    transform: translateY(-1px);
}

.size-pill.is-selected {
    border-color: #7ec8ff;
    background: rgba(77, 166, 255, 0.35);
    box-shadow: 0 0 0 1px rgba(126, 200, 255, 0.35);
}

.size-pill.out {
    opacity: 0.45;
    text-decoration: line-through;
    cursor: not-allowed;
}

.product-modal-sizes-label {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
}

.lux-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(126, 200, 255, 0.2);
    border-top-color: #4da6ff;
    border-radius: 50%;
    animation: luxSpin 0.8s linear infinite;
}

@keyframes luxSpin {
    to { transform: rotate(360deg); }
}

/* Product card extras */
.product-card {
    position: relative;
}

.product-badge-primary {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 4;
    background: linear-gradient(135deg, #e63946, #ff4757);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(230, 57, 70, 0.45);
}

.product-badge-out {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 3;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.92);
    color: #fecaca;
    border: 1px solid rgba(248, 113, 113, 0.5);
    font-size: 0.78rem;
    font-weight: 800;
    padding: 0.4rem 1rem;
    border-radius: 999px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    white-space: nowrap;
}

.product-card.is-out-of-stock .product-img::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    background: rgba(10, 16, 28, 0.35);
    pointer-events: none;
}

.product-card.is-out-of-stock .product-img img {
    opacity: 0.55;
    filter: grayscale(0.35);
}

.product-card.is-out-of-stock .product-card-actions .btn:disabled {
    background: rgba(71, 85, 105, 0.55) !important;
    border-color: rgba(148, 163, 184, 0.35) !important;
    color: rgba(226, 232, 240, 0.75) !important;
    opacity: 1;
    cursor: not-allowed;
    box-shadow: none;
}

.product-quick-view {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 4;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(126, 200, 255, 0.28);
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.25s ease;
}

.product-card:hover .product-quick-view {
    opacity: 1;
    transform: scale(1);
}

.product-quick-view:hover {
    background: #4da6ff;
    color: #000;
}

.product-img-count {
    position: absolute;
    bottom: 8px;
    left: 8px;
    z-index: 2;
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 8px;
}

.product-img {
    position: relative;
}

.product-card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

body.product-modal-open {
    overflow: hidden;
    touch-action: none;
}

@media (max-width: 768px) {
    .product-modal {
        padding: max(0.5rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-right)) max(0.5rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
        align-items: center;
    }

    .product-modal-dialog {
        max-height: calc(100dvh - 1rem);
        max-height: calc(100vh - 1rem);
    }

    .product-modal-inner {
        border-radius: 18px;
        max-height: calc(100dvh - 1rem);
        max-height: calc(100vh - 1rem);
        min-height: 0;
    }

    .product-modal-content.is-active {
        display: flex;
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        direction: rtl;
    }

    .product-modal-gallery {
        order: 1;
        flex-shrink: 0;
        border-right: none;
        border-bottom: 1px solid rgba(126, 200, 255, 0.12);
        padding: 3rem 1rem 0.85rem;
        overflow: visible;
    }

    .product-modal-info {
        order: 2;
        flex: 1 1 auto;
        min-height: auto;
        overflow: visible;
        padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
    }

    .product-modal-close {
        top: max(10px, env(safe-area-inset-top));
        right: max(10px, env(safe-area-inset-right));
        width: 40px;
        height: 40px;
    }

    .product-modal-info h2 {
        font-size: 1.15rem;
        margin-top: 0.35rem;
    }

    .product-modal-price {
        font-size: 1.25rem;
    }

    .product-modal-desc {
        font-size: 0.9rem;
        line-height: 1.7;
    }

    .product-modal-sizes {
        gap: 0.4rem;
    }

    .size-pill {
        font-size: 0.78rem;
        padding: 0.32rem 0.65rem;
    }

    #productModalCartForm {
        position: sticky;
        bottom: 0;
        z-index: 2;
        margin-top: 1rem;
        padding: 0.75rem 0 0;
        background: linear-gradient(180deg, transparent, rgba(6, 20, 46, 0.92) 24%);
    }

    .product-quick-view {
        opacity: 1;
        transform: scale(1);
    }

    .product-card-actions {
        flex-direction: column;
    }

    .product-modal-main-img {
        min-height: 160px;
    }

    .product-modal-main-img img {
        max-height: min(32dvh, 280px);
        max-height: min(32vh, 280px);
        min-height: 160px;
    }
}

@media (max-width: 480px) {
    .product-modal-inner {
        border-radius: 16px;
    }

    .product-modal-gallery {
        padding: 2.75rem 0.75rem 0.65rem;
    }

    .product-modal-info {
        padding: 0.85rem 0.75rem max(0.85rem, env(safe-area-inset-bottom));
    }

    .product-modal-thumb {
        width: 52px;
        height: 52px;
    }

    .product-modal-main-img img {
        max-height: min(28dvh, 220px);
        max-height: min(28vh, 220px);
        min-height: 140px;
    }
}

@media (max-height: 520px) and (orientation: landscape) {
    .product-modal {
        padding: 0.35rem;
    }

    .product-modal-inner {
        max-height: calc(100dvh - 0.5rem);
        max-height: calc(100vh - 0.5rem);
        min-height: 0;
    }

    .product-modal-content.is-active {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
        overflow: hidden;
    }

    .product-modal-gallery {
        padding: 2.5rem 0.75rem 0.75rem;
        border-bottom: none;
        border-right: 1px solid rgba(126, 200, 255, 0.12);
        overflow-y: auto;
    }

    .product-modal-info {
        overflow-y: auto;
        padding: 2.5rem 0.85rem 0.85rem;
    }

    .product-modal-main-img {
        min-height: 100px;
    }

    .product-modal-main-img img {
        min-height: 100px;
        max-height: 24vh;
    }

    #productModalCartForm {
        position: static;
        background: none;
        padding-top: 0.5rem;
    }
}
