/* Product image container */
.product-thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--surface-color);
}

    /* Product image */
    .product-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        cursor: pointer;
    }

/* Invisible clickable layer for details page */
.product-image-link {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: block;
    cursor: pointer;
}

/* Product card */
.product-box {
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

    .product-box:hover {
        transform: translateY(-6px);
        box-shadow: var(--shadow-md, 0 12px 28px rgba(0,0,0,0.12));
    }

.product-box-link {
    cursor: pointer;
}

/* Overlay */
.product-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.product-box:hover .product-overlay {
    opacity: 1;
}

/* Only real controls inside overlay should be clickable */
.product-overlay .product-quick-actions,
.product-overlay .quick-action-btn,
.product-overlay .add-to-cart-container,
.product-overlay .open-add-to-cart-modal {
    pointer-events: auto;
}

/* Keep quick actions positioned properly */
.product-quick-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
}

/* Keep add to cart positioned properly */
.add-to-cart-container {
    position: absolute;
    left: 50%;
    bottom: 12px;
    transform: translateX(-50%);
    z-index: 3;
    display: flex;
    justify-content: center;
}

/* Buttons */
.quick-action-btn,
.open-add-to-cart-modal {
    cursor: pointer;
}

/* Product content layout */
.product-content {
    display: flex;
    flex-direction: column;
    height: auto;
    overflow: visible;
    padding-top: 10px;
}

.product-details {
    height: auto;
    overflow: visible;
}

/* Product title */
.product-title {
    margin: 0 0 8px;
    height: auto;
    max-height: none;
    overflow: visible;
    white-space: normal;
    display: block;
    line-height: 1.35;
}

    .product-title a {
        display: block;
        line-height: 1.35;
        text-decoration: none;
        color: inherit;
        white-space: normal;
        overflow: visible;
    }

/* Product code */
.product-code {
    display: block;
    font-size: 12px;
    color: #777;
    margin-bottom: 2px;
    white-space: normal;
    overflow: visible;
}

/* Product name - full visible */
.product-name {
    display: block;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.4;
}

/* Product colors spacing */
.product-color-options {
    margin-top: 8px;
}

/* Size grid */
.size-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.size-option {
    margin: 0;
}

    .size-option .form-check-input {
        position: absolute;
        opacity: 0;
    }

.size-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    min-width: 70px;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 8px;
    background: var(--surface-color, #fff);
    cursor: pointer;
    font-size: 14px;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.size-option .form-check-input:checked + .size-chip {
    border-color: var(--bs-primary, #0d6efd);
    background: rgba(13, 110, 253, 0.08);
    color: var(--bs-primary, #0d6efd);
    font-weight: 600;
}

.size-chip:hover {
    border-color: var(--bs-primary, #0d6efd);
}

.size-count {
    margin-left: 4px;
    opacity: 0.7;
}


/* Force product title and name to wrap fully */
.product-content,
.product-details,
.product-title,
.product-title a,
.product-title .product-code,
.product-title .product-name {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    white-space: normal !important;
    text-overflow: unset !important;
    word-break: break-word !important;
    overflow-wrap: anywhere !important;
}

/* Keep title as block and allow multiple lines */
.product-title {
    display: block !important;
    margin: 0 0 8px !important;
    line-height: 1.35 !important;
}

    .product-title a {
        display: block !important;
        line-height: 1.35 !important;
    }

/* Code on its own line */
.product-code {
    display: block !important;
    font-size: 12px;
    color: #777;
    margin-bottom: 4px;
}

/* Name on its own line and fully visible */
.product-name {
    display: block !important;
    line-height: 1.4 !important;
}

/* Keep card layout stable */
.product-box {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-content {
    display: flex;
    flex-direction: column;
    padding-top: 10px;
}


/* =========================
   Category tree
========================= */
.category-tree {
    width: 100%;
    min-width: 0;
}

    .category-tree .category-item {
        margin-bottom: 8px;
        min-width: 0;
    }

    .category-tree .category-header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 8px;
        width: 100%;
        min-width: 0;
    }

    .category-tree .category-link,
    .category-tree .subcategory-link {
        display: block;
        flex: 1 1 auto;
        min-width: 0;
        max-width: 100%;
        text-decoration: none;
        line-height: 1.45;
        white-space: normal;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .category-tree .category-link {
        font-weight: 500;
        padding: 2px 0;
    }

        .category-tree .category-link.active,
        .category-tree .subcategory-link.active {
            font-weight: 700;
        }

    .category-tree .category-toggle-btn,
    .category-tree .category-toggle {
        flex: 0 0 24px;
        width: 24px;
        min-width: 24px;
        height: 24px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        margin-top: 2px;
        border: 0;
        background: transparent;
        box-shadow: none !important;
    }

        .category-tree .category-toggle-btn:focus,
        .category-tree .category-toggle:focus {
            box-shadow: none !important;
            outline: none;
        }

    .category-tree .category-children-wrap,
    .category-tree .category-featuregroups-wrap {
        margin-top: 6px;
        margin-left: 0;
        padding-left: 14px !important;
        border-left: 1px solid rgba(0, 0, 0, 0.08);
        min-width: 0;
    }

        .category-tree .category-children-wrap > ul,
        .category-tree .category-featuregroups-wrap > ul,
        .category-tree .subcategory-list {
            margin: 0;
            padding: 0;
            list-style: none;
            min-width: 0;
        }

            .category-tree .subcategory-list li,
            .category-tree .category-children-wrap li {
                margin-bottom: 6px;
                min-width: 0;
            }

    .category-tree .subcategory-link {
        font-size: 0.95rem;
        padding: 2px 0;
    }

    .category-tree .category-item:last-child,
    .category-tree .subcategory-list li:last-child,
    .category-tree .category-children-wrap li:last-child {
        margin-bottom: 0;
    }