/**
 * Products Page Styles
 * Optimized and cached
 */

/* Main Container */
.product-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    animation: fadeIn 1s ease-out;
}

/* Page Title */
.latest {
    font-size: clamp(24px, 5vw, 32px);
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    margin: 20px auto;
    padding: 16px 32px;
    border-radius: 20px;
    display: inline-block;
}

/* Category Scroll */
.scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 16px 0;
    margin-bottom: 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--glass-bg) transparent;
}

.scroll::-webkit-scrollbar {
    height: 6px;
}

.scroll::-webkit-scrollbar-thumb {
    background: var(--glass-bg);
    border-radius: 3px;
}

.scroll a {
    flex-shrink: 0;
    padding: 12px 24px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.scroll a:hover,
.scroll a.active {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-blue));
    border-color: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.4);
}

/* Divider */
.hr-advanced {
    height: 4px;
    background: linear-gradient(to right, 
        transparent, 
        rgba(245, 158, 11, 0.5),
        rgba(139, 92, 246, 0.5),
        rgba(59, 130, 246, 0.5),
        rgba(139, 92, 246, 0.5),
        rgba(245, 158, 11, 0.5),
        transparent);
    border: none;
    margin: 30px 0;
    border-radius: 2px;
}

/* Products Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 120px;
}

/* Product Card */
.grid-item {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.grid-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 48px rgba(139, 92, 246, 0.4);
    border-color: rgba(139, 92, 246, 0.3);
}

/* Product Image */
.product-image {
    width: 100%;
    height: 160px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.6s ease;
}

.grid-item:hover .product-image {
    transform: scale(1.1);
}

.lazy-image:not(.loaded) {
    background: linear-gradient(90deg, #1e293b 0%, #334155 50%, #1e293b 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.lazy-image.loaded {
    animation: fadeIn 0.5s ease-out;
}

/* Product Details */
.product-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    padding: 12px 12px 8px;
    text-align: center;
    cursor: pointer;
}

.star-rating {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 0 12px 8px;
}

.star {
    font-size: 16px;
    color: var(--accent-gold);
    text-shadow: 0 0 4px rgba(251, 191, 36, 0.5);
}

.star.empty {
    color: var(--text-secondary);
}

.pricing {
    padding: 0 12px 12px;
    text-align: center;
    cursor: pointer;
}

.discount-price {
    font-size: 12px;
    color: var(--accent-red);
    text-decoration: line-through;
    display: block;
}

.original-price {
    font-size: 18px;
    font-weight: 800;
    color: var(--accent-green);
}

/* Product Footer */
.product-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: rgba(15, 23, 42, 0.5);
    border-top: 1px solid var(--glass-border);
}

.remove-from-cart,
.add-to-cart {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    font-size: 24px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.remove-from-cart {
    background: linear-gradient(135deg, var(--accent-red), #dc2626);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.remove-from-cart:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
}

.add-to-cart {
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.add-to-cart:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.remove-from-cart:active,
.add-to-cart:active {
    transform: scale(0.95);
}

.remove-from-cart:disabled,
.add-to-cart:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.quantity-wrapper {
    min-width: 40px;
    text-align: center;
}

.quantity-display {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

.modal.show {
    display: flex;
}

.modal-dialog {
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
}

.close {
    background: none;
    border: none;
    font-size: 32px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1;
}

.close:hover {
    color: var(--accent-red);
    transform: rotate(90deg);
}

.modal-body {
    padding: 24px;
}

.modal-body img {
    width: 100%;
    border-radius: 16px;
    margin-bottom: 20px;
}

.info-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 20px;
    margin-bottom: 8px;
}

.modal-info {
    padding: 12px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* Addon Modal */
.addon-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2001;
}

.addon-modal.show {
    display: flex;
}

.addon {
    padding: 16px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-bottom: 12px;
    transition: all 0.3s ease;
}

.addon:hover {
    background: rgba(15, 23, 42, 0.7);
    border-color: var(--accent-purple);
}

.addon label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.addon input[type="checkbox"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: var(--accent-purple);
}

.add-to-cart-with-addons,
.add-to-cart-from-modal {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 20px;
    transition: all 0.3s ease;
}

.add-to-cart-with-addons:hover,
.add-to-cart-from-modal:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.6);
}

.close-btnz {
    float: right;
    font-size: 32px;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: 1;
}

.close-btnz:hover {
    color: var(--accent-red);
    transform: rotate(90deg);
}

/* Toast */
.toast {
    position: fixed;
    top: 90px;
    right: 24px;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: white;
    border-radius: 16px;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(16, 185, 129, 0.4);
    z-index: 3000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

/* Empty State */
.no-products {
    text-align: center;
    padding: 80px 20px;
    grid-column: 1 / -1;
}

.no-products i {
    font-size: 64px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .product-container {
        padding: 16px;
    }

    .grid-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 100px;
    }

    .product-image {
        height: 140px;
    }

    .product-name {
        font-size: 14px;
    }

    .remove-from-cart,
    .add-to-cart {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .modal-dialog {
        width: 95%;
    }

    .modal-header,
    .modal-body {
        padding: 16px;
    }

    .toast {
        top: 70px;
        right: 16px;
        left: 16px;
        text-align: center;
    }
}