/**
 * Responsive: Mobile, Tablet, Desktop
 * Breakpoints: 1200, 992, 768, 576, 480, 375
 * Touch targets: min 44px for interactive elements.
 */

:root {
    --touch-target: 44px;
    --safe-top: env(safe-area-inset-top, 0);
    --safe-bottom: env(safe-area-inset-bottom, 0);
    --safe-left: env(safe-area-inset-left, 0);
    --safe-right: env(safe-area-inset-right, 0);
}

input, select, textarea, button {
    font-size: max(1rem, 16px);
}

/* ========== Cart page (cart.php) layout ========== */
.cart-item {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 1rem;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    position: relative;
}

.item-image-container {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg);
}

.item-image-container .item-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.item-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.35;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.item-category {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.item-price-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: baseline;
}

.item-price-group .current-price {
    font-weight: 700;
    color: var(--primary);
}

.item-price-group .item-subtotal {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.cart-item .remove-btn {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 2;
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    padding: 0.5rem;
}

.cart-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.cart-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.35rem;
}

.cart-count {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.85rem;
}

.checkout-btn,
.continue-shopping-btn {
    min-height: var(--touch-target);
    padding: 0.75rem 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

body:not(.admin-body) .main-content {
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    padding-bottom: var(--safe-bottom);
}

@media (max-width: 1200px) {
    .product-details-container { padding: 1.5rem; }
    .product-details-grid { gap: 2rem; }
    .categories-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}

@media (max-width: 992px) {
    .main-content { margin-top: 90px; }
    .product-details-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1.5rem;
    }
    .product-details-container { padding: 1rem; }
    .main-image-container { max-height: 400px; }
    .thumbnail-gallery {
        display: flex;
        gap: 0.5rem;
        overflow-x: auto;
        padding: 0.5rem 0;
        -webkit-overflow-scrolling: touch;
    }
    .thumbnail-gallery img { flex: 0 0 auto; width: 70px; height: 70px; object-fit: cover; border-radius: 8px; }
    .cart-items { grid-template-columns: repeat(2, 1fr); }
    .footer-content { flex-direction: column; align-items: center; text-align: center; }
    .section-title { font-size: 1.6rem; }
}

