/* Modal Container */
#product-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 0;
    z-index: 1001;
    width: 95vw;
    height: 95vh;
    max-width: 1200px;
    max-height: 95vh;
    overflow: hidden;
}

/* Modal Backdrop */
#modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    backdrop-filter: blur(3px);
}

/* Modal Layout */
.modal-container {
    display: flex;
    gap: 30px;
    padding: 30px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

/* Image Container */
.modal-image-container {
    flex: 0 0 70%;
    max-width: 70%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 20px;
    box-sizing: border-box;
    margin: 0 auto;
}

.modal-product-image {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    object-position: center;
    border-radius: 12px;
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.modal-product-image:hover {
    transform: scale(1.02);
}

/* Content Container */
.modal-content {
    flex: 1;
    padding: 0 20px 20px 20px; /* Added bottom padding */
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Allow scrolling for content */
    justify-content: flex-start; /* Start from top */
    max-height: 100%;
}

/* Product Title */
.modal-product-title {
    color: #7a5c3e;
    font-family: 'Georgia', serif;
    font-size: 2em;
    margin: 0 0 10px 0;
    padding: 0;
    border: none;
}

/* Form Elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #5a4a3a;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d4c9b9;
    border-radius: 6px;
    font-size: 1em;
    color: #5a4a3a;
    background-color: #fff;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: #b48c64;
    outline: none;
    box-shadow: 0 0 0 2px rgba(180, 140, 100, 0.2);
}

/* Quantity Controls */
.quantity-group {
    margin: 25px 0;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.qty-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #d4c9b9;
    background: #fff;
    border-radius: 6px;
    font-size: 1.1em;
    cursor: pointer;
    color: #7a5c3e;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.qty-btn:hover {
    background: #f5f1eb;
    border-color: #b48c64;
}

.quantity-input {
    width: 60px;
    text-align: center;
    padding: 8px;
    border: 1px solid #d4c9b9;
    border-radius: 6px;
    font-size: 1em;
}

/* Price & Stock */
.price-stock-container {
    margin: 20px 0;
    padding: 15px;
    background: #f9f7f3;
    border-radius: 8px;
}

.modal-price {
    color: #b48c64;
    font-size: 1.5em;
    font-weight: 600;
    font-family: 'Georgia', serif;
    display: block;
    margin-bottom: 5px;
}

.modal-stock {
    color: #7a8b94;
    font-size: 0.95em;
}

/* Add to Cart Button */
.add-cart-btn {
    width: 100%;
    padding: 14px;
    background: #b48c64;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin: 25px 0;
}

.add-cart-btn:hover {
    background: #9c7a56;
}

/* Product Description */
.product-description {
    margin: 5px 0 20px 0;
    padding: 0;
    border: none;
    overflow-y: auto;
    flex: 0 0 auto;
    padding-right: 10px;
    margin-right: -10px;
    color: #5a4a3a;
    line-height: 1.5;
}

/* Custom scrollbar for description */
.product-description::-webkit-scrollbar {
    width: 6px;
}

.product-description::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

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

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

.product-description h3 {
    color: #7a5c3e;
    margin: 0 0 15px 0;
    font-size: 1.3em;
}

.product-description p {
    color: #5a4a3a;
    line-height: 1.6;
    margin: 0;
}

/* Fullscreen Image Viewer */
.image-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    overflow: auto;
    padding: 20px;
    box-sizing: border-box;
}

.image-viewer img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
    cursor: default;
}

.image-viewer img:hover {
    transform: scale(1.02);
}

.close-viewer {
    position: fixed;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2001;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-viewer:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.modal-product-image {
    cursor: zoom-in;
    transition: transform 0.3s ease;
    border-radius: 8px;
}

.modal-product-image:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.modal-product-image:active {
    transform: scale(0.98);
}

/* Image viewer controls */
.image-viewer-controls {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    z-index: 2001;
    flex-wrap: wrap;
    justify-content: center;
}

.image-viewer-btn {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    min-width: 100px;
}

.image-viewer-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.9);
    transform: translateY(-2px);
}

.image-viewer-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Mobile responsive for image viewer */
@media (max-width: 768px) {
    .image-viewer {
        padding: 10px;
    }
    
    .image-viewer img {
        max-width: 100%;
        max-height: calc(100vh - 100px);
    }
    
    .close-viewer {
        top: 15px;
        right: 15px;
        font-size: 30px;
        width: 50px;
        height: 50px;
    }
    
    .image-viewer-controls {
        bottom: 20px;
        gap: 10px;
    }
    
    .image-viewer-btn {
        padding: 10px 15px;
        font-size: 12px;
    }
}

