/* ===================================
   IMPROVED PRODUCTS MODAL - MOBILE OPTIMIZED
   =================================== */

/* Modal Overlay */
.ai-products-modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

/* Animation */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Modal Content */
.ai-products-modal .modal-content {
    background: white;
    border-radius: 12px;
    max-width: 90%;
    max-height: 90vh;
    width: 1000px; /* Reduced from 1200px for better sizing */
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
    overflow: hidden;
}

/* Header */
.ai-products-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.ai-products-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* Close Button */
.ai-products-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.ai-products-modal-close:hover {
    background: #e0e0e0;
    color: #333;
}

/* Body */
.ai-products-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Products Grid */
.ai-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

/* Product Card */
.ai-product-card-modal {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: white;
    display: flex;
    flex-direction: column;
}

.ai-product-card-modal:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.ai-product-card-modal img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-bottom: 1px solid #e0e0e0;
}

/* Product Info */
.ai-product-info {
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ai-product-info h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.3;
    color: #333;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-height: 36px;
}

/* Rating */
.ai-product-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 12px;
}

.ai-product-rating .stars {
    color: #ffc107;
    letter-spacing: 1px;
    font-size: 14px;
}

.ai-product-rating span:last-child {
    color: #666;
    font-size: 11px;
}

/* Description */
.ai-product-description {
    margin: 0 0 10px 0;
    font-size: 12px;
    color: #666;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    flex: 1;
}

/* Price */
.ai-product-price {
    font-size: 16px;
    font-weight: bold;
    color: #e74c3c;
    margin-bottom: 10px;
}

/* View Product Button */
.ai-product-btn {
    display: block;
    padding: 8px 12px;
    background: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    transition: background 0.3s ease;
}

.ai-product-btn:hover {
    background: #2980b9;
    color: white;
}

/* Show More Button */
.ai-show-more-btn {
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 20px auto 0;
    padding: 12px 24px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.ai-show-more-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.ai-show-more-btn:active {
    transform: translateY(0);
}

/* Hidden products */
.ai-product-card-modal.hidden {
    display: none;
}

/* ===================================
   MOBILE RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    /* Modal takes full screen on mobile */
    .ai-products-modal .modal-content {
        max-width: 100%;
        max-height: 100vh;
        width: 100%;
        height: 100%;
        border-radius: 0;
        margin: 0;
    }

    /* Header - smaller on mobile */
    .ai-products-modal-header {
        padding: 12px 16px;
    }

    .ai-products-modal-header h3 {
        font-size: 16px;
    }

    .ai-products-modal-close {
        font-size: 22px;
        width: 28px;
        height: 28px;
    }

    /* Body - less padding */
    .ai-products-modal-body {
        padding: 12px;
    }

    /* Single column on mobile */
    .ai-products-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Smaller product cards on mobile */
    .ai-product-card-modal {
        display: flex;
        flex-direction: row;
        min-height: 120px;
    }

    .ai-product-card-modal img {
        width: 120px;
        height: 120px;
        flex-shrink: 0;
        border-bottom: none;
        border-right: 1px solid #e0e0e0;
    }

    .ai-product-info {
        padding: 10px;
        flex: 1;
    }

    .ai-product-info h4 {
        font-size: 13px;
        -webkit-line-clamp: 2;
        min-height: auto;
        margin-bottom: 6px;
    }

    .ai-product-rating {
        margin-bottom: 6px;
        font-size: 11px;
    }

    .ai-product-rating .stars {
        font-size: 12px;
    }

    .ai-product-description {
        font-size: 11px;
        -webkit-line-clamp: 2;
        margin-bottom: 8px;
    }

    .ai-product-price {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .ai-product-btn {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* Show More Button */
    .ai-show-more-btn {
        font-size: 13px;
        padding: 10px 20px;
        margin-top: 12px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .ai-product-card-modal img {
        width: 100px;
        height: 100px;
    }

    .ai-product-info h4 {
        font-size: 12px;
    }

    .ai-product-price {
        font-size: 13px;
    }

    .ai-product-btn {
        font-size: 11px;
        padding: 5px 8px;
    }
}

/* Tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .ai-products-modal .modal-content {
        width: 90%;
        max-width: 800px;
    }

    .ai-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 14px;
    }
}
