/* 
 * Home Products CSS
 * Styling cho product cards trên trang chủ
 */

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 3rem 0;
    background: #f8f9fa;
    color: #333;
    margin-bottom: 3rem;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    opacity: 0;
    transform: translateY(-20px);
    animation: heroFadeInDown 0.8s ease forwards;
}

.hero-section h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.hero-section p {
    font-size: 1.1rem;
    color: #666;
    margin: 0;
}

/* Products Section */
.products-section {
    padding: 2rem 0;
}

.products-section h2 {
    text-align: center;
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: #333;
    opacity: 0;
    transform: translateY(20px);
    animation: titleFadeInUp 0.8s ease forwards;
    animation-delay: 0.3s;
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    padding: 0 1rem;
}

@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 576px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.8rem;
        padding: 0 0.5rem;
    }
}

/* Product Card */
.product-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    overflow: visible;
    transition: all 0.3s ease;
    position: relative;
    opacity: 0;
    transform: translateY(30px);
    animation: cardFadeInUp 0.6s ease forwards;
}

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

/* Product Image */
.product-image {
    position: relative;
    height: 140px;
    overflow: hidden;
    background: #f8f9fa;
}

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

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

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

.product-image .no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: #adb5bd;
    font-size: 2rem;
}

@media (max-width: 576px) {
    .product-image .no-image {
        font-size: 1.2rem;
    }
}

/* Discount Badge */
.discount-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #dc3545;
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 2;
}

@media (max-width: 576px) {
    .discount-badge {
        top: 5px;
        right: 5px;
        padding: 0.2rem 0.4rem;
        font-size: 0.6rem;
    }
}

.discount-badge:contains("MIỄN PHÍ") {
    background: #28a745;
}

/* Product Info */
.product-info {
    padding: 1rem;
}

@media (max-width: 576px) {
    .product-info {
        padding: 0.6rem;
    }
}

.product-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.8rem;
    line-height: 1.3;
    min-height: 2.6rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (max-width: 576px) {
    .product-name {
        font-size: 0.85rem;
        margin-bottom: 0.6rem;
        min-height: 2rem;
        font-weight: 500;
    }
}



/* Product Pricing */
.product-pricing {
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.price-current {
    font-size: 1.2rem;
    font-weight: 700;
    color: #dc3545;
    order: 2;
}

@media (max-width: 576px) {
    .price-current {
        font-size: 0.9rem;
        font-weight: 600;
    }
}

.price-current.free {
    color: #28a745;
    font-size: 1rem;
    background: #d4edda;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    border: 1px solid #c3e6cb;
    order: 1;
}

@media (max-width: 576px) {
    .price-current.free {
        font-size: 0.75rem;
        padding: 0.15rem 0.3rem;
        border-radius: 8px;
    }
}

.price-original {
    font-size: 1rem;
    color: #adb5bd;
    text-decoration: line-through;
    font-weight: 500;
    order: 1;
}

@media (max-width: 576px) {
    .price-original {
        font-size: 0.75rem;
    }
}

/* Product Meta */
.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    padding: 0.6rem;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.8rem;
}

@media (max-width: 576px) {
    .product-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
        padding: 0.4rem;
        margin-bottom: 0;
        font-size: 0.65rem;
    }
    
    /* Mobile tooltip adjustments */
    .quantity-info::before,
    .delivery-info::before {
        font-size: 0.55rem;
        padding: 0.25rem 0.4rem;
        max-width: 100px;
        margin-top: 3px;
    }
    
    .quantity-info::after,
    .delivery-info::after {
        border-width: 2px;
        margin-top: 1px;
    }
    
    .quantity-info i,
    .delivery-info i {
        font-size: 0.8rem;
    }
}

.quantity-info, .delivery-info {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: #666;
    cursor: help;
    transition: all 0.2s ease;
    position: relative;
}

.quantity-info:hover, .delivery-info:hover {
    color: #333;
    transform: translateY(-1px);
}

.quantity-info.unlimited {
    color: #28a745;
}

.quantity-info.unlimited:hover {
    color: #1e7e34;
}

.quantity-info i {
    color: #007bff;
    font-size: 0.9rem;
}

.delivery-info i {
    color: #ff6b35;
    font-size: 0.9rem;
}

.quantity-info.unlimited i {
    color: #28a745;
}

/* Tooltip styling */
.quantity-info::before,
.delivery-info::before {
    content: attr(title);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 0.3rem 0.5rem;
    border-radius: 3px;
    font-size: 0.6rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    margin-top: 5px;
    max-width: 120px;
    text-align: center;
    word-wrap: break-word;
    white-space: normal;
}

