/**
 * Product Card Responsive & Uniform Image Sizes
 * Makes all product cards the same size on mobile with uniform images
 */

/* ========================================
   PRODUCT CARD BASE STYLES
   ======================================== */

.product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: all 0.3s ease;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #f0f0f0;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15) !important;
}

/* ========================================
   PRODUCT IMAGE - UNIFORM SIZING
   ======================================== */

.product-thumb {
    position: relative;
    width: 100%;
    padding-top: 100%; /* 1:1 Aspect Ratio (Square) */
    overflow: hidden;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.product-thumb a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* FIXED: Removed position:absolute to allow flexbox centering */
.product-thumb img.product-image {
    /* position: absolute; - REMOVED: Breaks flexbox centering */
    /* top: 0; - REMOVED */
    /* left: 0; - REMOVED */
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain; /* Keep product fully visible without cropping */
    object-position: center;
    margin: 0 auto !important;
    display: block !important;
    transition: transform 0.3s ease;
    padding: 0; /* Padding is handled by .product-thumb container */
    background: transparent;
}

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

/* Alternative: Use 'cover' if you want images to fill the entire space */
.product-thumb img.product-image.cover-mode {
    object-fit: cover; /* Fills space but may crop image */
    padding: 0;
}

/* ========================================
   BADGES & OVERLAYS
   ======================================== */

/* Discount Badge */
.on-sale {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(135deg, #ff0000 0%, #cc0000 100%);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(255, 0, 0, 0.3);
    animation: pulse 2s infinite;
}

/* Cart Icon - Clean Black Style */
.cart-action-buttons {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
    display: flex !important;
    gap: 8px;
    flex-direction: column;
    opacity: 1 !important;
    visibility: visible !important;
}

.cart-icon-clean {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 44px !important;
    height: 44px !important;
    background: rgba(255, 255, 255, 0.95) !important;
    border: none !important;
    border-radius: 50% !important;
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    position: relative;
    z-index: 9999;
    opacity: 1 !important;
    visibility: visible !important;
}

.cart-icon-clean i {
    font-size: 20px !important;
    color: #000 !important;
    transition: all 0.3s ease;
    display: block !important;
}

.cart-icon-clean:hover {
    background: #000 !important;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
}

.cart-icon-clean:hover i {
    color: #fff !important;
}

/* Success State */
.cart-icon-clean.added {
    background: #28a745 !important;
}

.cart-icon-clean.added i {
    color: white !important;
    animation: bounce 0.5s ease;
}

/* Out of Stock */
.cart-icon-clean.cart-out-of-stock {
    cursor: not-allowed;
    opacity: 0.4 !important;
    background: rgba(200, 200, 200, 0.8) !important;
}

/* ========================================
   PRODUCT CONTENT
   ======================================== */

.product-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0.35rem !important;
    padding-top: 0.35rem;  /* No !important here - let media query override */
    padding-bottom: 0 !important;
    background: white;
    margin-top: 0 !important; /* Remove any top margin */
}

.product-title {
    min-height: 44px;
    margin-bottom: 10px;
    margin-top: 0 !important; /* Remove any top margin */
    font-size: 14px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.3s ease;
    font-weight: 500;
}

.product-title a:hover {
    color: #7caa53;
}

/* ========================================
   PRICE SECTION
   ======================================== */

.product-price {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.price-current {
    font-size: 18px;
    font-weight: bold;
    color: #7caa53;
    margin: 0 !important;
    padding: 0 !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

.price-old {
    font-size: 14px;
    color: #999;
    text-decoration: line-through;
    margin: 0 !important;
    padding: 0 !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* ========================================
   RATING SECTION
   ======================================== */

.product-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: auto; /* Push to bottom */
}

.product-rating .stars i {
    font-size: 14px;
    color: #ffc107;
}

.product-rating .stars i.text-muted {
    color: #ddd;
}

.rating-count {
    font-size: 12px;
    color: #999;
}

/* ========================================
   GRID LAYOUT - RESPONSIVE
   ======================================== */

/* Default: 6 columns on large screens */
.product-item {
    margin-bottom: 20px;
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

/* Tablets & Medium Screens */
@media (max-width: 992px) {
    .product-thumb {
        padding-top: 100%; /* Keep square */
    }

    .product-title {
        font-size: 13px;
        min-height: 40px;
    }

    .price-current {
        font-size: 16px;
    }
}

/* Small Tablets & Large Phones (577px - 768px) */
@media (min-width: 577px) and (max-width: 767px) {
    .product-thumb {
        padding-top: 100%; /* Keep square */
    }

    .product-thumb img.product-image {
        padding: 8px;
    }

    .cart-icon-clean {
        width: 40px;
        height: 40px;
    }

    .cart-icon-clean i {
        font-size: 18px;
    }

    /* Make cart icons visible on tablets */
    .product-card .cart-action-buttons {
        opacity: 1 !important;
        visibility: visible !important;
    }

    .on-sale {
        font-size: 11px;
        padding: 4px 8px;
    }

    /* MOBILE TABLET NEEDS MORE SPACE */
    .product-content {
        padding: 0.35rem !important;
        padding-top: 0.35rem !important;  /* Override desktop 5px for tablet */
        padding-bottom: 0 !important;
    }

    .product-title {
        font-size: 13px;
        min-height: 38px;
        margin-bottom: 8px;
    }

    .price-current {
        font-size: 15px;
    }

    .price-old {
        font-size: 13px;
    }
}

/* Mobile Phones (col-6 = 2 columns) - 400px to 576px */
@media (max-width: 576px) {
    .product-item {
        margin-bottom: 15px;
    }

    .product-card {
        border-radius: 6px;
    }

    .product-thumb {
        padding-top: 100%; /* Perfect square */
        border-radius: 6px 6px 0 0;
    }

    .product-thumb img.product-image {
        padding: 10px; /* More padding on mobile */
    }

    /* Cart icon - Mobile Optimized for Full Visibility */
    .cart-action-buttons {
        top: 6px;
        right: 6px;
        opacity: 1 !important;
        visibility: visible !important;
        gap: 5px;
    }

    .cart-icon-clean {
        width: 34px !important;
        height: 34px !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
    }

    .cart-icon-clean i {
        font-size: 15px !important;
    }

    .on-sale {
        font-size: 10px;
        padding: 3px 6px;
        top: 6px;
        left: 6px;
    }

    /* Make cart icons always visible on mobile */
    .product-card .cart-icon-clean {
        opacity: 1 !important;
        visibility: visible !important;
        display: inline-flex !important;
    }

    /* Content adjustments - MOBILE NEEDS MORE SPACE */
    .product-content {
        padding: 0.35rem !important;
        padding-top: 0.35rem !important;  /* Override desktop 5px for mobile */
        padding-bottom: 0 !important;
        margin-top: 0 !important;
    }

    .product-title {
        font-size: 12px;
        min-height: 36px;
        margin-bottom: 8px;
        margin-top: 0 !important;
        line-height: 1.3;
    }

    .product-price {
        margin-bottom: 8px;
        margin-top: 0 !important;
        gap: 6px;
    }

    .price-current {
        font-size: 14px;
    }

    .price-old {
        font-size: 12px;
    }

    .product-rating .stars i {
        font-size: 12px;
    }

    .rating-count {
        font-size: 11px;
    }
}

/* Large Mobile Phones (401px - 576px) - Specific fix for gap issue */
@media (min-width: 401px) and (max-width: 576px) {
    .product-content {
        padding: 0.35rem !important;
        padding-top: 0.35rem;  /* Removed !important for desktop override */
        padding-bottom: 0 !important;
        margin-top: 0 !important;
    }

    .product-title {
        margin-top: 0 !important;
        margin-bottom: 8px;
        padding-top: 0 !important;
    }

    .product-thumb {
        margin-bottom: 0 !important;
    }
}

/* Extra Small Phones */
@media (max-width: 400px) {
    .cart-action-buttons {
        top: 4px !important;
        right: 4px !important;
        gap: 4px !important;
    }

    .cart-icon-clean {
        width: 30px !important;
        height: 30px !important;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2) !important;
    }

    .cart-icon-clean i {
        font-size: 13px !important;
    }

    .product-title {
        font-size: 11px;
        min-height: 34px;
    }

    .price-current {
        font-size: 13px;
    }

    .price-old {
        font-size: 11px;
    }

    .on-sale {
        font-size: 9px;
        padding: 2px 5px;
        top: 4px;
        left: 4px;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
}

/* Loading Animation */
.cart-icon-clean.loading i {
    animation: rotate 0.8s linear infinite;
}

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

/* ========================================
   IMAGE LOADING STATE
   ======================================== */

.product-thumb img[src=""],
.product-thumb img:not([src]) {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========================================
   UTILITIES
   ======================================== */

/* Force equal heights in grid */
.product-item {
    display: flex;
}

.product-item > div {
    width: 100%;
}

/* ========================================
   DESKTOP: 5PX GAP OVERRIDE - MUST BE LAST
   ======================================== */
@media (min-width: 768px) {
    /* High specificity to override inline styles */
    .product-card .product-content[style],
    .product-item .product-card .product-content[style],
    .product-card .product-content,
    .product-item .product-card .product-content,
    div.product-content {
        padding-top: 5px !important;
    }

    .product-card .product-thumb,
    .product-item .product-card .product-thumb {
        padding-bottom: 5px !important;
        margin-bottom: 0 !important;
    }
}