@media (max-width: 768px) {
    /* Shrink fixed top bar overlap; keep enough spacing for smaller screens */
    .main-content { margin-top: 64px; padding-top: 0.75rem; }
    .top-bar { padding: 0.45rem 0.9rem; }
    .logo { font-size: 1.35rem; }
    .section { padding: 0.75rem; }
    .section-title { font-size: 1.4rem; margin: 1.5rem 0 1rem; }
    .section-title::after { width: 40px; height: 3px; }
    .hero { margin-bottom: 1.25rem; }

    /* Use aspect-ratio for the banner so it scales proportionally on narrow screens */
    .banner-slider {
        height: auto;
        aspect-ratio: 16 / 9;
        max-height: 280px;
    }
    .banner-slider .swiper-wrapper,
    .banner-slider .swiper-slide {
        height: 100% !important;
    }

    .banner-slider .banner-content { padding: 1.25rem 1rem; }
    .banner-slider .banner-content h2 { font-size: 1.5rem; }
    .banner-slider .banner-content p { font-size: 1rem; }
    .categories-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
    .category-image { height: 160px; }
    .category-showcase-card .category-info h3 { font-size: 1rem; }
    .products-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; padding: 12px; }
    .product-card { width: 100%; max-width: 280px; }
    .offers-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .best-sellers .products-grid,
    .new-arrivals .products-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .store-features { padding: 1.5rem 1rem; margin: 1.5rem 0; }
    .features-grid { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
    .feature-card { padding: 1.25rem 1rem; }
    .feature-card i { width: 40px; height: 40px; font-size: 1.35rem; }
    .newsletter { padding: 2rem 1rem; }
    .newsletter-content h2 { font-size: 1.5rem; }
    .newsletter-form { flex-direction: column; }
    .newsletter-form button { width: 100%; }
    .search-bar { max-width: 100%; margin: 1rem; }
    .auth-content { width: 95%; max-width: 380px; padding: 1.5rem; }
    .cart-page { padding: 0.75rem; }
    .cart-header { flex-direction: column; align-items: stretch; }
    .cart-title { justify-content: center; }
    .continue-shopping-btn { width: 100%; justify-content: center; }
    .cart-page .cart-items { padding: 0.75rem; gap: 0.75rem; }
    .cart-item {
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem;
    }
    .cart-page .cart-item {
        display: grid;
        grid-template-columns: 1fr;
        margin: 0 0.75rem 0.75rem;
        border: 1px solid var(--border-color);
        border-radius: 10px;
    }
    .item-image-container {
        width: 100%;
        height: 180px;
        border-radius: 8px;
    }
    .cart-page .item-image-container {
        width: 72px;
        height: 72px;
    }
    .cart-summary { padding: 1.25rem; margin-top: 1rem; }
    .checkout-btn { width: 100%; }
    .product-details-grid { padding: 1rem; }
    .product-title { font-size: 1.35rem; }
    .product-actions { flex-wrap: wrap; }
    .product-actions .quantity-selector,
    .action-buttons { width: 100%; }
    .add-to-cart-btn, .login-to-buy-btn { width: 100%; min-height: var(--touch-target); }
    .favorites-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
    .favorite-card img { height: 200px; }
    /* Mobile styles for employee and chat windows */
    .online-employees-window,
    .chat-window {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 95%;
        max-width: 400px;
        max-height: 85vh;
        background: var(--background);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-lg);
        z-index: 1100;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .online-employees-window .window-header,
    .chat-window .chat-header {
        background: var(--primary);
        color: white;
        padding: 1rem;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .online-employees-window .window-header h2,
    .chat-window .chat-header h2 {
        margin: 0;
        font-size: 1.1rem;
        font-weight: 600;
    }

    .online-employees-window .close-btn,
    .chat-window .close-btn {
        cursor: pointer;
        font-size: 1.5rem;
        line-height: 1;
        padding: 0.25rem;
        border-radius: 50%;
        transition: background 0.2s ease;
    }

    .online-employees-window .close-btn:hover,
    .chat-window .close-btn:hover {
        background: rgba(255, 255, 255, 0.2);
    }

    .online-employees-window ul {
        list-style: none;
        padding: 0;
        margin: 0;
        max-height: calc(85vh - 60px);
        overflow-y: auto;
    }

    .online-employees-window ul.empty {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 2rem 1rem;
        color: var(--text-muted);
        font-style: italic;
        text-align: center;
    }

    .online-employees-window .error {
        padding: 2rem 1rem;
        color: var(--danger);
        text-align: center;
        font-size: 0.9rem;
    }

    .online-employees-window .loading {
        padding: 2rem 1rem;
        color: var(--text-muted);
        text-align: center;
        font-style: italic;
    }

    .online-employees-window li {
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-color);
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 0.75rem;
        transition: background 0.2s ease;
    }

    .online-employees-window li:hover {
        background: var(--background-light);
    }

    .online-employees-window li:last-child {
        border-bottom: none;
    }

    .online-employees-window .employee-avatar {
        width: 40px;
        height: 40px;
        background: var(--primary);
        color: white;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.2rem;
        font-weight: 600;
        flex-shrink: 0;
    }

    .online-employees-window .employee-avatar:not(div) {
        background: var(--primary-light);
        color: var(--text);
    }

    .online-employees-window .employee-name {
        font-weight: 500;
        color: var(--text);
        flex: 1;
    }

    .online-employees-window .status-indicator {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: var(--success);
        flex-shrink: 0;
    }

    .online-employees-window .status-indicator.online {
        background: var(--success);
    }

    .online-employees-window .status-indicator.away {
        background: var(--accent);
    }

    .online-employees-window .status-indicator.offline {
        background: var(--text-muted);
    }

    .chat-window .chat-body {
        flex: 1;
        padding: 1rem;
        overflow-y: auto;
        background: var(--bg);
        max-height: calc(85vh - 120px);
    }

    .chat-window .chat-form {
        padding: 0.75rem 1rem;
        background: var(--background);
        border-top: 1px solid var(--border-color);
        display: flex;
        gap: 0.5rem;
    }

    .chat-window .chat-form input {
        flex: 1;
        padding: 0.5rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
    }

    .chat-window .chat-form button {
        padding: 0.5rem 1rem;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: var(--radius-md);
        cursor: pointer;
        transition: background 0.2s ease;
    }

    .chat-window .chat-form button:hover {
        background: var(--primary-dark);
    }

    .toggle-employees-btn {
        position: fixed;
        bottom: 18px;
        right: 18px;
        padding: 0.75rem 0.9rem;
        font-size: 0.9rem;
        background: var(--primary);
        color: white;
        border: none;
        border-radius: 999px;
        box-shadow: 0 6px 18px rgba(0,0,0,0.18);
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        z-index: 1200;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .toggle-employees-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 22px rgba(0,0,0,0.25);
    }

    .theme-toggle-btn { top: 10px; left: 10px; padding: 8px 14px; font-size: 0.9rem; }
    .subsection-preview { padding: 1rem; margin: 1rem 0; }
    .preview-header { flex-wrap: wrap; gap: 0.5rem; }
    .preview-header h3 { font-size: 1rem; }
    .view-all { padding: 10px 14px; min-height: var(--touch-target); }
}