.quantity-info::after,
.delivery-info::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 3px solid transparent;
    border-bottom-color: #333;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    margin-top: 2px;
}

.quantity-info:hover::before,
.quantity-info:hover::after,
.delivery-info:hover::before,
.delivery-info:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Prevent tooltip overflow */
.product-meta {
    overflow: visible;
    position: relative;
}

.product-card {
    overflow: visible;
}

/* Product Card Cursor */
.product-card {
    cursor: pointer;
}

/* Product Modal */
.product-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0);
    backdrop-filter: blur(0px);
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    transition: all 0.3s ease;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.product-modal.show {
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
}

/* Ensure smooth scrolling on all devices */
.product-modal {
    scroll-behavior: smooth;
}

.modal-content {
    scroll-behavior: smooth;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    max-width: 700px;
    width: 100%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    opacity: 0;
    transform: scale(0.7) translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    -webkit-overflow-scrolling: touch;
    position: relative;
    margin-top: 20px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.product-modal.show .modal-content {
    opacity: 1;
    transform: scale(1) translateY(0);
}



.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    color: #333;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.4s ease;
    transition-delay: 0.1s;
}

.product-modal.show .modal-header {
    opacity: 1;
    transform: translateY(0);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-close {
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    color: #666;
    transition: color 0.3s ease;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 2rem;
}

.modal-product-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: stretch;
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.5s ease;
    transition-delay: 0.2s;
}

