/* ============================================ */
/* RESET & BASE                                 */
/* ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
    background: #f5f5f5;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: #111;
    line-height: 1.5;
    padding-bottom: 75px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar {
    width: 0;
    height: 0;
    background: transparent;
    display: none;
}

::selection {
    background: #f97316;
    color: white;
}

/* ============================================ */
/* LAYOUT & CONTAINER                           */
/* ============================================ */

.container,
.products-content {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    background:white;
}

.products-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ============================================ */
/* SORT BAR                                     */
/* ============================================ */

.sort-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid #eef2f6;
    border-top: 1px solid #eef2f6;
}

.d-flex {
    display: flex;
    align-items: center;
    width: 100%;
}

.w-100 {
    width: 100%;
}

.sort-label {
    font-size: 13px;
    color: #737373;
    font-weight: 500;
    margin-right: 8px;
    white-space: nowrap;
}

.sort-select {
    background: white;
    border: 1px solid #e5e5e5;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #111;
    font-family: inherit;
    appearance: auto;
    -webkit-appearance: auto;
    cursor: pointer;
    flex: 1;
    max-width: 200px;
}

.sort-select:focus {
    outline: none;
    border-color: #f97316;
}

/* ============================================ */
/* PRODUCTS GRID                                */
/* ============================================ */

.products-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    margin: 0;
    width: 100%;
    background:white;
}

/* ============================================ */
/* PRODUCT CARD                                 */
/* ============================================ */

.product-card {
    border-radius: 0;
    border: none;
    border-bottom: 1px solid #eef2f6;
    border-right: 1px solid #eef2f6;
    margin: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.product-card:nth-child(even) {
    border-right: none;
}

.product-card:active {
    background: #fafafa;
}

/* ============================================ */
/* PRODUCT IMAGE                                */
/* ============================================ */

.product-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.product-img a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
}

.product-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================ */
/* PRODUCT ACTIONS (Wishlist)                   */
/* ============================================ */

.product-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 2;
}

.btn-wishlist {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: #f97316;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
}

.btn-wishlist:active {
    transform: scale(0.9);
    background: #f97316;
    color: white;
}

.btn-wishlist:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-wishlist .fas.fa-heart {
    color: #f97316;
}

/* ============================================ */
/* PRODUCT BODY                                 */
/* ============================================ */

.product-body {
    padding: 10px 12px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-title {
    font-size: 13px;
    font-weight: 600;
    color: #111;
    text-decoration: none;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 34px;
    line-height: 1.3;
    margin-bottom: 4px;
}

.product-title:active {
    color: #f97316;
}

.product-price {
    font-size: 16px;
    font-weight: 700;
    color: #f97316;
    margin-bottom: 6px;
}

.product-old-price {
    font-size: 11px;
    color: #999;
    text-decoration: line-through;
    font-weight: 400;
    margin-left: 5px;
}

.product-weight {
    font-size: 11px;
    color: #737373;
    margin-bottom: 2px;
}

.product-supplier {
    font-size: 11px;
    color: #737373;
    margin-bottom: 8px;
}

.product-supplier i {
    margin-right: 4px;
    color: #f97316;
}

/* ============================================ */
/* ADD TO CART BUTTON                           */
/* ============================================ */

.btn-add-to-cart {
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: #f97316;
    color: white;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    border-radius: 25px;
    font-family: inherit;
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-add-to-cart:active {
    opacity: 0.7;
    transform: scale(0.97);
}

.btn-add-to-cart:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-add-to-cart i {
    font-size: 14px;
}

/* ============================================ */
/* EMPTY STATE                                  */
/* ============================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 14px;
    margin: 20px 16px;
    border: 1px solid #e5e5e5;
    grid-column: 1 / -1;
}

.empty-state i {
    font-size: 48px;
    color: #ccc;
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 18px;
    color: #111;
    margin-bottom: 4px;
}

.empty-state p {
    color: #737373;
    font-size: 14px;
    margin-bottom: 14px;
}

/* ============================================ */
/* BUTTONS                                      */
/* ============================================ */

.btn-primary {
    display: inline-block;
    background: #f97316;
    color: white;
    padding: 10px 24px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

.btn-primary:active {
    opacity: 0.8;
    transform: scale(0.97);
}

.btn-secondary {
    display: inline-block;
    background: #e5e5e5;
    color: #111;
    padding: 10px 24px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
}

.btn-secondary:active {
    opacity: 0.7;
    transform: scale(0.97);
}

/* ============================================ */
/* PAGINATION                                   */
/* ============================================ */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 20px 16px;
    list-style: none;
    flex-wrap: wrap;
    background: white;
    margin: 0;
}

.page-item {
    display: inline-block;
}

.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    background: white;
    color: #111;
    text-decoration: none;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
}

.page-link:active {
    background: #f97316;
    color: white;
    border-color: #f97316;
}

.page-item.active .page-link {
    background: #f97316;
    color: white;
    border-color: #f97316;
}

.page-link i {
    font-size: 12px;
}

/* ============================================ */
/* FILTER SIDEBAR - Slide-in on Mobile          */
/* ============================================ */

.filter-sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 320px;
    height: 100%;
    background: white;
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding: 16px;
    overscroll-behavior: contain;
}

