/* Search Panel v5 - Fixed Scrolling */

.h4-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9998;
}
.h4-search-overlay.active {
    opacity: 1;
    visibility: visible;
}

.h4-search-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 400px;
    height: 100%;
    height: 100dvh;
    background: #fff;
    transform: translateX(-100%);
    transition: transform 0.35s ease;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.h4-search-panel.active {
    transform: translateX(0);
}

.h4-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #faf8f5;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
}
.h4-panel-header h3 {
    font-family: "Cormorant Garamond", Georgia, serif;
    font-size: 20px;
    font-weight: 500;
    margin: 0;
    color: #2d2d2d;
}
.h4-panel-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #666;
    background: none;
    border: none;
    cursor: pointer;
}

.h4-search-input-wrap {
    padding: 12px 20px;
    display: flex;
    gap: 10px;
    background: #fff;
    flex-shrink: 0;
}
#h4SearchInput {
    flex: 1;
    padding: 12px 16px;
    font-size: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
}
#h4SearchInput:focus {
    border-color: #d4a574;
}
.h4-search-btn {
    width: 46px;
    height: 46px;
    background: #d4a574;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.h4-search-btn svg {
    width: 20px;
    height: 20px;
}

.h4-search-results {
    padding: 0 20px;
    max-height: 40vh;
    overflow-y: auto;
    flex-shrink: 0;
}
.h4-search-results:empty {
    display: none;
}
.h4-search-results:not(:empty) {
    padding: 10px 20px;
    border-bottom: 1px solid #eee;
}
.h4-results-loading, .h4-no-results {
    padding: 15px 0;
    text-align: center;
    color: #888;
}
.h4-result-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: #2d2d2d;
}
.h4-result-item:last-child {
    border-bottom: none;
}
.h4-result-item img {
    width: 55px;
    height: 55px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}
.h4-result-item-info {
    flex: 1;
    min-width: 0;
}
.h4-result-item-title {
    font-weight: 500;
    font-size: 13px;
    line-height: 1.3;
    margin-bottom: 4px;
}
.h4-result-item-price {
    color: #d4a574;
    font-size: 13px;
    font-weight: 600;
}

.h4-tabs {
    display: flex;
    background: #faf8f5;
    border-bottom: 2px solid #eee;
    padding: 0 20px;
    flex-shrink: 0;
}
.h4-tab {
    flex: 1;
    padding: 12px 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #888;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
}
.h4-tab.active {
    color: #d4a574;
    border-bottom-color: #d4a574;
}

/* THIS IS THE KEY - scrollable content area */
.h4-tab-panels {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 20px 100px 20px;
    min-height: 0;
}
.h4-tab-panel {
    display: none;
}
.h4-tab-panel.active {
    display: block;
}

.h4-cat-item {
    display: block;
    padding: 12px 14px;
    margin-bottom: 6px;
    background: #faf8f5;
    border-radius: 8px;
    text-decoration: none;
    color: #2d2d2d;
    font-size: 14px;
    font-weight: 500;
}
.h4-cat-item:hover {
    background: #f0ebe5;
}

.h4-view-all {
    display: block;
    padding: 12px 20px;
    text-align: center;
    background: #faf8f5;
    color: #d4a574;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

body.h4-search-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

@media (max-width: 480px) {
    .h4-search-panel {
        max-width: 100%;
    }
}

/* Fix for Added to cart state in search results */
.h4-search-result .added_to_cart,
.h4-search-result .add_to_cart_button.added {
    display: inline-block !important;
    background: #e3967e !important;
    color: white !important;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    font-size: 12px !important;
    text-transform: none !important;
    margin-top: 8px !important;
    text-decoration: none !important;
}

.h4-search-result .add_to_cart_button.added {
    background: #28a745 !important;
    pointer-events: none;
}

.h4-search-result .add_to_cart_button.added::after {
    content:  ✓ !important;
}

.h4-search-result .added_to_cart {
    display: block !important;
    margin-top: 5px !important;
    font-size: 11px !important;
    background: transparent !important;
    color: #e3967e !important;
    padding: 5px 0 !important;
}

/* Keep price visible and styled */
.h4-search-result .price {
    display: block !important;
    font-weight: bold !important;
    color: #e3967e !important;
    font-size: 14px !important;
    margin: 5px 0 !important;
}

/* Hide WooCommerce default messages in search results */
.h4-search-result .woocommerce-message,
.h4-search-result .wc-forward {
    font-size: 11px !important;
    color: #e3967e !important;
}