.product-modal.show .modal-product-info {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 768px) {
    .product-modal {
        align-items: flex-start;
        padding: 20px 10px;
    }
    
    .modal-content {
        max-width: none;
        width: calc(100% - 20px);
        max-height: calc(100vh - 40px);
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-product-info {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        align-items: start;
    }
    
    .modal-image-section {
        height: auto;
        width: 100%;
    }
    
    .modal-product-image {
        height: 280px;
        width: 100%;
        flex: none;
    }
}

/* Modal Image Section */
.modal-image-section {
    position: relative;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.modal-product-image {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
    position: relative;
    flex: 1;
}

.modal-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(45deg, #f8f9fa, #e9ecef);
    color: #adb5bd;
    font-size: 4rem;
}

.modal-discount-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 0.5rem 1rem;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 700;
    z-index: 2;
}

.modal-badge-free {
    background: #28a745;
    color: white;
}

.modal-badge-discount {
    background: #dc3545;
    color: white;
}

/* Modal Details Section */
.modal-details-section h3 {
    font-size: 1.4rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.8rem;
    line-height: 1.3;
}

.modal-details-section p {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

/* Modal Pricing */
.modal-pricing {
    margin-bottom: 1rem;
    padding: 0.8rem;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #007bff;
}

.modal-price-current {
    font-size: 1.4rem;
    font-weight: 700;
    color: #dc3545;
    display: block;
    margin-bottom: 0.3rem;
}

.modal-price-current.modal-price-free {
    color: #28a745;
    background: #d4edda;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    display: inline-block;
    border: 1px solid #c3e6cb;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.modal-price-original {
    font-size: 1rem;
    color: #adb5bd;
    text-decoration: line-through;
    font-weight: 500;
}

/* Modal Meta */
.modal-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
    padding: 0.8rem;
    background: #f8f9fa;
    border-radius: 6px;
}

.modal-quantity, .modal-delivery {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #666;
    font-weight: 500;
}

.modal-quantity i, .modal-delivery i {
    color: #007bff;
    font-size: 1.1rem;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: center;
}

.modal-btn {
    flex: 1;
    border: none;
    padding: 0.6rem 1rem;
    border-radius: 4px;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.modal-btn-primary {
    background: #007bff;
    color: white;
}

.modal-btn-primary:hover {
    background: #0056b3;
}

.modal-btn-secondary {
    background: #f8f9fa;
    color: #666;
    border: 2px solid #dee2e6;
}

.modal-btn-secondary:hover {
    background: #e9ecef;
    color: #495057;
    border-color: #adb5bd;
}

/* Mobile Modal Adjustments */
@media (max-width: 768px) {
    .modal-content {
        margin: 10px;
        max-height: 95vh;
    }
    
    .modal-header {
        padding: 1rem 1.5rem;
    }
    
    .modal-header h2 {
        font-size: 1.3rem;
    }
    
    .modal-body {
        padding: 1.5rem;
    }
    
    .modal-details-section h3 {
        font-size: 1.5rem;
    }
    
    .modal-price-current {
        font-size: 1.5rem;
    }
    
    .modal-meta {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-btn {
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 576px) {
    .product-modal {
        padding: 10px;
        align-items: flex-start;
    }
    
    .modal-content {
        max-height: calc(100vh - 20px);
        border-radius: 3px;
        width: calc(100% - 20px);
        max-width: none;
        min-height: auto;
    }
    
    .modal-header {
        padding: 0.8rem 1rem;
    }
    
    .modal-header h2 {
        font-size: 1rem;
    }
    
    .modal-close {
        font-size: 1.2rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-product-image {
        height: 150px;
    }
    
    .modal-details-section h3 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .modal-details-section p {
        font-size: 0.8rem;
        margin-bottom: 1rem;
        line-height: 1.4;
    }
    
    .modal-pricing {
        padding: 0.8rem;
        margin-bottom: 1rem;
    }
    
    .modal-price-current {
        font-size: 1.1rem;
        margin-bottom: 0.3rem;
    }
    
    .modal-price-current.modal-price-free {
        font-size: 0.9rem;
        padding: 0.3rem 0.6rem;
    }
    
    .modal-price-original {
        font-size: 0.9rem;
    }
    
    .modal-meta {
        padding: 0.8rem;
        margin-bottom: 1.5rem;
    }
    
    .modal-quantity, .modal-delivery {
        font-size: 0.75rem;
    }
    
    .modal-quantity i, .modal-delivery i {
        font-size: 0.9rem;
    }
    
    .modal-actions {
        gap: 0.8rem;
    }
    
    .modal-btn {
        padding: 0.7rem 1rem;
        font-size: 0.8rem;
        gap: 0.4rem;
    }
    
    .modal-discount-badge {
        top: 8px;
        right: 8px;
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
    }
}

/* No Products */
.no-products {
    text-align: center;
    padding: 4rem 2rem;
    opacity: 0;
    transform: translateY(20px);
    animation: titleFadeInUp 0.8s ease forwards;
    animation-delay: 0.5s;
}

.no-products-content {
    max-width: 400px;
    margin: 0 auto;
}

.no-products-content i {
    font-size: 4rem;
    color: #adb5bd;
    margin-bottom: 1.5rem;
}

.no-products-content h3 {
    font-size: 1.5rem;
    color: #666;
    margin-bottom: 1rem;
}

.no-products-content p {
    color: #999;
    font-size: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .hero-section {
        padding: 2rem 1rem;
        margin-bottom: 2rem;
    }
    
    .hero-section h1 {
        font-size: 2rem;
    }
    
    .hero-section p {
        font-size: 1rem;
    }
    
    .product-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .product-actions {
        flex-direction: column;
    }
}

@media (max-width: 576px) {
    .products-section {
        padding: 1rem 0;
    }
    
    .products-section h2 {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }
    
    .hero-section {
        padding: 2rem 1rem;
        margin-bottom: 2rem;
    }
    
    .hero-section h1 {
        font-size: 1.8rem;
    }
    
    .hero-section p {
        font-size: 0.9rem;
    }
}

/* Animation for product cards */
@keyframes cardFadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Hero animation */
@keyframes heroFadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Title animation */
@keyframes titleFadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered animation delays for sequential appearance */
.product-card:nth-child(1) { animation-delay: 0.5s; }
.product-card:nth-child(2) { animation-delay: 0.6s; }
.product-card:nth-child(3) { animation-delay: 0.7s; }
.product-card:nth-child(4) { animation-delay: 0.8s; }
.product-card:nth-child(5) { animation-delay: 0.9s; }
.product-card:nth-child(6) { animation-delay: 1.0s; }
.product-card:nth-child(7) { animation-delay: 1.1s; }
.product-card:nth-child(8) { animation-delay: 1.2s; }
.product-card:nth-child(9) { animation-delay: 1.3s; }
.product-card:nth-child(10) { animation-delay: 1.4s; }
.product-card:nth-child(11) { animation-delay: 1.5s; }
.product-card:nth-child(12) { animation-delay: 1.6s; }

/* Responsive fix cho modal ảnh sản phẩm trên mobile */
@media (max-width: 576px) {
  .modal-product-image {
    width: 100%;
    max-width: 320px;
    min-height: 160px;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
    border-radius: 8px;
  }
  .modal-product-image img,
  .modal-no-image {
    width: 100%;
    max-width: 320px;
    height: auto;
    min-height: 120px;
    object-fit: contain;
    display: block;
  }
  .modal-no-image {
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #adb5bd;
    background: linear-gradient(45deg, #f8f9fa, #e9ecef);
    border-radius: 8px;
    min-height: 120px;
    width: 100%;
  }
}
