@import url("https://fonts.googleapis.com/css2?family=Segoe+UI:wght@400;600;700&display=swap");
@import url("colors.css");

/* Base Product Card Styles */
.product-card {
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 32px var(--card-shadow);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    height: 100%;
    border: 1px solid var(--card-border);
    will-change: transform;
    font-family: "Segoe UI", "Inter", Arial, sans-serif;

    /* alignment fix */
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 60px var(--card-shadow-hover);
}

/* Image Section */
.product-image-wrapper {
    position: relative;
    overflow: hidden;
    background: var(--bg-light);
}

.product-image {
    aspect-ratio: 1 / 1; /* enforce square shape */
    width: 100%;
    max-height: 450px;

    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    overflow: hidden;
    position: relative;
}

.product-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.4s ease;
    will-change: transform;
}

/* Placeholder image styling */
.placeholder-img {
    background: var(--bg-light);
    opacity: 0.8;
}

/* Actual image styling */
.actual-img {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.actual-img[style*="display: block"] {
    opacity: 1;
}

.product-card:hover .product-img {
    transform: scale(1.1);
}

/* Overlay and Actions */
.product-overlay {
    position: absolute;
    inset: 0;
    background: rgba(65, 95, 66, 0.85);
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.product-card:hover .product-overlay {
    opacity: 1;
}

.product-actions {
    display: flex;
    gap: 12px;
}

.action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    font-size: 14px;
    will-change: transform;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Cart Form */
.cart-form {
    margin: 0;
    display: inline;
}

/* Badges */
.discount-badge {
    position: absolute;
    top: 15px;
    left: 15px;
    background: var(--accent-color);
    color: var(--text-light);
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Content Section */
.product-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
}

.product-category {
    margin-bottom: 8px;
}

.product-category span {
    background: var(--bg-light);
    color: var(--primary-color);
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-right: 5px;
    margin-bottom: 5px;
    display: inline-block;
    border: 1px solid var(--border-light);
}

.product-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary) !important;
    font-family: "Segoe UI", "Inter", Arial, sans-serif;
    margin-bottom: 10px;

    /* alignment fix */
    min-height: 40px;
    flex-grow: 0;
}

.product-title a {
    color: var(--text-primary) !important;
    text-decoration: none;
    transition: color 0.3s ease;
}

.product-title a:hover {
    color: var(--primary-color) !important;
}

/* Rating */
.product-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
}

.stars {
    display: flex;
    gap: 1px;
}

.stars i {
    color: var(--rating-empty);
    font-size: 0.8rem;
}

.stars i.filled {
    color: var(--rating-color);
}

.rating-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Price */
.product-price {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto; /* pushes price down */
    margin-bottom: 15px;
}

.original-price {
    color: var(--text-secondary);
    text-decoration: line-through;
    font-size: 0.85rem;
}

.current-price {
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 700;
}

/* Add to Cart Button */
.add-to-cart-form {
    margin: 0;
}

.add-to-cart-btn {
    color: var(--text-light);
    border: none;
    padding: 7px 12px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    cursor: pointer;
    width: 100%;
    margin-top: auto;
    will-change: transform;
    box-shadow: 0 2px 8px var(--shadow-primary);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color) !important;
}

.add-to-cart-btn:hover {
    background: var(--primary-dark) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-primary);
}

.add-to-cart-btn .spinner {
    display: none;
    margin-right: 8px;
    font-size: 1rem;
    animation: spin 1s linear infinite;
}

.add-to-cart-btn.loading .spinner {
    display: inline-block;
}

.add-to-cart-btn.loading .btn-text {
    opacity: 0.6;
}

.add-to-cart-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* .product-image {
        height: 200px;
    } */

    .product-content {
        padding: 15px;
    }

    .product-title {
        font-size: 0.9rem;
    }

    .action-btn {
        width: 35px;
        height: 35px;
        font-size: 12px;
    }
}

@media (max-width: 576px) {
    /* .product-image {
        height: 180px;
    } */

    .product-content {
        padding: 12px;
    }

    .product-title {
        font-size: 0.85rem;
    }

    .add-to-cart-btn {
        padding: 10px 16px;
        font-size: 0.8rem;
    }
}

/* Focus states for accessibility */
.action-btn:focus,
.add-to-cart-btn:focus,
.product-title a:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Loading states */
.add-to-cart-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.add-to-cart-btn.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
