/**
 * Product Query Optimizer - Frontend Styles
 * Harmonscreations - Exclusive for Spiritual Quest
 */

.pqo-products-grid {
    display: grid;
    gap: 20px;
    margin: 20px 0;
}

.pqo-columns-1 {
    grid-template-columns: 1fr;
}

.pqo-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.pqo-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.pqo-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

.pqo-columns-5 {
    grid-template-columns: repeat(5, 1fr);
}

.pqo-columns-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .pqo-columns-3,
    .pqo-columns-4,
    .pqo-columns-5,
    .pqo-columns-6 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .pqo-products-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
}

.pqo-product-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    background: #fff;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.pqo-product-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.pqo-product-image {
    margin-bottom: 12px;
    text-align: center;
}

.pqo-product-image img,
.pqo-product-image .pqo-product-img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    transition: transform 0.3s ease;
    display: block;
    margin: 0 auto;
}

.pqo-product-image:hover img {
    transform: scale(1.05);
}

.pqo-product-details {
    text-align: center;
}

.pqo-product-title {
    margin: 0 0 10px 0;
    font-size: 16px;
    line-height: 1.4;
}

.pqo-product-title a {
    text-decoration: none;
    color: #333;
    font-weight: 600;
}

.pqo-product-title a:hover {
    color: #007cba;
}

.pqo-product-price {
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: bold;
}

.pqo-product-price .price {
    color: #333;
}

.pqo-product-price .price del {
    color: #999;
    font-weight: normal;
    margin-right: 5px;
}

.pqo-product-price .price ins {
    color: #e74c3c;
    text-decoration: none;
}

.pqo-product-actions {
    margin-top: auto;
}

.pqo-add-to-cart-btn {
    background: #007cba;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pqo-add-to-cart-btn:hover {
    background: #005a87;
    transform: translateY(-1px);
}

.pqo-add-to-cart-btn:active {
    transform: translateY(0);
}

.pqo-add-to-cart-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.pqo-add-to-cart-btn.loading {
    position: relative;
    color: transparent;
}

.pqo-add-to-cart-btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    margin: auto;
    border: 2px solid transparent;
    border-top-color: #fff;
    border-radius: 50%;
    animation: pqo-spin 1s linear infinite;
}

.pqo-add-to-cart-btn.added {
    background: #27ae60;
}

.pqo-add-to-cart-btn.added::before {
    content: "✓ ";
}

.pqo-out-of-stock {
    display: inline-block;
    padding: 10px 20px;
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
    text-align: center;
}

.pqo-error,
.pqo-no-products {
    text-align: center;
    padding: 20px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 20px 0;
}

.pqo-no-products {
    background: #fff3cd;
    color: #856404;
    border-color: #ffeaa7;
}

/* Loading animation */
@keyframes pqo-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Success message styling */
.pqo-success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #27ae60;
    color: white;
    padding: 15px 20px;
    border-radius: 4px;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.pqo-success-message.show {
    transform: translateX(0);
}

.pqo-success-message .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    float: right;
    margin-left: 10px;
    padding: 0;
    line-height: 1;
}

/* WooCommerce compatibility */
.woocommerce .pqo-products-grid,
.woocommerce-page .pqo-products-grid {
    margin: 20px 0;
}

/* Theme compatibility adjustments */
.pqo-product-item * {
    box-sizing: border-box;
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .pqo-product-image img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Print styles */
@media print {
    .pqo-add-to-cart-btn,
    .pqo-product-actions {
        display: none !important;
    }
}

/* Accessibility improvements */
.pqo-add-to-cart-btn:focus {
    outline: 2px solid #005a87;
    outline-offset: 2px;
}

.pqo-product-title a:focus {
    outline: 2px solid #007cba;
    outline-offset: 1px;
}

/* Loading state for the entire grid */
.pqo-products-grid.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .pqo-product-item {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .pqo-product-title a {
        color: #e2e8f0;
    }
    
    .pqo-product-title a:hover {
        color: #63b3ed;
    }
    
    .pqo-product-price .price {
        color: #e2e8f0;
    }
    
    .pqo-out-of-stock {
        background: #4a5568;
        color: #a0aec0;
        border-color: #2d3748;
    }
}