/* ==========================================
   REFINED PROFESSIONAL PRODUCT MODAL
   ========================================== */

:root {
    --primary: #00A878;
    --primary-light: #33C49C;
    --primary-dark: #007a59;
    --secondary: #008FA3;
    --accent: #FFD166;
    --light: #F4FFFA;
    --dark: #1E2A23;
    --gray-100: #FAFAFA;
    --gray-200: #E8F0ED;
    --gray-300: #D0DDD9;
    --gray-500: #6D7A76;
    --gray-600: #45504C;
}

/* Modal Overlay */
.product-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease;
    overflow-y: auto;
    padding: 20px;
}

.product-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Modal Content Wrapper */
.modal-content-wrapper {
    position: relative;
    background: #ffffff;
    width: 100%;
    max-width: 900px;
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

@keyframes slideUp {
    from {
        transform: translateY(40px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Close Button */
.modal-close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 2rem;
    color: white;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.modal-close:hover {
    background: rgb(0,0,0);
    border-color: rgb(0,0,0);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 5px 20px rgba(122, 211, 166, 0.5);
}

/* Modal Body - Two Column Layout */
.modal-body {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 0;
    min-height: 500px;
    max-height: 85vh;
}

/* ===== LEFT SIDE - IMAGE SECTION ===== */
.modal-image-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Subtle pattern overlay */
.modal-image-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 30%, rgba(0, 168, 120, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(0, 168, 120, 0.02) 0%, transparent 50%);
    pointer-events: none;
}

/* Main Product Image */
.modal-product-image {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    position: relative;
    z-index: 1;
    min-height: 400px;
}

.modal-product-image img {
    max-width: 100%;
    max-height: 380px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.1));
    transition: all 0.4s ease;
}

.modal-product-image img:hover {
    transform: scale(1.05);
}

/* Thumbnail Gallery - Larger Size */
.modal-thumbnails {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.5);
    border-top: 1px solid rgba(0, 168, 120, 0.1);
    position: relative;
    z-index: 2;
}

.thumbnail-item {
    width: 90px;
    height: 90px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid rgba(0, 168, 120, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.thumbnail-item:hover,
.thumbnail-item.active {
    border-color: var(--primary);
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 168, 120, 0.25);
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
    background: white;
}

/* ===== RIGHT SIDE - PRODUCT DETAILS ===== */
.modal-details-section {
    padding: 0;
    background: white;
    overflow-y: auto;
    max-height: 85vh;
}

.modal-details-section::-webkit-scrollbar {
    width: 6px;
}

.modal-details-section::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.modal-details-section::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

/* Product Info Container */
.modal-product-info {
    padding: 2.5rem;
}

/* Product Name */
.modal-product-title,
.modal-product-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 12px;
    line-height: 1.3;
}

/* Category Badge - Subtle */
.modal-product-category {
    display: inline-block;
    background: var(--light);
    color: var(--primary);
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid var(--primary-light);
}

/* Product Description */
.modal-product-description {
    color: var(--gray-600);
    font-size: 0.95rem;
    line-height: 1.8;
    margin-bottom: 24px;
    padding: 0;
    background: transparent;
    border: none;
}

/* Price Display - More Subtle */
    .modal-price-display {
        background: var(--light);
        padding: 20px;
        border-radius: 12px;
        margin-bottom: 24px;
        text-align: center;
        border: 1px solid var(--primary-light);
    }

    .modal-price {
        font-size: 2rem;
        font-weight: 800;
        color: var(--primary);
    }

    .modal-price-unit {
        color: var(--gray-500);
        font-size: 0.9rem;
        margin-top: 4px;
    }

.modal-price-note {
    color: var(--gray-500);
    font-size: 0.85rem;
    margin-top: 8px;
}

/* Quick Specs - Clean Grid */
.modal-quick-specs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 0;
    background: transparent;
    border-radius: 0;
    margin-bottom: 24px;
}

.spec-item {
    text-align: center;
    padding: 16px 12px;
    background: var(--gray-100);
    border-radius: 10px;
    transition: all 0.3s ease;
    border: 1px solid var(--gray-200);
}

.spec-item:hover {
    background: var(--light);
    border-color: var(--primary-light);
    transform: translateY(-2px);
}

