/* استایل‌های انتخاب محصول */
.product-selector-container {
    margin: 10px 0;
}

.product-selector-btn {
    background: #0073aa;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.product-selector-btn:hover {
    background: #005a87;
}

.product-selector-btn .selected-product {
    font-weight: bold;
}

/* مودال انتخاب محصول - یکسان با repeater */
.product-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-modal-content {
    background: white;
    border-radius: 10px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    direction: rtl;
}

.product-modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-modal-header h3 {
    margin: 0;
    color: #333;
}

.close {
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #333;
}

.product-modal-body {
    padding: 20px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Mobile first - 2 columns by default */
    gap: 15px;
}

/* Desktop - 4 products per row */
@media (min-width: 1025px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
}

/* Tablet - 3 products per row */
@media (min-width: 769px) and (max-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 18px;
    }
}

.product-item {
    border: 2px solid #eee;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.product-item:hover {
    border-color: #0073aa;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.product-image {
    margin-bottom: 10px;
}

.product-image img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
}

/* استایل پیام عدم وجود محصول */
.no-products-message {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
    grid-column: 1 / -1;
}

.no-products-message p {
    margin: 0;
    color: #999;
    font-style: italic;
}

.product-info h4 {
    margin: 0 0 5px 0;
    color: #333;
    font-size: 14px;
}

.product-info p {
    margin: 0;
    color: #666;
    font-size: 12px;
}



/* پیام‌های سیستم */
.irannotrika-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 5px;
    color: white;
    font-weight: bold;
    z-index: 10000;
    animation: slideIn 0.3s ease;
}

.irannotrika-message.success {
    background: #28a745;
}

.irannotrika-message.error {
    background: #dc3545;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* استایل‌های ریسپانسیو */
/* Tablet - 3 products per row */
@media (max-width: 1024px) and (min-width: 769px) {
    .product-grid,
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 18px;
    }
}

/* Mobile - 2 products per row */
@media (max-width: 768px) {
    .product-modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .product-grid,
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 15px !important;
    }
    
    .product-modal-header {
        padding: 15px;
    }
    
    .product-modal-body {
        padding: 15px;
    }
    
    .irannotrika-message {
        right: 10px;
        left: 10px;
        text-align: center;
    }
    
    /* Debug style to confirm mobile CSS is working */
    .product-modal-overlay::before {
        content: "MOBILE MODE ACTIVE";
        position: fixed;
        top: 10px;
        left: 10px;
        background: red;
        color: white;
        padding: 5px;
        font-size: 12px;
        z-index: 10001;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .product-grid,
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .product-modal-content {
        width: 98%;
        margin: 5px;
    }
    
    .product-modal-body {
        padding: 10px;
    }
}

/* استایل‌های اضافی برای سازگاری با گرویتی فرم */
.gform_wrapper .product-selector-container {
    margin: 10px 0;
}



/* بهبود نمایش در حالت RTL */
[dir="rtl"] .product-modal-header {
    flex-direction: row-reverse;
}



/* Loading Modal Styles */
.loading-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-modal-content {
    background: white;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Product Modal Styles for Repeater */
.product-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.product-modal-content {
    background: white;
    border-radius: 8px;
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.product-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.product-modal-header h3 {
    margin: 0;
    color: #333;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    color: #333;
}

.product-modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Mobile first - 2 columns by default */
    gap: 15px;
}

/* Desktop - 4 products per row */
@media (min-width: 1025px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
}

/* Tablet - 3 products per row */
@media (min-width: 769px) and (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 18px;
    }
}

.product-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.product-item:hover {
    border-color: #3498db;
    box-shadow: 0 2px 10px rgba(52, 152, 219, 0.2);
    transform: translateY(-2px);
}

.product-image {
    text-align: center;
    margin-bottom: 10px;
}

.product-image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.product-info h4 {
    margin: 0 0 5px 0;
    color: #333;
    font-size: 16px;
}

.product-category {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* Image Loading Styles - یکسان با repeater */
.image-loading {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 14px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 10px;
}

.product-image img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    transition: opacity 0.3s ease;
}

.product-image img[style*="display: none"] {
    opacity: 0;
}

.product-image img:not([style*="display: none"]) {
    opacity: 1;
}
