/* Search Bar */
.search-input-wrapper {
    position: relative;
    width: 100%;
}

/* Mobile optimization */
@media (max-width: 576px) {
    .search-input {
        font-size: 0.9375rem !important;
    }

    .search-icon {
        font-size: 1.125rem !important;
    }

    .producer-select {
        font-size: 1rem !important;
        padding: 0.625rem 0.75rem !important;
    }
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
    color: var(--gray-500, #6B7280);
    pointer-events: none;
    z-index: 10;
}

.search-input {
    padding: 0.75rem 3rem !important;
    font-size: 1rem;
    border-radius: 0.5rem;
    border: 1.5px solid var(--gray-200, #E5E7EB);
    transition: all 0.2s ease;
    width: 100%;
}

.search-input:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem var(--bs-focus-ring-color);
    outline: none;
}

.search-input::placeholder {
    color: var(--gray-500, #6B7280);
    font-size: 0.9375rem;
}

.clear-search-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.25rem;
    color: var(--gray-400, #9CA3AF);
    z-index: 10;
    border: none;
    background: transparent;
    text-decoration: none;
}

.clear-search-btn:hover {
    color: var(--gray-600, #4B5563);
}

.clear-search-btn i {
    font-size: 1.25rem;
}

.search-spinner {
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
}

/* Producer Filter Section */
.producer-filter-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Mobile: Stack vertically on very small screens */
@media (max-width: 480px) {
    .producer-filter-container {
        flex-direction: column;
        gap: 0.75rem;
    }

    .producer-select-wrapper {
        width: 100%;
    }

    .producer-select {
        max-width: 100%;
    }

    .filter-btn {
        width: 100%;
        justify-content: center;
    }
}

.producer-select-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0; /* Allows flex item to shrink below content size */
}

.producer-select-wrapper .ti-building-store {
    font-size: 1.25rem;
    color: var(--gray-600, #6B7280);
    flex-shrink: 0; /* Prevent icon from shrinking */
}

.producer-select {
    flex: 1;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    min-width: 0; /* Allows select to shrink */
}

.producer-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem var(--bs-focus-ring-color);
    outline: none;
}

.filter-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: 0.375rem;
    white-space: nowrap;
}

.filter-btn .ti-filter {
    font-size: 1rem;
}

/* Category pills */
#category-pills {
    /* Two-row horizontal scroll */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    width: 100%;
    min-width: 0;
}

#category-pills::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.category-pill {
    transition: all 0.2s ease;
    border-radius: 20px;
    font-size: 1rem;
    /*padding: 0.375rem 0.75rem;*/
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    flex-shrink: 0; /* Prevent shrinking on mobile scroll */
    white-space: nowrap;
}

.category-pill .category-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.category-pill .category-name {
    line-height: 1;
}

.category-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.category-pill.active {
    box-shadow: 0 2px 4px var(--bs-focus-ring-color);
}

/* Category Sections */
.category-section {
    margin-bottom: 1rem;
    scroll-margin-top: 2rem; /* Offset for smooth scrolling */
}

.category-section-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

/* Mobile: Smaller section headers */
@media (max-width: 576px) {
    .category-section-icon {
        width: 40px;
        height: 40px;
    }

    .category-section-title {
        font-size: 1.25rem !important;
    }

    .category-section {
        margin-bottom: 2rem;
    }
}

.category-section-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-900, #111827);
    line-height: 1.5;
}

.category-section-count {
    font-size: 0.875rem;
    color: var(--gray-600, #6B7280);
    line-height: 1.25rem;
}

.category-products {
    margin-top: 1.5rem;
}

.products-collection-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    gap: 1rem;
    width: 100%;
    min-width: 0;
}

.products-collection-scroll::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

