:root {
    --ink: #0F172A;
    --ink-soft: #64748B;
    --canvas: #F8FAFC;
    --surface: #FFFFFF;
    --border: #E5E9F1;

    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --primary-soft: #EEF0FE;

    --emerald: #16A34A;

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 14px 30px -14px rgba(15, 23, 42, 0.2);
    --radius: 14px;

    --font-display: "Plus Jakarta Sans", Arial, sans-serif;
    --font-body: "Inter", Arial, sans-serif;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--canvas);
    font-family: var(--font-body);
}

.container {
    max-width: 1300px;
    margin: 20px auto;
    padding: 20px;
}

/* ---------- Breadcrumb ---------- */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    color: var(--ink-soft);
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.breadcrumb a {
    color: var(--ink-soft);
    text-decoration: none;
    font-weight: 500;
    transition: color .2s ease;
}
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb svg { color: var(--border); flex-shrink: 0; }
.breadcrumb span { color: var(--ink); font-weight: 600; }

/* ---------- Category head ---------- */
.category-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    position: relative;
    text-align: center;
}

.category-head h1 {
    font-family: var(--font-display);
    font-weight: 800;
    color: var(--ink);
    font-size: 32px;
}

.product-count {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-soft);
    padding: 5px 14px;
    border-radius: 999px;
}

/* ---------- Toolbar ---------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 8px;
    z-index: 5;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--canvas);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 12px;
    flex: 1 1 220px;
    min-width: 180px;
    color: var(--ink-soft);
}
.search-box input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-size: 14px;
    color: var(--ink);
    font-family: var(--font-body);
}

.sort-select {
    border: 1px solid var(--border);
    background: var(--canvas);
    color: var(--ink);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 13px;
    font-family: var(--font-body);
    cursor: pointer;
}

.view-toggle {
    display: flex;
    gap: 4px;
    background: var(--canvas);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 3px;
}
.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--ink-soft);
    border-radius: 7px;
    cursor: pointer;
    transition: background .18s ease, color .18s ease;
}
.view-btn:hover { color: var(--primary); }
.view-btn.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ---------- Products grid ---------- */
.product-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 22px;
}

.product-container.compact {
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
}

/* ---------- Product card ---------- */
.product-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    transition: transform .25s ease, box-shadow .25s ease;
    animation: card-in .5s ease backwards;
    animation-delay: calc(var(--delay, 0) * 45ms);
    display: flex;
    flex-direction: column;
}
@keyframes card-in {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}
.product-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); border-color: var(--primary); }
.product-card.is-hidden { display: none; }

.product-image-link {
    display: block;
    text-decoration: none;
    cursor: pointer;
    width: 100%;
}

.product-title-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.product-title-link:hover h3 {
    color: var(--primary);
}

.product-image {
    position: relative;
    width: 100%;
    height: 220px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--canvas);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform .35s ease;
}
.product-card:hover .product-image img { transform: scale(1.07); }

.badge {
    position: absolute;
    top: 6px;
    left: 6px;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .3px;
    z-index: 2;
}
.badge-low { background: #fef3c7; color: #b45309; }
.badge-out { background: #fee2e2; color: #dc2626; }

.product-card h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 10px;
    min-height: 44px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color .2s ease;
}

.card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    margin-bottom: 12px;
}

.card-bottom .price {
    font-family: var(--font-display);
    font-size: 20px;
    color: var(--emerald);
    font-weight: 800;
    margin-bottom: 0;
}

.stock {
    font-size: 12px;
    font-weight: 700;
    color: #16a34a;
}
.stock-zero { color: #dc2626; }

/* Add to Cart button */
.add-cart-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #ffffff;
    color: #218c1d;
    border: 1.5px solid #218c1d;
    padding: 11px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 14.5px;
    transition: .25s ease;
    font-family: var(--font-body);
}

.add-cart-btn:hover {
    background: #218c1d;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(33, 140, 29, .20);
}

.add-cart-btn.in-cart {
    background: #2563eb;
    color: #ffffff;
    border: 1.5px solid #2563eb;
    text-decoration: none;
}

.add-cart-btn.in-cart:hover {
    background: #1d4ed8;
    color: #ffffff;
    border-color: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, .25);
}

.add-cart-btn.disabled,
.add-cart-btn:disabled {
    background: #e5e7eb;
    color: #6b7280;
    border-color: #e5e7eb;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ---------- Compact view tweaks ---------- */
.product-container.compact .product-image { height: 150px; }
.product-container.compact .product-card h3 { font-size: 13.5px; min-height: 36px; }
.product-container.compact .card-bottom .price { font-size: 16px; }
.product-container.compact .add-cart-btn { padding: 8px; font-size: 12px; }

/* ---------- No products / no search results ---------- */
.no-products {
    width: 100%;
    text-align: center;
    padding: 70px 20px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.no-products svg { color: var(--border); margin-bottom: 14px; }
.no-products h2 { font-family: var(--font-display); color: var(--ink); margin-bottom: 8px; }
.no-products p { color: var(--ink-soft); margin-bottom: 22px; }
.browse-btn {
    display: inline-block;
    background: var(--primary);
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 9px;
    font-weight: 700;
    transition: background .2s ease, transform .18s ease;
}
.browse-btn:hover { background: var(--primary-dark); transform: translateY(-2px); }

.no-search-results {
    text-align: center;
    color: var(--ink-soft);
    padding: 50px 20px;
    font-size: 14px;
}

/* ---------- Tablet ---------- */
@media (max-width: 992px) {
    .product-container { grid-template-columns: repeat(3, 1fr); }
    .product-container.compact { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
    .container { padding: 22px 14px; margin: 12px auto; }
    .category-head h1 { font-size: 24px; }
    .toolbar { position: static; }
    .search-box { width: 100%; flex: 1 1 100%; min-width: 0; }
    .search-box input { min-width: 0; width: 100%; }

    .product-container { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .product-container.compact { grid-template-columns: repeat(3, 1fr); }

    .product-card { padding: 10px; border-radius: 10px; }
    .product-image { height: 130px; }
    .product-card h3 { font-size: 14px; min-height: 38px; }
    .card-bottom .price { font-size: 17px; }
    .add-cart-btn { padding: 9px; font-size: 12.5px; }
}

/* ---------- Small mobile ---------- */
@media (max-width: 420px) {
    .product-image { height: 110px; }
    .product-card h3 { font-size: 13px; }
    .card-bottom .price { font-size: 15px; }
    .add-cart-btn { padding: 8px 6px; font-size: 11.5px; }
}

/* ==========================
   FLOATING CART
========================== */
.floating-cart {
    position: fixed;
    right: 20px;
    bottom: 90px;
    width: 58px;
    height: 58px;
    background: #2563eb;
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    z-index: 9998;
    box-shadow: 0 8px 25px rgba(37,99,235,.35);
    user-select: none;
    touch-action: none;
    text-decoration: none;
    transition: transform .2s ease, box-shadow .2s ease;
}

.floating-cart:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 30px rgba(37,99,235,.45);
}

.floating-cart.dragging {
    cursor: grabbing;
    transform: scale(1.08);
    box-shadow: 0 15px 35px rgba(37,99,235,.50);
}

.floating-cart-icon {
    font-size: 25px;
    line-height: 1;
}

.floating-cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
}

@media (max-width: 768px) {
    .floating-cart {
        bottom: 80px;
        right: 16px;
        width: 50px;
        height: 50px;
    }
    .floating-cart-icon {
        font-size: 22px;
    }
}