@media (max-width: 576px) {
    .main-content { margin-top: 80px; padding-top: 0.5rem; }
    .section { padding: 0.5rem; }
    .section-title { font-size: 1.25rem; margin: 1.25rem 0 0.75rem; }
    .banner-slider { height: 240px; }
    .banner-slider .banner-content h2 { font-size: 1.25rem; }
    .banner-slider .banner-content p { font-size: 0.9rem; }
    .categories-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .category-image { height: 120px; }
    .category-info { padding: 0.75rem 1rem; }
    .category-info h3 { font-size: 0.9rem; }
    .view-category { font-size: 0.8rem; }
    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 8px; }
    .product-card { margin: 4px; }
    .product-card img { height: 160px; }
    .product-content { padding: 10px; }
    .product-title { font-size: 0.9rem; height: 36px; }
    .add-to-cart, .favorite-btn { min-width: 36px; min-height: 36px; padding: 8px; }
    .offers-grid,
    .best-sellers .products-grid,
    .new-arrivals .products-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .features-grid { grid-template-columns: 1fr; gap: 1rem; }
    .newsletter { padding: 1.5rem 0.75rem; }
    .newsletter-content h2 { font-size: 1.35rem; }
    .cart-items { grid-template-columns: 1fr; gap: 0.5rem; padding: 0.5rem; }
    .cart-item { padding: 0.5rem; }
    .item-image-container { height: 140px; }
    .cart-page .item-image-container { height: 64px; width: 64px; }
    .item-title { font-size: 0.9rem; }
    .quantity-controls { padding: 0.25rem; }
    .quantity-btn { min-width: 36px; min-height: 36px; width: 36px; height: 36px; }
    .remove-btn { min-width: 36px; min-height: 36px; }
    .cart-summary { padding: 1rem; }
    .product-details-container { padding: 0.75rem; }
    .product-details-grid { padding: 0.75rem; gap: 1rem; }
    .main-image-container { height: 280px; }
    .product-title { font-size: 1.2rem; }
    .product-features { flex-direction: column; }
    .favorites-grid { grid-template-columns: 1fr; gap: 0.75rem; }
    .favorite-card img { height: 180px; }
    .favorite-content { padding: 0.75rem; }
    .random-products-container { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.5rem; }
    .random-product-card { flex: 0 0 90px; width: 90px; }
    .random-product-card img { height: 90px; }
    .random-product-card p { font-size: 0.75rem; }
    #sub-section-products .products-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    #sub-section-products .product-card { width: 100%; }
    #sub-section-products .product-card img { height: 140px; }
    .show-more-btn { width: 100%; min-height: var(--touch-target); }
}

