/* Container Styles */

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Search Results */
.search-results {
    margin-bottom: 2rem;
}

.search-results h2 {
    color: #23284a;
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

/* Category Header */
.category-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e0e0e0;
}

.category-header h2 {
    color: #ffffff;
    font-size: 1.8rem;
    margin: 0;
}

/* Products Grid */
.products-grid { 
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.2rem;
}

/* Featured Products Grid - Style riêng cho sản phẩm nổi bật */
.featured-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
    padding: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* Featured Product Card - Style đặc biệt */
.featured-products-grid .product-card {
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    border: 3px solid #ffd700;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(255,215,0,0.3);
    transform: scale(1.02);
    position: relative;
    overflow: hidden;
}

.featured-products-grid .product-card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #ffd700, #ffed4e, #ffd700, #ffed4e);
    border-radius: 20px;
    z-index: -1;
    animation: borderGlow 3s ease-in-out infinite;
}

@keyframes borderGlow {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.featured-products-grid .product-card::after {
    content: '⭐ NỔI BẬT';
    position: absolute;
    top: 5px;
    right: -30px;
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 4px 25px;
    font-size: 0.65rem;
    font-weight: bold;
    transform: rotate(45deg);
    box-shadow: 0 2px 10px rgba(255,107,107,0.4);
    z-index: 2;
}

.featured-products-grid .product-card:hover {
    transform: scale(1.05) translateY(-8px);
    box-shadow: 0 15px 40px rgba(255,215,0,0.4);
}

.featured-products-grid .product-image,
.featured-products-grid .no-image {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    filter: brightness(1.1) contrast(1.1);
}

.featured-products-grid .product-info {
    padding: 1rem;
    background: linear-gradient(to bottom, rgba(255,255,255,0.95), rgba(248,249,250,0.95));
}

.featured-products-grid .product-info h3 {
    color: #2c3e50;
    font-size: 0.80rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
    margin-bottom: 0.5rem;
}

.featured-products-grid .category {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    border: none;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.featured-products-grid .price {
    font-size: 1.2rem;
    font-weight: 800;
}

.featured-products-grid .sale-price,
.featured-products-grid .current-price {
    color: #e74c3c;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.featured-products-grid .original-price {
    color: #95a5a6;
}

.featured-products-grid .metrics {
    background: transparent !important;
    color: #2ecc71 !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 5px !important;
    box-shadow: none !important;
}

.featured-products-grid .metrics span {
    color: #2ecc71 !important;
    font-weight: 700;
}

/* Product Card */
.product-card {
    background: white;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    transition: all 0.3s;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    border: 4px solid #6eea00;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.product-image, .no-image {
    width: 100%;
    height: 120px;
    object-fit: fill;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
}

.product-info {
    flex: 1;
    padding: 0.7rem 0.7rem 2.2rem 0.7rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: calc(100% - 120px);
}

.product-info h3 {
    font-size: 0.98rem;
    margin-bottom: 0.3rem;
    font-weight: bold;
    color: #222;
    min-height: 2.2em;
    max-height: 2.2em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.category {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 1.2em;
}

.price {
    margin: 0.3rem 0 0.2rem 0;
    font-size: 1rem;
    min-height: 1.5em;
    
    align-items: center;
}

.original-price {
    text-decoration: line-through;
    color: #bbb;
    font-size: 0.9em;
    margin-right: 0.3em;
}

.sale-price, .current-price {
    color: #222;
    font-weight: bold;
    font-size: 1.05em;
}

.quantity {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 1.2em;
}

.product-actions {
    position: absolute;
    right: 0.7rem;
    bottom: 0.7rem;
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
}

.product-actions .btn {
    background: #6eea00;
    color: #fff;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    min-width: unset;
    min-height: unset;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(110,234,0,0.15);
    transition: background 0.2s, transform 0.2s;
}

.product-actions .btn:hover {
    background: #4caf50;
    transform: scale(1.08);
}

.product-actions .btn-secondary {
    background: #fff;
    color: #6eea00;
    border: 2px solid #6eea00;
}

.product-actions .btn-secondary:hover {
    background: #eaffd6;
    color: #4caf50;
    border-color: #4caf50;
}

.no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.no-products i {
    font-size: 3rem;
    color: #666;
    margin-bottom: 1rem;
}

/* Desktop alignment for product card fields */
@media (min-width: 769px) {
    .products-grid {
        align-items: stretch;
    }
    
    .product-card {
        display: flex;
        flex-direction: column;
        height: 100%;
        min-height: 400px;
    }
    
    .product-image {
        flex: 0 0 auto;
    }
    
    .no-image {
        flex: 0 0 auto;
    }
    
    .product-info {
        display: flex;
        flex-direction: column;
        flex: 1;
        padding: 1rem;
        justify-content: space-between;
        min-height: 0;
    }
    
    .product-info h3 {
        flex: 0 0 auto;
        margin-bottom: 0.5rem;
        min-height: 3em;
        display: flex;
        align-items: flex-start;
    }
    
    .category {
        flex: 0 0 auto;
        margin-bottom: 0.5rem;
        height: 2.5em;
        min-height: 2.5em;
        max-height: 2.5em;
        display: flex;
        align-items: center;
        background: #f8f9fa;
        border: 1px solid #e9ecef;
        border-radius: 12px;
        padding: 8px 12px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        gap: 6px;
        font-size: 0.6rem;
    }
    
    .price {
        flex: 0 0 auto;
        margin: 0.3rem 0;
        min-height: 2em;
        
        align-items: center;
        font-weight: bold;
    }
    
    .quantity {
        flex: 0 0 auto;
        margin: 0.3rem 0;
        min-height: 1.5em;
        display: flex;
        align-items: center;
    }
    
    .metrics-container {
        flex: 0 0 auto;
        margin-top: auto;
        padding-top: 0.5rem;
    }
    
    .metrics {
        min-height: 2em;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Media Queries */
@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 1rem;
    }
    
    .featured-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 1rem;
        padding: 1rem;
    }
    
    .featured-products-grid .product-card {
        min-height: 280px;
    }
    
    .featured-products-grid .product-card::after {
        font-size: 0.6rem;
        padding: 3px 25px;
        right: -20px;
    }
    
    .featured-products-grid .product-image,
    .featured-products-grid .no-image {
        height: 140px;
    }
    
    .featured-products-grid .product-info {
        height: calc(100% - 140px);
        padding: 0.8rem;
    }
    
    .product-card {
        min-height: 200px;
    }
    
    .product-image, .no-image {
        height: 100px;
    }
    
    .product-info {
        flex: 1;
        padding: 0.6rem 0.6rem 2rem 0.6rem;
        height: calc(100% - 100px);
        justify-content: space-between;
    }
    
    .product-info h3 {
        font-size: 0.82rem;
        min-height: 2.2em;
        max-height: 2.2em;
        line-height: 1.3;
        -webkit-line-clamp: 2;
    }
    
    .category {
         min-height: 1.1em;
         font-size: 0.75rem;
     }
    
    .price {
        min-height: 1.4em;
        font-size: 0.9rem;
        flex-wrap: nowrap;
    }
    
    .quantity {
        margin-top: auto;
        min-height: 1.1em;
    }
    
    .sale-price, .current-price {
        font-size: 1rem;
    }
}

@media (max-width: 800px) {
    .container {
        width: 100%;
        max-width: 100vw;
        padding: 0 0.5rem;
        margin: 0 auto;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.8rem;
    }
    
    .featured-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 0.8rem;
        padding: 0.8rem;
    }
    
    .featured-products-grid .product-card {
        min-height: 260px;
    }
    
    .featured-products-grid .product-image,
    .featured-products-grid .no-image {
        height: 130px;
    }
    
    .featured-products-grid .product-info {
        height: calc(100% - 130px);
        padding: 0.7rem;
    }
    
    .product-card {
        min-height: 210px;
    }
    
    .product-image, .no-image {
        height: 110px;
    }
    
    .product-info {
        padding: 0.5rem 0.5rem 0.5rem 0.5rem;
        flex: 1;
        height: calc(100% - 110px);
        justify-content: space-between;
    }
    
    .product-info h3 {
        font-size: 0.8rem;
        min-height: 2.1em;
        max-height: 2.1em;
        line-height: 1.25;
        -webkit-line-clamp: 2;
    }
    
    .category {
         min-height: 1.05em;
         font-size: 0.7rem;
     }
    
    .price {
        min-height: 1.3em;
        font-size: 0.85rem;
        flex-wrap: nowrap;
    }
    
    .quantity {
        margin-top: auto;
        min-height: 1.05em;
    }
    
    .product-actions .btn {
        width: 30px;
        height: 30px;
        font-size: 0.95rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 0 0.75rem;
        max-width: 100%;
        overflow-x: hidden;
    }
    
    .products-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.7rem;
        padding: 0;
    }
    
    .featured-products-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.7rem;
        padding: 0.5rem;
        margin-bottom: 2rem;
    }
    
    .featured-products-grid .product-card {
        min-height: 240px;
    }
    
    .featured-products-grid .product-image,
    .featured-products-grid .no-image {
        height: 110px;
        max-height: 110px;
    }
    
    .featured-products-grid .product-info {
        height: calc(100% - 110px);
        padding: 0.5rem 0.5rem 0.5rem 0.5rem;
    }
    
    .featured-products-grid .product-card::after {
        font-size: 0.5rem;
        padding: 2px 20px;
        right: -15px;
    }
    
    .product-card {
        min-height: 200px;
        max-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }
    
    .product-image, .no-image {
        height: 100px;
        max-height: 100px;
        width: 100%;
        object-fit: cover;
    }
    
    .product-info {
        padding: 0.4rem 0.4rem 0.4rem 0.4rem;
        flex: 1;
        height: calc(100% - 100px);
        justify-content: space-between;
    }
    
    .product-info h3 {
        font-size: 0.75rem;
        min-height: 2em;
        max-height: 2em;
        line-height: 1.2;
        -webkit-line-clamp: 2;
        margin-bottom: 0.3rem;
        padding-bottom: 30px;
    }
    
    .category {
         min-height: 1em;
         font-size: 0.5rem;
     }
    
    .price {
        min-height: 1.2em;
        font-size: 0.8rem;
        flex-wrap: nowrap;
    }
    
    .quantity {
        margin-top: auto;
        min-height: 1em;
        font-size: 0.8rem;
    }
    
    .product-actions .btn {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
}

@media (max-width: 400px) {
    .load-more-btn {
        padding: 8px 15px;
        font-size: 0.85rem;
        min-width: 160px;
    }
    
    .load-more-container {
        margin: 1rem 0;
    }
}

/* Load More Button */
.load-more-container {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
    width: 100%;
    padding: 0 10px;
}

.load-more-btn {
    background: #6eea00;
    color: #fff;
    border: none;
    padding: 10px 25px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 3px 10px rgba(110, 234, 0, 0.2);
    transition: all 0.3s ease;
    text-align: center;
    min-width: 200px;
    justify-content: center;
}

.load-more-btn:hover {
    background: #4caf50;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

.load-more-btn i {
    font-size: 1.2rem;
}

.load-more-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.load-more-btn.finished {
    background: #ccc;
    pointer-events: none;
}

@media (max-width: 576px) {
    .load-more-btn {
        padding: 8px 20px;
        font-size: 0.9rem;
        min-width: 180px;
    }
    
    .load-more-container {
        margin: 1.5rem 0;
    }
}