.filter-sidebar.active,
.filter-sidebar.open {
    left: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e5e5;
    margin-bottom: 16px;
}

.sidebar-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
}

.close-sidebar {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    padding: 4px 8px;
    color: #737373;
}

.close-sidebar:active {
    color: #111;
}

.filter-section {
    margin-bottom: 20px;
}

.filter-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #111;
}

/* Category Tree */
.category-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-tree li {
    margin-bottom: 2px;
}

.category-tree a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    color: #444;
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
}

.category-tree a:active {
    background: #fff0e6;
    color: #f97316;
}

.category-tree a.active {
    background: #f97316;
    color: white;
}

.category-tree a i {
    width: 18px;
    font-size: 14px;
}

.category-tree ul {
    list-style: none;
    padding-left: 16px;
}

.category-badge {
    background: #e5e5e5;
    color: #666;
    font-size: 10px;
    padding: 1px 8px;
    border-radius: 12px;
    margin-left: auto;
    min-width: 20px;
    text-align: center;
}

/* Brand Filter List */
.filter-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.filter-list li {
    margin-bottom: 2px;
}

.filter-list a {
    display: block;
    padding: 8px 10px;
    color: #444;
    text-decoration: none;
    border-radius: 8px;
    font-size: 13px;
}

.filter-list a:active {
    background: #fff0e6;
    color: #f97316;
}

.filter-list a.active {
    background: #f97316;
    color: white;
}

/* Price Range */
.price-range {
    padding: 4px 0;
}

.price-range .row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.price-range .col-6 {
    flex: 0 0 calc(50% - 4px);
    max-width: calc(50% - 4px);
}

.price-range .col-12 {
    flex: 0 0 100%;
    max-width: 100%;
}

.price-range input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    background: white;
}

.price-range input[type="number"]:focus {
    border-color: #f97316;
    outline: none;
}

.price-range .mt-2 {
    margin-top: 8px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.price-range .btn-primary,
.price-range .btn-secondary {
    padding: 8px 16px;
    font-size: 13px;
    flex: 1;
    text-align: center;
    min-width: 80px;
}

/* ============================================ */
/* SIDEBAR OVERLAY                              */
/* ============================================ */

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================ */
/* SIDEBAR TOGGLE BUTTON - Mobile Only          */
/* ============================================ */

.sidebar-toggle {
    position: fixed;
    bottom: 80px;
    left: 16px;
    background: #f97316;
    color: white;
    border: none;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    font-size: 18px;
    z-index: 100;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.sidebar-toggle:active {
    transform: scale(0.9);
}

.sidebar-toggle i {
    font-size: 20px;
}

/* ============================================ */
/* NOTIFICATIONS                                */
/* ============================================ */

.cart-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    z-index: 9999;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 10px;
    max-width: 90%;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-notification i {
    font-size: 18px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============================================ */
/* RESPONSIVE - TABLET & DESKTOP                */
/* ============================================ */

@media (min-width: 576px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
        padding: 16px;
        background: transparent;
    }

    .product-card {
        border-radius: 14px;
        border: 1px solid #eef2f6;
    }

    .product-card:nth-child(even) {
        border-right: 1px solid #eef2f6;
    }

    .product-img {
        border-radius: 14px 14px 0 0;
    }

    .filter-sidebar {
        position: sticky;
        top: 0;
        left: 0 !important;
        width: 280px;
        max-width: 280px;
        height: auto;
        max-height: 100vh;
        background: white;
        padding: 16px;
        border-radius: 14px;
        border: 1px solid #eef2f6;
        overflow-y: auto;
        display: block !important;
        flex-shrink: 0;
        margin-right: 0;
        transition: none;
        position: sticky;
    }

    .sidebar-overlay {
        display: none !important;
    }

    .close-sidebar {
        display: none;
    }

    .sidebar-toggle {
        display: none !important;
    }

    .products-layout {
        display: flex;
        flex-direction: row;
        gap: 20px;
        padding: 16px;
        max-width: 1200px;
        margin: 0 auto;
        align-items: flex-start;
    }

    .products-content {
        flex: 1;
        min-width: 0;
    }

    .sort-bar {
        border-radius: 10px;
        border: 1px solid #eef2f6;
        margin-bottom: 16px;
        background: white;
    }

    .pagination {
        background: transparent;
        padding: 16px 0;
    }
}

@media (min-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
        padding: 20px;
    }

    .filter-sidebar {
        width: 300px;
        max-width: 300px;
        padding: 20px;
    }
}

@media (min-width: 992px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 24px;
        padding: 24px;
    }

    .filter-sidebar {
        width: 320px;
        max-width: 320px;
        padding: 24px;
    }
}