.spec-label {
    font-size: 0.7rem;
    color: var(--gray-500);
    text-transform: uppercase;
    margin-bottom: 6px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.spec-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--dark);
}

/* Specifications Container */
.specs-container {
    background: var(--gray-100);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid var(--gray-200);
}

.specs-container h6 {
    color: var(--dark);
    font-weight: 700;
    margin-bottom: 16px;
    font-size: 1rem;
}

.spec-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-200);
}

.spec-row:last-child {
    border-bottom: none;
}

.spec-row .spec-label {
    font-size: 0.9rem;
    color: var(--gray-600);
    font-weight: 500;
}

.spec-row .spec-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--dark);
}

/* Features List */
.features-list {
    background: var(--gray-100);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid var(--gray-200);
}

.features-list h6 {
    color: var(--dark);
    font-weight: 700;
    margin-bottom: 16px;
    font-size: 1rem;
}

.feature-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
    color: var(--gray-600);
    font-size: 0.9rem;
}

.feature-item i {
    color: var(--primary);
    margin-top: 3px;
    font-size: 0.85rem;
}

/* Action Buttons - Refined */
.modal-actions {
    display: flex;
    gap: 12px;
}

.btn-contact-seller,
.btn-get-quote {
    flex: 1;
    padding: 16px 24px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-contact-seller {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 168, 120, 0.25);
}

.btn-contact-seller:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 168, 120, 0.35);
}

.btn-get-quote {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-get-quote:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 168, 120, 0.25);
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 991px) {
    .modal-body {
        grid-template-columns: 1fr;
        max-height: none;
    }
    
    .modal-image-section {
        min-height: 400px;
    }
    
    .modal-product-image {
        padding: 2rem;
        min-height: 350px;
    }
}

@media (max-width: 767px) {
    .modal-content-wrapper {
        max-width: 95%;
        border-radius: 16px;
    }
    
    .modal-product-info {
        padding: 1.5rem;
    }
    
    .modal-product-title,
    .modal-product-name {
        font-size: 1.5rem;
    }
    
    .modal-price {
        font-size: 1.7rem;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-quick-specs {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .thumbnail-item {
        width: 70px;
        height: 70px;
    }
}

@media (max-width: 575px) {
    .thumbnail-item {
        width: 60px;
        height: 60px;
    }
    
    .modal-thumbnails {
        gap: 8px;
        padding: 15px;
    }
    
    .modal-quick-specs {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}


/* Missing Modal Styles */
.modal-product-title {
    font-size: 1.9rem;
    font-weight: 800;
    color: #0B2154;
    margin-bottom: 0.75rem;
}

.specs-container {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.specs-container h6 {
    color: #0B2154;
    font-weight: 700;
    margin-bottom: 1rem;
}

.spec-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e0e0e0;
}

.spec-row:last-child {
    border-bottom: none;
}

.features-list {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.features-list h6 {
    color: #0B2154;
    font-weight: 700;
    margin-bottom: 1rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    color: #555;
}

.feature-item i {
    color: var(--primary);
}

.modal-price-note {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

/* Add this to your product-modal.css */

/* Smooth image transition */
#modal-main-image {
    transition: opacity 0.3s ease;
}

/* Thumbnail active state animation */
.thumbnail-item.active {
    animation: thumbPulse 0.4s ease;
}

@keyframes thumbPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1.05); }
}

.thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    padding: 0px;  
    background: white;
}


/* ==========================================
   MOBILE MODAL FIXES - CRITICAL
   ========================================== */

/* 1. FIX MODAL CONTAINER OVERFLOW */
@media (max-width: 991px) {
    .product-modal {
        padding: 10px;
        align-items: flex-start; /* Start from top on mobile */
        padding-top: 20px;
    }

    .modal-content-wrapper {
        max-width: 100%;
        width: 100%;
        max-height: calc(100vh - 40px); /* Leave space for padding */
        overflow-y: auto;
        margin: 0;
    }

    /* Grid becomes single column */
    .modal-body {
        grid-template-columns: 1fr;
        max-height: none;
        overflow: visible;
    }

    /* Image section - smaller on mobile */
    .modal-image-section {
        min-height: 300px;
        position: relative;
    }

    .modal-product-image {
        padding: 1.5rem;
        min-height: 250px;
    }

    .modal-product-image img {
        max-height: 250px;
    }

    /* Details section - scrollable */
    .modal-details-section {
        max-height: none;
        overflow-y: visible;
    }

    .modal-product-info {
        padding: 1.5rem;
    }
}

