/* Tối ưu cho thiết bị di động */
@media (max-width: 768px) {
    /* Header */
    .header {
        position: sticky;
        top: 0;
        z-index: 1000;
    }
    
    .logo a {
        font-size: 1.2rem;
    }
    
    .user-menu, .cart-icon {
        margin-left: 12px;
    }
    
    /* Hero Banner */
    .hero-banner {
        height: auto;
        padding: 3rem 0;
    }
    
    .hero-content h1 {
        font-size: 2rem;
        line-height: 1.2;
    }
    
    .hero-content p {
        font-size: 1rem;
    }
    
    /* Categories */
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .category-card {
        margin-bottom: 1rem;
    }
    
    .category-image {
        height: 150px;
    }
    
    /* Products */
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    .product-card {
        margin-bottom: 1rem;
    }
    
    .product-image {
        height: 180px;
    }
    
    .product-title {
        font-size: 0.9rem;
        margin-bottom: 0.2rem;
    }
    
    .product-price {
        font-size: 0.9rem;
    }
    
    /* Modals */
    .cart-container, .product-container, .checkout-container, .auth-container {
        width: 95%;
        max-width: none;
        max-height: 90vh;
        margin: 0.5rem;
        border-radius: 10px;
    }
    
    .product-container .product-gallery {
        height: 200px;
    }
    
    /* Swipe gesture for product images */
    .product-gallery {
        position: relative;
        overflow: hidden;
        touch-action: pan-y;
    }
    
    .product-gallery::after {
        content: '';
        position: absolute;
        top: 0;
        right: 10px;
        bottom: 0;
        width: 40px;
        background: linear-gradient(90deg, transparent, rgba(255,255,255,0.7));
        z-index: 1;
        pointer-events: none;
    }
    
    .swipe-indicator {
        position: absolute;
        top: 50%;
        right: 20px;
        transform: translateY(-50%);
        color: var(--primary);
        font-size: 1.5rem;
        animation: swipeHint 1.5s infinite;
        z-index: 2;
    }
    
    @keyframes swipeHint {
        0%, 100% { transform: translateY(-50%) translateX(0); opacity: 0.7; }
        50% { transform: translateY(-50%) translateX(-10px); opacity: 1; }
    }
    
    /* Blog */
    .blog-hero {
        padding: 4rem 0;
    }
    
    .blog-hero-content h1 {
        font-size: 2rem;
    }
    
    .blog-grid {
        grid-template-columns: 1fr;
    }
    
    .blog-image {
        height: 200px;
    }
    
    .blog-card .blog-title {
        font-size: 1.1rem;
    }
    
    /* Footer */
    .footer-content {
        flex-direction: column;
        gap: 2rem;
    }
    
    .footer-logo, .footer-links, .footer-contact {
        width: 100%;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .footer-links-column {
        width: 100%;
    }
    
    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
    }
    
    /* Product Detail */
    .product-detail-section {
        padding: 1rem 0;
    }
    
    .product-detail-container {
        flex-direction: column;
    }
    
    .product-detail-gallery, .product-detail-info {
        width: 100%;
    }
    
    .product-detail-gallery {
        margin-bottom: 1.5rem;
    }
    
    .product-thumbnails {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .product-thumbnail {
        flex: 0 0 auto;
        width: 60px;
        height: 60px;
        scroll-snap-align: start;
    }
    
    /* Touch specific interactions */
    .touch-scroll {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
    }
    
    .touch-scroll > * {
        scroll-snap-align: start;
    }
    
    /* Bottom navigation for mobile */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background-color: var(--white);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 90;
    }
    
    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0.8rem 0;
        color: var(--text-medium);
        text-decoration: none;
        font-size: 0.7rem;
    }
    
    .mobile-nav-item i {
        font-size: 1.2rem;
        margin-bottom: 0.3rem;
    }
    
    .mobile-nav-item.active {
        color: var(--primary);
    }
    
    /* Fix for bottom padding due to fixed nav */
    body {
        padding-bottom: 60px;
    }
    
    /* Toast notifications */
    .toast {
        bottom: 70px;
        width: 90%;
        left: 5%;
        right: 5%;
    }
}