@media (min-width: 1200px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 24px;
        padding: 24px;
    }

    .filter-sidebar {
        width: 340px;
        max-width: 340px;
        padding: 24px;
    }
}

/* ============================================ */
/* RESPONSIVE - SMALL MOBILE (below 400px)      */
/* ============================================ */

@media (max-width: 400px) {
    .product-title {
        font-size: 12px;
        min-height: 28px;
    }

    .product-price {
        font-size: 14px;
    }

    .btn-add-to-cart {
        font-size: 11px;
        padding: 8px;
    }

    .sort-label {
        font-size: 11px;
    }

    .sort-select {
        font-size: 12px;
        padding: 6px 10px;
    }

    .sidebar-toggle {
        width: 48px;
        height: 48px;
        font-size: 16px;
        bottom: 72px;
        left: 12px;
    }

    .sidebar-toggle i {
        font-size: 18px;
    }

    .product-body {
        padding: 8px 10px 10px;
    }

    .product-actions {
        top: 6px;
        right: 6px;
    }

    .btn-wishlist {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
}

/* ============================================ */
/* TOUCH DEVICE OPTIMIZATIONS                   */
/* ============================================ */

@media (hover: none) and (pointer: coarse) {
    .product-card:hover {
        transform: none !important;
    }

    .product-card:active {
        background: #fafafa;
    }

    .btn-add-to-cart:active {
        opacity: 0.7;
        transform: scale(0.97);
    }

    .btn-wishlist:active {
        transform: scale(0.9);
        background: #f97316;
        color: white;
    }

    .category-tree a:hover {
        background: none !important;
    }

    .filter-list a:hover {
        background: none !important;
    }
}

/* ============================================ */
/* UTILITY CLASSES                              */
/* ============================================ */

.text-center {
    text-align: center;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.mt-2 {
    margin-top: 8px;
}

.col-6 {
    flex: 0 0 50%;
    max-width: 50%;
}

.col-12 {
    flex: 0 0 100%;
    max-width: 100%;
}

.g-2 {
    gap: 8px;
}

.row {
    display: flex;
    flex-wrap: wrap;
}

/* ============================================ */
/* SAFE AREA (Notch phones)                     */
/* ============================================ */

@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-bottom: calc(75px + env(safe-area-inset-bottom));
    }

    .sidebar-toggle {
        bottom: calc(80px + env(safe-area-inset-bottom));
    }

    .cart-notification {
        top: calc(20px + env(safe-area-inset-top));
        right: calc(20px + env(safe-area-inset-right));
    }
}

/* ============================================ */
/* BODY MODIFIER FOR SIDEBAR OPEN              */
/* ============================================ */

body.sidebar-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ============================================ */
/* PRINT STYLES                                 */
/* ============================================ */

@media print {
    .sidebar-toggle,
    .filter-sidebar,
    .sidebar-overlay,
    .sort-bar,
    .pagination,
    .btn-add-to-cart,
    .btn-wishlist {
        display: none !important;
    }

    .products-grid {
        display: block;
    }

    .product-card {
        break-inside: avoid;
        page-break-inside: avoid;
        border: 1px solid #ddd;
        margin-bottom: 20px;
        padding: 10px;
    }

    body {
        padding-bottom: 0 !important;
    }
}

/* ============================================ */
/* FOCUS STYLES FOR ACCESSIBILITY              */
/* ============================================ */

.sort-select:focus-visible,
.price-range input:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.sidebar-toggle:focus-visible,
.close-sidebar:focus-visible,
.btn-add-to-cart:focus-visible,
.btn-wishlist:focus-visible {
    outline: 2px solid #f97316;
    outline-offset: 2px;
}

.category-tree a:focus-visible,
.filter-list a:focus-visible,
.page-link:focus-visible,
.product-title:focus-visible {
    outline: 2px solid #f97316;
    outline-offset: 2px;
}