/* 2. FIX CLOSE BUTTON - ALWAYS VISIBLE */
.modal-close {
    position: fixed; /* Changed from absolute to fixed */
    right: 15px;
    top: 15px;
    font-size: 1.8rem;
    z-index: 10000; /* Higher z-index */
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    width: 40px;
    height: 40px;
}

@media (max-width: 767px) {
    .modal-close {
        width: 45px;
        height: 45px;
        right: 10px;
        top: 10px;
        font-size: 1.5rem;
        background: var(--primary);
        border: 2px solid white;
    }

    .modal-close:hover {
        background: var(--primary-dark);
        transform: scale(1.1);
    }
}

/* 3. FIX THUMBNAILS ON MOBILE */
@media (max-width: 767px) {
    .modal-thumbnails {
        gap: 8px;
        padding: 12px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .modal-thumbnails::-webkit-scrollbar {
        height: 4px;
    }

    .modal-thumbnails::-webkit-scrollbar-thumb {
        background: var(--primary);
        border-radius: 4px;
    }

    .thumbnail-item {
        width: 70px;
        height: 70px;
        flex-shrink: 0;
    }
}

@media (max-width: 575px) {
    .thumbnail-item {
        width: 60px;
        height: 60px;
    }
}

/* 4. FIX QUICK SPECS GRID */
@media (max-width: 767px) {
    .modal-quick-specs {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .modal-quick-specs {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .spec-item {
        padding: 12px 10px;
    }
}

/* 5. FIX ACTION BUTTONS ON MOBILE */
@media (max-width: 767px) {
    .modal-actions {
        flex-direction: column;
        gap: 10px;
    }

    .btn-contact-seller,
    .btn-get-quote,
    .btn-email-quote,
    .btn-whatsapp-quote {
        width: 100%;
        padding: 14px 20px;
        font-size: 0.9rem;
    }
}

/* 6. FIX FONT SIZES ON MOBILE */
@media (max-width: 767px) {
    .modal-product-title,
    .modal-product-name {
        font-size: 1.4rem;
        line-height: 1.3;
    }

    .modal-product-description {
        font-size: 0.9rem;
        line-height: 1.6;
    }

    .spec-label {
        font-size: 0.65rem;
    }

    .spec-value {
        font-size: 0.85rem;
    }
}

/* 7. FIX MODAL OVERLAY - PREVENT BODY SCROLL */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* 8. ENSURE MODAL CLOSES ON BACKGROUND CLICK */
.product-modal {
    cursor: pointer;
}

.modal-content-wrapper {
    cursor: default;
}

/* 9. FIX SPECS CONTAINER ON MOBILE */
@media (max-width: 767px) {
    .specs-container,
    .features-list {
        padding: 15px;
        margin-bottom: 15px;
    }

    .specs-container h6,
    .features-list h6 {
        font-size: 0.95rem;
        margin-bottom: 12px;
    }

    .spec-row {
        padding: 10px 0;
        flex-direction: column;
        gap: 4px;
    }

    .feature-item {
        font-size: 0.85rem;
        padding: 6px 0;
    }
}

/* 10. FIX VERY SMALL SCREENS */
@media (max-width: 400px) {
    .modal-product-info {
        padding: 1rem;
    }

    .modal-product-title,
    .modal-product-name {
        font-size: 1.2rem;
    }

    .modal-product-image {
        padding: 1rem;
        min-height: 200px;
    }

    .modal-product-image img {
        max-height: 200px;
    }
}

/* 11. PREVENT HORIZONTAL SCROLL IN MODAL */
.modal-content-wrapper,
.modal-body,
.modal-details-section,
.modal-product-info {
    max-width: 100%;
    overflow-x: hidden;
}

/* 12. FIX PRICE DISPLAY ON MOBILE */
@media (max-width: 767px) {
    .modal-price-display {
        padding: 15px;
        margin-bottom: 20px;
    }

    .modal-price {
        font-size: 1.6rem;
    }

    .modal-price-unit {
        font-size: 0.85rem;
    }
}

/* 13. SMOOTH SCROLLING IN MODAL */
.modal-content-wrapper {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.modal-details-section {
    -webkit-overflow-scrolling: touch;
}