/* Tablet responsive adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .categories-grid, .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .blog-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .product-detail-gallery {
        width: 45%;
    }
    
    .product-detail-info {
        width: 55%;
    }
}

/* Mobile touch gestures */
.swipeable {
    position: relative;
    overflow: hidden;
    touch-action: pan-x;
}

/* Loading skeletons for mobile */
@keyframes shimmer {
    0% { background-position: -468px 0 }
    100% { background-position: 468px 0 }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 936px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--border-radius);
}

.product-card-skeleton {
    height: 300px;
}

.product-image-skeleton {
    height: 180px;
}

.product-title-skeleton {
    height: 20px;
    margin: 10px 0;
    width: 80%;
}

.product-price-skeleton {
    height: 20px;
    width: 40%;
}

/* Pull to refresh animation */
.pull-to-refresh {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-100%);
    transition: transform 0.3s;
}

.pull-to-refresh.visible {
    transform: translateY(0);
}

.pull-to-refresh .spinner {
    width: 24px;
    height: 24px;
    border: 2px solid transparent;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile styles */
@media screen and (max-width: 768px) {
    /* Header */
    .header-content {
        padding: 1rem;
    }

    .main-nav {
        display: none;
    }

    .mobile-menu-btn {
        display: block;
    }

    .mobile-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100vh;
        background: var(--white);
        z-index: 1000;
        padding: 2rem;
        transition: left 0.3s ease;
    }

    .mobile-menu.active {
        left: 0;
    }

    .mobile-menu ul {
        list-style: none;
        padding: 0;
        margin: 2rem 0;
    }

    .mobile-menu ul li {
        margin: 1rem 0;
    }

    .mobile-menu ul li a {
        font-size: 1.2rem;
        color: var(--text-color);
        text-decoration: none;
    }

    /* Products Grid */
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        padding: 1rem;
    }

    .product-card {
        margin: 0;
    }

    /* Categories */
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        padding: 1rem;
    }

    .category-card {
        flex-direction: column;
    }

    /* Cart Modal */
    .cart-modal {
        width: 100%;
        max-width: 100%;
        margin: 0;
        height: 100vh;
    }

    .cart-item {
        flex-direction: column;
        text-align: center;
    }

    .cart-item-image {
        margin-bottom: 1rem;
    }

    /* Checkout Modal */
    .checkout-modal {
        width: 100%;
        max-width: 100%;
        margin: 0;
        height: 100vh;
    }

    .form-row {
        flex-direction: column;
    }

    .form-group {
        width: 100%;
        margin-bottom: 1rem;
    }

    /* Benefits Section */
    .benefits-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 1rem;
    }

    /* Contact Section */
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 1rem;
    }

    /* Footer */
    .footer-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 1rem;
    }
}

@media screen and (max-width: 480px) {
    /* Header */
    .header-actions {
        gap: 0.5rem;
    }

    .search-box {
        display: none;
    }

    /* Products Grid */
    .products-grid {
        grid-template-columns: 1fr;
    }

    /* Categories */
    .categories-grid {
        grid-template-columns: 1fr;
    }

    /* Product Card */
    .product-card {
        margin: 0.5rem;
    }

    .product-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Cart Item */
    .cart-item-quantity {
        flex-direction: column;
        align-items: center;
    }

    /* Mobile Bottom Navigation */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--white);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }

    .mobile-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 0.5rem;
        color: var(--text-color);
        text-decoration: none;
        font-size: 0.8rem;
    }

    .mobile-nav-item i {
        font-size: 1.2rem;
        margin-bottom: 0.2rem;
    }

    .mobile-nav-item.active {
        color: var(--primary-color);
    }

    .badge {
        position: absolute;
        top: 0;
        right: 25%;
        background: var(--accent-color);
        color: var(--white);
        border-radius: 50%;
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
}

/* Tablet styles */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .benefits-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .contact-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Print styles */
@media print {
    .header,
    .mobile-bottom-nav,
    .footer,
    .cart-modal,
    .product-modal,
    .checkout-modal,
    .auth-modal {
        display: none !important;
    }

    .container {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    body {
        font-size: 12pt;
    }

    a {
        text-decoration: none;
        color: #000;
    }

    .product-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}