/* Responsive Design - Mobile First Approach */
@media (max-width: 768px) {
    #product-modal {
        width: 100vw;
        height: 100vh;
        padding: 0;
        box-sizing: border-box;
        border-radius: 0;
        overflow-y: auto;
    }
    
    .modal-container {
        flex-direction: column;
        gap: 15px;
        padding: 10px;
        min-height: 100vh;
        display: flex;
        overflow: visible;
    }
    
    .modal-image-container {
        flex: none;
        max-width: 100%;
        height: auto;
        margin: 0 auto;
        padding: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 60vh;
    }
    
    .modal-product-image {
        max-height: 80vh;
        max-width: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        border-radius: 8px;
    }
    
    .modal-content {
        padding: 0 10px 20px 10px;
        flex: none;
        display: flex;
        flex-direction: column;
        min-height: auto;
    }
    
    /* Adjust font sizes and spacing for mobile */
    .modal-product-title {
        font-size: 1.2em !important; /* Reduced from 1.5em */
        margin: 2px 0 !important; /* Reduced from 5px */
        line-height: 1.2;
    }
    
    .product-description {
        font-size: 0.8em; /* Reduced from 0.9em */
        margin: 0 0 20px 0 !important; /* Increased bottom margin for better spacing */
        flex: 0 0 auto;
        line-height: 1.3;
    }
    
    .form-group {
        margin-bottom: 6px; /* Reduced from 12px */
    }
    
    .form-group label {
        font-size: 0.8em; /* Reduced from 0.9em */
        margin-bottom: 2px; /* Reduced from 5px */
    }
    
    .form-control, .quantity-input {
        padding: 6px 8px; /* Reduced from 8px 10px */
        font-size: 0.85em; /* Reduced from 0.95em */
    }
    
    .qty-btn {
        width: 26px; /* Reduced from 30px */
        height: 26px; /* Reduced from 30px */
        font-size: 0.9em; /* Reduced from 1em */
    }
    
    .quantity-input {
        width: 40px; /* Reduced from 50px */
    }
    
    .add-cart-btn {
        padding: 10px; /* Reduced from 12px */
        font-size: 0.9em; /* Reduced from 1em */
        margin: 8px 0 0 0 !important; /* Reduced top margin from 15px to 8px */
        position: relative;
        z-index: 2;
    }
    
    .price-stock-container {
        margin: 5px 0 !important; /* Reduced from 10px */
        padding: 5px 8px !important; /* Reduced from 10px */
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: #f8f9fa;
        border-radius: 4px;
    }
    
    .modal-price {
        font-size: 1.1em !important; /* Reduced from 1.2em */
        font-weight: bold;
        color: #333;
    }
    
    .modal-stock {
        font-size: 0.8em !important; /* Reduced from 0.9em */
        color: #666;
    }
}

/* Extra small devices (phones, 600px and down) */
@media (max-width: 600px) {
    #product-modal {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        padding: 0;
        overflow-y: auto;
    }
    
    .modal-container {
        padding: 5px;
        gap: 10px;
        min-height: 100vh;
        overflow: visible;
    }
    
    .modal-image-container {
        flex: none;
        max-width: 100%;
        height: auto;
        margin: 0 auto;
        padding: 5px;
        min-height: 70vh;
    }
    
    .modal-product-image {
        max-height: 85vh;
        max-width: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
        border-radius: 6px;
    }
    
    .modal-content {
        flex: none;
        padding: 0 5px 15px 5px;
        min-height: auto;
    }
    
    .modal-product-title {
        font-size: 1.3em !important;
    }
    
    .product-description {
        font-size: 0.85em;
    }
    
    .form-group {
        margin-bottom: 10px;
    }
}

/* Very small screens (phones in portrait) */
@media (max-width: 576px) {
    .modal-container {
        padding: 3px;
        gap: 8px;
        min-height: 100vh;
        overflow: visible;
    }
    
    .modal-image-container {
        flex: none;
        max-width: 100%;
        height: auto;
        margin: 0 auto;
        padding: 3px;
        min-height: 75vh;
    }
    
    .modal-product-image {
        max-height: 90vh;
        max-width: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
    }
    
    .modal-content {
        flex: none;
        padding: 0 3px 10px 3px;
        min-height: auto;
    }
    
    .modal-product-title {
        font-size: 1.4em !important;
        margin: 1px 0 !important;
    }
    
    .modal-price {
        font-size: 1.2em !important;
    }
    
    .add-cart-btn {
        padding: 10px;
        font-size: 0.9em;
        margin: 5px 0 !important;
    }
    
    .form-group {
        margin-bottom: 5px !important;
    }
    
    .form-group label {
        font-size: 0.75em !important;
        margin-bottom: 1px !important;
    }
    
    .form-control, .quantity-input {
        padding: 5px 6px !important;
        font-size: 0.8em !important;
    }
    
    .qty-btn {
        width: 24px !important;
        height: 24px !important;
        font-size: 0.8em !important;
    }
    
    .quantity-input {
        width: 35px !important;
    }
    
    .price-stock-container {
        margin: 3px 0 !important;
        padding: 3px 6px !important;
    }
}