@media (pointer: fine) {
    .products-collection-scroll,
    #category-pills {
        cursor: grab;
    }

    .products-collection-scroll.is-dragging,
    #category-pills.is-dragging {
        cursor: grabbing;
    }

    .products-collection-scroll.is-dragging *,
    #category-pills.is-dragging * {
        user-select: none;
    }
}

.product-card {
    width: 20%;
    min-width: 160px;
    max-width: 260px;
    flex-shrink: 0;
    align-self: stretch;
}

.product-card .card {
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out, border-color 0.2s ease-in-out;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.product-card .card-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    flex: 1;
}

.product-card .card-body > div:last-child {
    margin-top: auto;
}

.product-price-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.product-card .card-title {
    font-size: 1rem;
    line-height: 1.4;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0;
    min-height: 2.8em; /* Reserve 2 lines (2 × 1.4 line-height) so producer names align */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
}

.product-card .card:hover {
    transform: translateY(-4px);
    box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.12);
    border-color: var(--brand-primary);
}

.product-image-shell {
    position: relative;
    width: 100%;
}

.product-image-placeholder {
    height: 250px;
}

.product-card .quick-add-form {
    margin: 0;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

/* Producer manage actions (edit/delete) — inline with price */
.product-manage-actions {
    display: flex;
    gap: 0.35rem;
    flex-shrink: 0;
}

.product-manage-btn {
    width: 2rem;
    height: 2rem;
    border: none;
    border-radius: 50%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none !important;
    line-height: 1;
    padding: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.product-manage-edit {
    background: #fff;
    color: var(--gray-600, #4B5563);
}

.product-manage-edit:hover {
    background: var(--brand-primary);
    color: #fff;
    transform: translateY(-1px);
}

.product-manage-delete {
    background: #fff;
    color: #dc3545;
}

.product-manage-delete:hover {
    background: #dc3545;
    color: #fff;
    transform: translateY(-1px);
}

.product-card .quick-add-overlay {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 1;
}

.product-card .quick-add-btn {
    width: 2.35rem;
    height: 2.35rem;
    border: none;
    border-radius: 999px;
    background: var(--brand-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.28);
    transition: all 0.2s ease;
}

.product-card .quick-add-btn:hover {
    background: var(--brand-primary-hover);
    transform: translateY(-1px);
}

.product-card .producer-name-link {
    font-size: 1rem;
    font-weight: 500;
    color: var(--brand-primary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: all 0.2s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: auto;
}

.product-card .producer-name-link:hover {
    color: var(--brand-primary-hover);
    text-decoration: underline;
}

.product-card .badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    flex-shrink: 0;
}

.product-card .badge.bg-success {
    background-color: #dcfce7 !important;
    color: #00772B !important;
}

.product-card .quick-add-plus {
    font-size: 1.4rem;
    font-weight: 500;
    line-height: 1;
    transform: translateY(-1px);
}

.product-card .quick-add-spinner {
    width: 0.9rem;
    height: 0.9rem;
    position: absolute;
    opacity: 0;
}

.product-card .quick-add-form.htmx-request .quick-add-plus {
    opacity: 0;
}

.product-card .quick-add-form.htmx-request .quick-add-spinner {
    opacity: 1;
}

.product-card .quick-add-quantity-input {
    -moz-appearance: textfield;
}

.product-card .quick-add-quantity-input::-webkit-outer-spin-button,
.product-card .quick-add-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Search input focus */
#search-input:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem var(--bs-focus-ring-color);
}

.product-card .producer-badge-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.product-card .product-rating-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--gray-600, #4B5563);
    font-size: 0.875rem;
    font-weight: 500;
    flex-shrink: 0;
    white-space: nowrap;
}

.product-card .product-rating-icon {
    color: #f59e0b;
    font-size: 0.9rem;
}

.product-card .product-rating-value,
.product-card .product-rating-count {
    line-height: 1;
}

@media (max-width: 576px) {
    .product-card .producer-badge-row {
        align-items: center;
        flex-wrap: nowrap;
    }

    .product-card .product-rating-badge {
        font-size: 0.8rem;
        gap: 0.2rem;
    }
}

.product-card .distance-badge {
    color: var(--gray-500);
}

/* Card link */
.product-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.card-img-top {
    height: 180px;
    width: 100%;
    object-fit: cover;
    aspect-ratio: 4 / 3;
    border-bottom: 1px solid var(--bs-border-color);
}

.product-card .stock-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.375rem 0.75rem;
    border-radius: 1rem;
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1;
}