@media (max-width: 480px) {
    .main-content { margin-top: 60px; }
    .top-bar { padding: 0.45rem 0.65rem; }
    .logo { font-size: 1.1rem; }
    .cart-counter { width: 20px; height: 20px; font-size: 0.7rem; }
    .user-menu-trigger span { display: none; }

    /* Make banner responsive and not too tall on small phones */
    .banner-slider {
        height: auto;
        aspect-ratio: 16 / 9;
        max-height: 220px;
    }
    .banner-slider .swiper-wrapper,
    .banner-slider .swiper-slide {
        height: 100% !important;
    }

    .banner-slider .banner-content { padding: 1rem; }
    .banner-slider .banner-content h2 { font-size: 1.1rem; }
    .banner-slider .banner-content p { font-size: 0.85rem; }
    .product-card img { height: 140px; }
    .discounted-price { font-size: 1rem; }
    .item-image-container { height: 120px; }
    .cart-page .item-image-container { width: 56px; height: 56px; }
    .item-price-group { flex-direction: column; align-items: flex-start; }
    .main-image-container { height: 240px; }
    .reviews-section .reviews-summary { flex-direction: column; }
    .add-review-section { width: 100%; }
}

@media (max-width: 375px) {
    .section-title { font-size: 1.1rem; }
    .categories-grid { gap: 0.5rem; }
    .category-image { height: 100px; }
    .product-card img { height: 120px; }
    .product-title { font-size: 0.85rem; height: 32px; }
    .cart-item .item-image-container { height: 100px; }
    .cart-page .item-image-container { width: 52px; height: 52px; }
    .item-title { font-size: 0.85rem; }
    .main-image-container { height: 200px; }
    .random-product-card { flex: 0 0 80px; width: 80px; }
    .random-product-card img { height: 80px; }
}

@media (max-width: 576px) {
    .auth-modal { align-items: flex-end; padding: 0; }
    .auth-content {
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        margin: 0;
    }
    #orderFormModal .auth-content,
    #addProductModal .auth-content { max-height: 85vh; overflow-y: auto; }
}

@media (hover: none) and (pointer: coarse) {
    .nav-link { min-height: var(--touch-target); display: inline-flex; align-items: center; }
    .product-actions .favorite-btn,
    .product-actions .add-to-cart { min-width: 44px; min-height: 44px; }
    .quantity-btn { min-width: 44px; min-height: 44px; }
    .close-btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
}

/* ========== Admin / Employee pages ========== */
body.admin-body {
    overflow-x: auto;
}
@media (max-width: 992px) {
    body.admin-body .main-content {
        margin-right: 0;
        margin-left: 0;
        padding: 1rem;
    }
    .admin-layout .table-container {
        min-width: 0;
        overflow-x: auto;
    }
    .admin-layout .data-table {
        min-width: 600px;
    }
}
@media (max-width: 768px) {
    body.admin-body .main-content {
        padding: 0.75rem;
    }
    .admin-layout .section {
        padding: 1rem;
    }
    .admin-layout .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .admin-layout .table-container {
        height: 400px;
    }
    .admin-layout .table-search input {
        width: 100%;
    }
}
@media (max-width: 576px) {
    body.admin-body .main-content {
        padding: 0.5rem;
    }
    .admin-layout .data-table {
        min-width: 500px;
        font-size: 0.9rem;
    }
    .admin-layout .data-table th,
    .admin-layout .data-table td {
        padding: 0.5rem;
    }
}

