/* Override any potential z-index conflicts */
#quick-view-modal.modal-overlay {
    z-index: 9999999 !important;
}

#quick-view-modal.modal-overlay .modal-content {
    z-index: 9999999 !important;
}

#quick-view-modal.modal-overlay .modal-header {
    z-index: 9999999 !important;
}

/* Modal Base Styles - Derived from quick-view-sample.html */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 0;
    box-sizing: border-box;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 20px 20px 0 0;
    max-width: 650px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

/* Desktop styles - center modal */
@media (min-width: 769px) {
    .modal-overlay {
        align-items: center;
        padding: 20px;
    }

    .modal-content {
        border-radius: 20px;
        max-height: 85vh;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
        transform: translateY(100px);
    }

    .modal-overlay.active .modal-content {
        transform: translateY(0);
    }
}

.modal-header {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 999999;
}

.close-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #666;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.close-btn:hover {
    background: white;
    color: #333;
    transform: scale(1.1);
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    padding: 25px;
    flex: 1;
    overflow: auto;
    min-height: 0;
}

/* Left Side - Image Gallery */
.image-gallery {
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
}

.main-image-container {
    position: relative;
    aspect-ratio: 1;
    border-radius: 15px;
    overflow: hidden;
    background: #f8f6f4;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    flex: 1;
}

.main-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease-in-out;
    /* Ensure smoother image transitions */
    will-change: opacity;
    backface-visibility: hidden;
}

.image-thumbnails {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    background: #f8f6f4;
}

.thumbnail:hover,
.thumbnail.active {
    border-color: #1d7b89;
    transform: scale(1.05);
}

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

/* Right Side - Product Details */
.product-details {
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: 100%;
    min-height: 0;
}

.product-category {
    font-size: 13px;
    color: #1d7b89;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.product-title {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.2;
    margin-top: -4px;
}

.product-description {
    color: #666;
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 4px;
    overflow-y: auto;
    max-height: 120px;
    scrollbar-width: thin;
    scrollbar-color: #e0e0e0 transparent;
    position: relative;
}

.product-description::-webkit-scrollbar {
    width: 4px;
}

.product-description::-webkit-scrollbar-track {
    background: transparent;
}

.product-description::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 2px;
}

.product-description::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

.product-description::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 15px;
    background: linear-gradient(transparent, rgba(255, 255, 255, 0.8));
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.product-description[data-scrollable="true"]::after {
    opacity: 1;
}

.price-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}

.current-price {
    font-size: 22px;
    font-weight: 700;
    color: #1d7b89;
}

.original-price {
    font-size: 16px;
    color: #999;
    text-decoration: line-through;
}