.stock-badge-warning {
    color: #b45309;
}

.stock-badge-danger {
    color: #b91c1c;
}

/* Distance Filter Styles */
.distance-filter-container {
    margin-bottom: 1.5rem;
}

/* Hide distance filter by default until location is available */
#productSearchForm:not(:has(#userLatitude[value]:not([value=""]))) .distance-filter-container {
    display: none;
}

.distance-filter-container label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.distance-slider {
    --bs-form-range-track-bg: var(--gray-200);
}

.distance-slider::-webkit-slider-thumb {
    background-color: var(--brand-primary);
}

.distance-slider::-moz-range-thumb {
    background-color: var(--brand-primary);
}

.distance-slider:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 0.25rem var(--brand-primary-light);
}

.distance-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.product-card .card-text {
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--gray-600);
    margin-bottom: 0;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    flex: 1;
}

.product-card .product-price {
    font-size: 1.25rem;
    line-height: 1;
    font-weight: 700;
    color: var(--brand-primary) !important;
    margin-bottom: 0;
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.product-card .product-price .unit {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--gray-500);
}

/* Sub-category badges on product cards */
.subcategory-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.subcategory-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--brand-primary);
    background-color: var(--brand-primary-light, #D1FAE5);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
}

/* ── Product card image overlays ──────────────────────────────────────── */

/* Info button — top-left of image */
.product-info-btn {
    position: absolute;
    top: 0.4rem;
    left: 0.4rem;
    z-index: 4;
    background: rgba(0, 0, 0, 0.45);
    border: none;
    border-radius: 50%;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
    padding: 0;
    line-height: 1;
}

.product-info-btn:hover {
    background: rgba(0, 0, 0, 0.65);
}

/* Favorite toggle button — top-left of image, next to info button */
.favorite-toggle {
    position: absolute;
    top: 0.4rem;
    left: 0.4rem;
    z-index: 4;
    border: none;
    border-radius: 50%;
    width: 1.75rem;
    height: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
    padding: 0;
    line-height: 1;
    background: rgba(0, 0, 0, 0.45);
}

/* Shift right when info button is present before it */
.product-info-btn ~ .favorite-toggle {
    left: 2.5rem;
}

.favorite-toggle:hover {
    background: rgba(0, 0, 0, 0.65);
}

/* Info overlay panel — fills the image area */
.product-info-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: rgba(0, 0, 0, 0.72);
    border-radius: inherit;
    padding: 2.25rem 0.75rem 0.75rem 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-info-description {
    color: #fff;
    font-size: 0.8125rem;
    line-height: 1.45;
    margin: 0;
}

.product-info-subcats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.product-info-subcat-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.6875rem;
    font-weight: 500;
    color: #fff;
    background: rgba(16, 185, 129, 0.75);
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    white-space: nowrap;
}

.product-info-subcat-badge i {
    font-size: 0.875rem;
    color: #fff;
    line-height: 1;
}

/* Sub-category icon strip — bottom-left of image */
.product-subcat-icons {
    position: absolute;
    bottom: 0.4rem;
    left: 0.4rem;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem;
    max-width: calc(100% - 0.8rem);
}

.product-subcat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 50%;
    width: 1.6rem;
    height: 1.6rem;
    line-height: 1;
    cursor: default;
    color: #fff;
}

.product-subcat-icon i {
    font-size: 0.875rem;
    color: #fff;
    line-height: 1;
}