/* ========== Button Responsiveness ========== */
@media (max-width: 768px) {
    button[type="submit"] {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }

    .add-to-cart, .favorite-btn {
        padding: 6px;
        font-size: 0.9rem;
        min-width: 36px;
        min-height: 36px;
    }

    .favorite-btn {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 480px) {
    button[type="submit"] {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
    }

    .add-to-cart, .favorite-btn {
        padding: 5px;
        font-size: 0.85rem;
        min-width: 32px;
        min-height: 32px;
    }

    .favorite-btn {
        width: 32px;
        height: 32px;
    }
}

/* ========== Product Card Responsiveness ========== */
@media (max-width: 768px) {
    .product-card {
        max-width: 240px;
        margin: 0 auto;
    }

    .product-card img {
        height: 180px;
    }

    .product-content {
        padding: 0.75rem;
    }

    .product-title {
        font-size: 0.95rem;
        line-height: 1.3;
    }

    .price-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .product-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .product-actions button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .product-card {
        max-width: 200px;
    }

    .product-card img {
        height: 150px;
    }

    .product-content {
        padding: 0.5rem;
    }

    .product-title {
        font-size: 0.9rem;
    }

    .price-section .current-price {
        font-size: 1rem;
    }

    .price-section .original-price {
        font-size: 0.85rem;
    }
}

/* ========== Form Responsiveness ========== */
@media (max-width: 768px) {
    .auth-modal .modal-content {
        width: 90%;
        max-width: 400px;
        margin: 20px;
        padding: 1.5rem;
    }

    .auth-form input,
    .auth-form select,
    .auth-form textarea {
        padding: 0.75rem;
        font-size: 1rem;
    }

    .auth-form button[type="submit"] {
        padding: 0.875rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .auth-modal .modal-content {
        width: 95%;
        margin: 10px;
        padding: 1rem;
    }

    .auth-form input,
    .auth-form select,
    .auth-form textarea {
        padding: 0.625rem;
        font-size: 0.95rem;
    }

    .auth-form button[type="submit"] {
        padding: 0.75rem;
        font-size: 0.95rem;
    }
}

/* ========== Navigation Responsiveness ========== */
@media (max-width: 768px) {
    .top-bar {
        padding: 0.5rem 1rem;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--card-bg);
        flex-direction: column;
        padding: 1rem 0;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .nav-links.show {
        display: flex;
    }

    .nav-links a {
        padding: 0.75rem 1.5rem;
        border-bottom: 1px solid var(--border-color);
    }

    .nav-links a:last-child {
        border-bottom: none;
    }

    .mobile-menu {
        display: block;
        background: none;
        border: none;
        font-size: 1.25rem;
        color: var(--text);
        cursor: pointer;
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .top-bar {
        padding: 0.375rem 0.75rem;
    }

    .logo {
        font-size: 1.1rem;
    }

    .nav-links {
        padding: 0.75rem 0;
    }

    .nav-links a {
        padding: 0.625rem 1rem;
        font-size: 0.95rem;
    }
}

/* ========== Modal Responsiveness ========== */
@media (max-width: 768px) {
    .modal {
        padding: 20px;
    }

    .modal-content {
        width: 90%;
        max-width: 500px;
        margin: 20px auto;
        padding: 1.5rem;
    }

    .modal-header h2 {
        font-size: 1.25rem;
    }

    .modal-body {
        padding: 1rem 0;
    }
}

@media (max-width: 480px) {
    .modal {
        padding: 10px;
    }

    .modal-content {
        width: 95%;
        margin: 10px auto;
        padding: 1rem;
    }

    .modal-header h2 {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 0.75rem 0;
    }

    .modal-footer {
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-footer button {
        width: 100%;
    }
}

/* ========== Search Bar Responsiveness ========== */
@media (max-width: 768px) {
    .search-bar {
        margin: 1rem 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .search-bar input {
        padding: 0.75rem 2.5rem 0.75rem 1rem;
        font-size: 1rem;
    }

    .search-icon {
        right: 0.75rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .search-bar {
        margin: 0.75rem 0.25rem;
        max-width: calc(100% - 0.5rem);
    }

    .search-bar input {
        padding: 0.625rem 2rem 0.625rem 0.75rem;
        font-size: 0.95rem;
    }

    .search-icon {
        right: 0.5rem;
        font-size: 0.9rem;
    }
}

/* ========== Grid Responsiveness ========== */
@media (max-width: 768px) {
    .categories-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
        gap: 0.875rem;
        padding: 0.875rem;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 10px;
        padding: 10px;
    }

    .offers-grid,
    .best-sellers-grid,
    .new-arrivals-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .categories-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 8px;
        padding: 8px;
    }

    .offers-grid,
    .best-sellers-grid,
    .new-arrivals-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* ========== Footer Responsiveness ========== */
@media (max-width: 768px) {
    .footer {
        padding: 2rem 1rem;
    }

    .footer-content {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }

    .footer-section {
        width: 100%;
    }

    .footer-links {
        flex-direction: column;
        gap: 0.75rem;
    }
}

@media (max-width: 480px) {
    .footer {
        padding: 1.5rem 0.75rem;
    }

    .footer-content {
        gap: 1.25rem;
    }

    .footer-section h3 {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }

    .footer-links a {
        font-size: 0.9rem;
    }
}

/* ========== Touch Device Optimizations ========== */
@media (hover: none) and (pointer: coarse) {
    .product-card,
    .category-showcase-card,
    .add-to-cart,
    .favorite-btn,
    button {
        min-height: 44px;
        min-width: 44px;
    }

    .product-card:hover {
        transform: none;
    }

    .category-showcase-card:hover {
        transform: none;
    }

    .add-to-cart:active,
    .favorite-btn:active {
        transform: scale(0.95);
    }
}

/* ========== High DPI Displays ========== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .product-card img,
    .category-image img,
    .banner-slider img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ========== Cart Page Responsiveness ========== */
@media (max-width: 768px) {
    .cart-items {
        padding: 1rem;
    }

    .cart-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem;
    }

    .cart-item img {
        width: 100px;
        height: 100px;
        align-self: center;
    }

    .cart-item .item-details {
        width: 100%;
        text-align: center;
    }

    .cart-item h3 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }

    .cart-item .price {
        font-size: 1rem;
    }

    .cart-item .quantity {
        margin: 0.5rem 0;
    }

    .cart-item .remove-from-cart {
        align-self: center;
    }

    .cart-summary {
        padding: 1.5rem;
        margin: 1rem;
        position: static;
        width: auto;
    }

    .cart-summary .total-price {
        font-size: 1.25rem;
    }

    .checkout-btn {
        padding: 0.875rem 2rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .cart-items {
        padding: 0.5rem;
    }

    .cart-item {
        padding: 0.75rem;
    }

    .cart-item img {
        width: 80px;
        height: 80px;
    }

    .cart-item h3 {
        font-size: 1rem;
    }

    .cart-item .price {
        font-size: 0.95rem;
    }

    .cart-summary {
        padding: 1rem;
        margin: 0.5rem;
    }

    .cart-summary .total-price {
        font-size: 1.1rem;
    }

    .checkout-btn {
        padding: 0.75rem 1.5rem;
        font-size: 0.95rem;
    }
}

/* ========== Subcategories Page Responsiveness ========== */
@media (max-width: 768px) {
    .subcategories-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
        padding: 1rem;
    }

    .subcategory-card {
        padding: 1rem;
    }

    .subcategory-card img {
        height: 120px;
    }

    .subcategory-card h3 {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .subcategories-grid {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .subcategory-card {
        padding: 0.75rem;
    }

    .subcategory-card img {
        height: 100px;
    }

    .subcategory-card h3 {
        font-size: 0.9rem;
    }
}

/* ========== Banner Slider Responsiveness ========== */
@media (max-width: 768px) {
    .banner-slider {
        height: 300px;
    }

    .banner-slider .swiper-wrapper,
    .banner-slider .swiper-slide {
        height: 300px;
    }

    .banner-slider img {
        object-fit: cover;
        height: 100%;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .banner-slider {
        height: 250px;
    }

    .banner-slider .swiper-wrapper,
    .banner-slider .swiper-slide {
        height: 250px;
    }
}

/* ========== Product Details Page Responsiveness ========== */
@media (max-width: 768px) {
    .product-details {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 1rem;
        margin: 1rem auto;
    }

    .product-details .product-images {
        order: 2;
    }

    .product-details .product-info {
        order: 1;
    }

    .product-details .product-info h2 {
        font-size: 1.8rem;
    }

    .product-details .product-info p {
        font-size: 1rem;
    }

    .product-details .price {
        font-size: 1.5rem;
    }

    .product-details .add-to-cart {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .product-details {
        padding: 0.75rem;
        margin: 0.75rem auto;
        gap: 1rem;
    }

    .product-details .product-info h2 {
        font-size: 1.5rem;
    }

    .product-details .product-info p {
        font-size: 0.95rem;
    }

    .product-details .price {
        font-size: 1.25rem;
    }

    .product-details .add-to-cart {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
    }

    .product-details .thumbnail-gallery {
        padding: 0.75rem 0;
    }

    .product-details .thumbnail-gallery img {
        width: 50px;
        height: 50px;
    }
}