.discount-tag {
    background: #ff6b6b;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.variant-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.variant-label {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

.variant-options {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.variant-option {
    padding: 5px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 16px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
    font-weight: 500;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.variant-option:hover,
.variant-option.active {
    border-color: #1d7b89;
    background: #f0f8f9;
    color: #1d7b89;
}

.quantity-section {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.quantity-label {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

.quantity-controls {
    display: flex;
    align-items: center;
    border: 2px solid #e0e0e0;
    border-radius: 18px;
    background: white;
    overflow: hidden;
    height: 36px;
}

.quantity-btn {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: all 0.3s ease;
}

.quantity-btn:hover {
    background: #f0f8f9;
    color: #1d7b89;
}

.quantity-input {
    border: none;
    width: 45px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    background: transparent;
    height: 32px;
}

.action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 0;
    padding-top: 8px;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    background: white;
    z-index: 10;
}

.btn-primary {
    background: #1d7b89;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(29, 123, 137, 0.3);
    flex: 1;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover {
    background: #165a66;
    transform: translateY(-1px);
    box-shadow: 0 5px 18px rgba(29, 123, 137, 0.4);
}

.btn-secondary {
    background: white;
    color: #1d7b89;
    border: 2px solid #1d7b89;
    padding: 8px 18px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary:hover {
    background: #f0f8f9;
    transform: translateY(-1px);
    color: #1d7b89;
}

.wishlist-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.wishlist-section:hover {
    color: #ff6b6b;
}

.wishlist-icon {
    font-size: 18px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
        padding-top: 0;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
    }

    .modal-content {
        max-height: 92vh;
        max-height: 92dvh; /* Ensure it fits in dynamic viewport */
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
        max-width: 100%;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);
        min-height: 0;
        overflow: hidden;
    }

    .modal-overlay.active .modal-content {
        transform: translateY(0);
    }

    .modal-header {
        top: 8px;
        right: 8px;
        z-index: 20;
    }

    .close-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .modal-body {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 10px 10px 0 10px;
        overflow-y: auto;
        min-height: 0;
        flex: 1;
        display: flex;
        flex-direction: column;
        max-height: calc(92vh - 20px);
        max-height: calc(92dvh - 20px);
    }

    /* Compact Mobile Image Gallery */
    .image-gallery {
        order: 1;
        display: block;
        width: 100%;
        max-width: 100%;
        margin: 0;
        flex-shrink: 0;
    }

    .main-image-container {
        width: 100%;
        aspect-ratio: 1.3;
        border-radius: 8px;
        margin-bottom: 6px;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    }

    .image-thumbnails {
        display: flex;
        gap: 6px;
        justify-content: flex-start;
        overflow-x: auto;
        padding: 2px 0;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .image-thumbnails::-webkit-scrollbar {
        display: none;
    }

    .thumbnail {
        width: 45px;
        height: 45px;
        border-radius: 6px;
        flex-shrink: 0;
        border: 2px solid transparent;
    }

    .thumbnail:hover,
    .thumbnail.active {
        border-color: #1d7b89;
        transform: scale(1.05);
    }

    /* Compact Mobile Product Details */
    .product-details {
        order: 2;
        gap: 8px;
        height: auto;
        min-height: 0;
        flex: 1;
        display: flex;
        flex-direction: column;
    }

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

    .product-title {
        font-size: 18px;
        line-height: 1.2;
        margin-top: -2px;
        margin-bottom: 4px;
    }

    .product-description {
        font-size: 11px;
        line-height: 1.4;
        margin-bottom: 2px;
        overflow-y: auto;
        max-height: 60px;
        scrollbar-width: thin;
        scrollbar-color: #e0e0e0 transparent;
    }

    .product-description::-webkit-scrollbar {
        width: 2px;
    }

    .price-section {
        gap: 6px;
        margin-bottom: 4px;
    }

    .current-price {
        font-size: 18px;
    }

    .original-price {
        font-size: 13px;
    }

    .discount-tag {
        font-size: 9px;
        padding: 2px 6px;
    }

    .variant-section {
        gap: 6px;
        margin-bottom: 6px;
    }

    .variant-label {
        font-size: 12px;
    }

    .variant-options {
        gap: 4px;
    }

    .variant-option {
        padding: 4px 10px;
        font-size: 11px;
        border-radius: 12px;
    }

    .quantity-section {
        gap: 8px;
        margin-bottom: 0;
        margin-top: auto;
    }

    .quantity-label {
        font-size: 12px;
    }

    .quantity-controls {
        border-radius: 14px;
    }

    .quantity-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .quantity-input {
        width: 40px;
        font-size: 12px;
    }

    .action-buttons {
        gap: 6px;
        margin-top: 12px;
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 15;
        padding: 10px;
        margin-left: -10px;
        margin-right: -10px;
        margin-bottom: 0;
        border-top: 1px solid #f0f0f0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }

    .btn-primary,
    .btn-secondary {
        padding: 12px 12px;
        font-size: 12px;
        border-radius: 4px;
        height: 44px;
        font-weight: 600;
        touch-action: manipulation;
    }
}

@media (max-width: 480px) {
    .modal-overlay {
        padding: 0;
        padding-top: 0;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
    }

    .modal-content {
        max-height: 90vh;
        max-height: 90dvh; /* Ensure it fits in smaller screens */
        border-radius: 12px 12px 0 0;
        min-height: 0;
        overflow: hidden;
    }

    .modal-header {
        top: 6px;
        right: 6px;
        z-index: 20;
    }

    .close-btn {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .modal-body {
        padding: 8px 8px 0 8px;
        gap: 8px;
        max-height: calc(90vh - 16px);
        max-height: calc(90dvh - 16px);
        overflow-y: auto;
    }

    .main-image-container {
        aspect-ratio: 1.4;
        border-radius: 6px;
        margin-bottom: 4px;
    }

    .image-thumbnails {
        gap: 4px;
        padding: 2px 0;
    }

    .thumbnail {
        width: 40px;
        height: 40px;
        border-radius: 4px;
    }

    .product-details {
        gap: 6px;
    }

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

    .product-title {
        font-size: 16px;
        margin-bottom: 3px;
    }

    .product-description {
        font-size: 10px;
        overflow-y: auto;
        max-height: 50px;
        scrollbar-width: thin;
        scrollbar-color: #e0e0e0 transparent;
    }

    .product-description::-webkit-scrollbar {
        width: 2px;
    }

    .current-price {
        font-size: 16px;
    }

    .original-price {
        font-size: 12px;
    }

    .discount-tag {
        font-size: 8px;
        padding: 1px 4px;
    }

    .variant-label,
    .quantity-label {
        font-size: 11px;
    }

    .variant-option {
        padding: 3px 8px;
        font-size: 10px;
        border-radius: 10px;
    }

    .quantity-section {
        margin-bottom: 0;
        margin-top: auto;
    }

    .quantity-btn {
        width: 24px;
        height: 24px;
        font-size: 11px;
    }

    .quantity-input {
        width: 35px;
        font-size: 11px;
    }

    .btn-primary,
    .btn-secondary {
        padding: 10px 10px;
        font-size: 11px;
        border-radius: 4px;
        height: 40px;
        font-weight: 600;
        touch-action: manipulation;
    }

    .action-buttons {
        margin-top: 10px;
        flex-shrink: 0;
        position: sticky;
        bottom: 0;
        background: white;
        z-index: 15;
        padding: 8px;
        margin-left: -8px;
        margin-right: -8px;
        margin-bottom: 0;
        gap: 6px;
        border-top: 1px solid #f0f0f0;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    }
}
