/* =========================================================
   Product Grid
========================================================= */
.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);  /* 4 equal columns */
    gap: 1.5rem;
    max-width: 100vw;
    margin: 2rem 1rem;
}

/* Product Card */
.product-card {
    position: relative;   /* Add this */
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background-color: var(--cardBgColor);
    padding: 0rem 0 1rem 0;
    margin: 0rem 0rem;
}

.product-card a {
    text-decoration: none;
    cursor: pointer;
    box-shadow: none;
}
.product-card a:hover {
    text-decoration: none;
    cursor: pointer;
}

/* Product Image */
.product-card img {
    width: 100%;
    height: auto;
    padding: 0rem;
    margin: 0rem;
    object-fit: cover;
    box-sizing: border-box;
}

/* Product Name */
.product-card h3 {
    font-size: 1.125rem;
    font-weight: 400;
    color: var(--textColor);
}

/* Product Price */
.product-card p {
    font-weight: 500;
    margin: 0.5rem;
    color: var(--textColor);
}

/* ------------------- wishlist ------------------- */
.wishlist-heart {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    z-index: 10;
}

/* ------------------- Share section ------------------- */
.share-wrapper {
    position: absolute;
    top: 0.5rem;      /* top-left corner */
    left: 0.5rem;
    z-index: 15;
}

.share-wrapper .share-btn {
    border: none;
    border-radius: 1rem;
    cursor: pointer;
    font-size: 1.3rem;
}

.share-menu {
    display: none;     /* hidden by default */
    position: absolute;
    top: 110%;         /* below the button */
    left: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    flex-direction: column;
    min-width: 80px;
    cursor: pointer;
    z-index: 20;
}

.share-menu.open {
    display: flex;     /* show menu when .open is toggled */
}

.share-menu button {
    background: none;
    border: none;
    padding: 0.6rem;
    text-align: left;
    cursor: pointer;
    font-size: 0.85rem;
}

.share-menu button:hover {
    cursor: pointer;
    background-color: #e1e1e1;
}

/* ------------------- Sort and Filter ------------------- */

/* Container toolbar aligned top right */
.product-toolbar {
    display: flex;
    justify-content: flex-end; /* aligns everything to the right */
    align-items: center;
    gap: 1rem; /* space between sort and filter */
    padding: 1rem;
    position: relative;
}

/* Sort dropdown styling */
.sort-dropdown {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.sort-dropdown select {
    height: var(--toolbar-control-height);
    padding: 0rem 0.4rem;
    border-radius: 4px;
    border: 1px solid #ccc;
    cursor: pointer;
}

/* Filter button styling */
.filter-btn {
    height: var(--toolbar-control-height);
    padding: 0rem 0.4rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    position: relative;
    min-width: 80px;
    transition: all 0.2s ease;
}

/* Filter icon hidden by default */
.filter-btn .filter-icon {
    display: inline-block;
    font-size: 0.8rem;
    color: var(--btnBgColor); /* subtle blue checkmark */
    width: 12px;      /* reserve fixed width for the icon */
    text-align: center;
    visibility: hidden; /* hide icon but keep space */
}

/* Show icon when filters are active */
.filter-btn.active .filter-icon {
    visibility: visible;
}

/* Make the filter dropdown container relative */
.filter-dropdown {
    position: relative; /* now the menu aligns to this container */
    z-index: 20;
}

/* Filter menu (hidden by default) */
.filter-menu {
    display: none; /* hide initially */
    position: absolute;
    top: 100%; /* right below the button */
    right: 0;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 0.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    min-width: 150px;
}

/* Show the menu when button is active (JS will toggle this class) */
.filter-menu.show {
    display: block;
}

/* Filter menu checkboxes styling */
.filter-menu label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0;
    cursor: pointer;
}

.filter-menu input[type="checkbox"] {
    cursor: pointer;
}

/* =========================================================
   MOBILE RESPONSIVE STYLES
========================================================= */
@media (max-width: 700px) {
    .product-grid {
        display: grid;
        grid-template-columns: repeat(1, 1fr);
        gap: 1rem;
        margin: 1rem;
    }

    .wishlist-heart {
        top: 0.5rem;
    }

    .share-wrapper .share-btn {
        font-size: 1.1rem;
        border-radius: 1.5rem;
    }

    .product-card img {
        width: 100%;
        height: auto;
    }
}
