/* ============================================================
   HNNP — Unified Smart Product Search (Desktop & Mobile)
   Namespace: .hnnp-search*
   ============================================================ */

.hnnp-search {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    font-family: inherit;
}

.hnnp-search *,
.hnnp-search *::before,
.hnnp-search *::after,
.hnnp-search-dropdown,
.hnnp-search-dropdown *,
.hnnp-search-dropdown *::before,
.hnnp-search-dropdown *::after {
    box-sizing: border-box;
}

.hnnp-search [hidden],
.hnnp-search-dropdown[hidden] {
    display: none !important;
}

.hnnp-search-form {
    display: flex;
    align-items: stretch;
    width: 100%;
    height: 38px;
    min-height: 38px;
    margin: 0;
    padding: 0;
    background: #fff;
    border: 1px solid #d4d8e1;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.hnnp-search-form:focus-within {
    border-color: #4A79FF;
    box-shadow: 0 0 0 3px rgba(74, 121, 255, .14);
}

.hnnp-search input.hnnp-search-input {
    appearance: none;
    -webkit-appearance: none;
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 8px 0 12px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    color: #192334 !important;
    font-family: inherit;
    font-size: 14px !important;
    font-weight: 400;
    line-height: 1.3;
}

.hnnp-search input.hnnp-search-input::placeholder {
    color: #9ca3af !important;
    font-weight: 400;
}

.hnnp-search input.hnnp-search-input::-webkit-search-cancel-button,
.hnnp-search input.hnnp-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.hnnp-search button.hnnp-search-clear {
    appearance: none;
    flex: 0 0 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px !important;
    min-width: 30px !important;
    height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #8b929c !important;
    cursor: pointer;
    transition: color .15s ease;
}

.hnnp-search button.hnnp-search-clear:hover,
.hnnp-search button.hnnp-search-clear:focus,
.hnnp-search button.hnnp-search-clear:focus-visible {
    color: #192334 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

.hnnp-search button.hnnp-search-clear svg {
    display: block;
    width: 15px;
    height: 15px;
    pointer-events: none;
}

.hnnp-search button.hnnp-search-submit {
    appearance: none;
    flex: 0 0 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px !important;
    min-width: 42px !important;
    height: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: linear-gradient(180deg, #4A79FF 0%, #2B5ACD 100%) !important;
    box-shadow: none !important;
    color: #fff !important;
    cursor: pointer;
    transition: filter .15s ease;
}

.hnnp-search button.hnnp-search-submit:hover,
.hnnp-search button.hnnp-search-submit:focus,
.hnnp-search button.hnnp-search-submit:focus-visible {
    filter: brightness(1.06);
    background: linear-gradient(180deg, #4A79FF 0%, #2B5ACD 100%) !important;
    color: #fff !important;
    box-shadow: none !important;
    outline: none !important;
}

.hnnp-search button.hnnp-search-submit::before,
.hnnp-search button.hnnp-search-submit::after,
.hnnp-search button.hnnp-search-clear::before,
.hnnp-search button.hnnp-search-clear::after {
    content: none !important;
}

.hnnp-search button.hnnp-search-submit svg {
    display: block;
    width: 17px;
    height: 17px;
    pointer-events: none;
}

/* ── Dropdown đa khối ──────────────────────────────────────── */
.hnnp-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    min-width: min(500px, calc(100vw - 32px));
    z-index: 99990;
    display: flex;
    flex-direction: column;
    max-height: min(560px, calc(100dvh - 104px));
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 14px 36px rgba(15, 23, 42, .16);
    overflow: hidden;
    text-align: left;
}

.hnnp-search-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.hnnp-search-section {
    padding: 0;
}

.hnnp-search-section + .hnnp-search-section {
    border-top: 1px solid #f1f3f6;
}

.hnnp-search-sec-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    background: #f8fafc;
    color: #192334;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
}

.hnnp-search-sec-head svg {
    width: 15px;
    height: 15px;
    flex: 0 0 auto;
    color: #2B5ACD;
}

.hnnp-search-sec-head--hot svg {
    color: #f97316;
}

/* 1. Có phải bạn muốn tìm */
.hnnp-search-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px 12px;
}

.hnnp-search-chip {
    display: inline-block;
    padding: 5px 11px;
    border-radius: 999px;
    background: #f3f5f8;
    color: #334155 !important;
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.3;
    text-decoration: none !important;
    transition: background-color .12s ease, color .12s ease;
}

.hnnp-search-chip strong {
    font-weight: 700;
    color: #111827;
}

.hnnp-search-chip:hover {
    background: #eaf0ff;
    color: #2B5ACD !important;
}

.hnnp-search-chip:hover strong {
    color: #2B5ACD;
}

/* 2. Danh mục gợi ý (2 cột) */
.hnnp-search-cat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 10px;
    padding: 8px 10px 10px;
}

.hnnp-search-cat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    color: #192334 !important;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.3;
    text-decoration: none !important;
    transition: background-color .12s ease, color .12s ease;
}

.hnnp-search-cat-item:hover {
    background: #f5f8ff;
    color: #2B5ACD !important;
}

.hnnp-search-cat-thumb {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #edf0f5;
    border-radius: 7px;
    background: #fff;
    overflow: hidden;
}

.hnnp-search-cat-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: contain;
}

.hnnp-search-cat-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-width: 0;
}

/* 3. Sản phẩm gợi ý */
.hnnp-search-list {
    margin: 0;
    padding: 4px 0;
    list-style: none;
}

.hnnp-search-item {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #f3f4f6;
}

.hnnp-search-item:last-child {
    border-bottom: 0;
}

.hnnp-search-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 14px;
    color: #192334 !important;
    text-decoration: none !important;
    transition: background-color .12s ease;
}

.hnnp-search-link:hover,
.hnnp-search-link.is-active {
    background: #f5f8ff;
    color: #192334 !important;
    text-decoration: none !important;
}

.hnnp-search-thumb {
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #edf0f5;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.hnnp-search-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: contain;
}

.hnnp-search-info {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.hnnp-search-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: #192334;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
}

.hnnp-search-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
}

.hnnp-search-price {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
    color: #2B5ACD;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.25;
}

.hnnp-search-price ins {
    order: 1;
    background: none !important;
    color: #2B5ACD !important;
    text-decoration: none !important;
}

.hnnp-search-price del {
    order: 2;
    color: #8b929c !important;
    font-size: 11.5px !important;
    font-weight: 400 !important;
    text-decoration: line-through !important;
}

.hnnp-search-price .woocommerce-Price-amount {
    color: inherit !important;
}

.hnnp-search-out {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 10px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

/* 4. Thông tin liên quan */
.hnnp-search-post-list {
    margin: 0;
    padding: 6px 14px 10px;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hnnp-search-post-link {
    display: block;
    color: #2B5ACD !important;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
    text-decoration: none !important;
}

.hnnp-search-post-link:hover {
    text-decoration: underline !important;
}

/* Footer dropdown */
.hnnp-search-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px 14px;
    border-top: 1px solid #edf0f5;
    background: #f8fafc;
    color: #2B5ACD !important;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none !important;
    transition: background-color .12s ease;
}

.hnnp-search-footer:hover {
    background: #edf3ff;
    color: #2B5ACD !important;
}

/* Loading & Empty state trong dropdown */
.hnnp-search-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 14px;
    color: #64748b;
    font-size: 13px;
    line-height: 1.45;
    text-align: center;
}

.hnnp-search-spinner {
    width: 15px;
    height: 15px;
    border: 2px solid #dbe5ff;
    border-top-color: #2B5ACD;
    border-radius: 50%;
    animation: hnnp-search-spin .7s linear infinite;
    flex: 0 0 auto;
}

@keyframes hnnp-search-spin {
    to { transform: rotate(360deg); }
}

.hnnp-search-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 16px 22px;
    text-align: center;
}

.hnnp-search-empty-icon {
    display: block;
    width: 86px;
    height: 86px;
    margin: 0 0 8px;
    object-fit: contain;
}

.hnnp-search-empty-msg {
    margin: 0;
    color: #2B5ACD;
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.35;
}

.hnnp-search-empty-sub {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 12.5px;
    line-height: 1.4;
}

/* ── Mobile dropdown & form ────────────────────────────────── */
@media (max-width: 767px) {
    .hnnp-search-form {
        height: 36px;
        min-height: 36px;
    }

    .hnnp-search input.hnnp-search-input {
        font-size: 16px !important;
        padding: 0 6px 0 10px !important;
    }

    .hnnp-search button.hnnp-search-submit {
        flex-basis: 38px;
        width: 38px !important;
        min-width: 38px !important;
    }

    .hnnp-search-dropdown.is-fixed-mobile {
        position: fixed;
        left: 10px;
        right: 10px;
        width: auto;
        min-width: 0;
        border-radius: 12px;
    }

    .hnnp-search-sec-head {
        padding: 8px 12px;
        font-size: 12.5px;
    }

    .hnnp-search-chips {
        padding: 8px 12px 10px;
        gap: 5px;
    }

    .hnnp-search-chip {
        padding: 4px 10px;
        font-size: 12px;
    }

    .hnnp-search-cat-grid {
        padding: 6px 8px 8px;
        gap: 4px 6px;
    }

    .hnnp-search-cat-item {
        padding: 5px 6px;
        gap: 7px;
        font-size: 12px;
    }

    .hnnp-search-cat-thumb {
        flex-basis: 30px;
        width: 30px;
        height: 30px;
    }

    .hnnp-search-link {
        padding: 8px 12px;
        gap: 9px;
    }

    .hnnp-search-thumb {
        flex-basis: 44px;
        width: 44px;
        height: 44px;
    }

    .hnnp-search-name {
        font-size: 12.5px;
    }

    .hnnp-search-price {
        font-size: 13px;
    }
}

/* ── Trang kết quả tìm kiếm (gọn, chuẩn màu HNNP) ──────────── */
.hnnp-search-hero {
    background: #fff;
    padding: 8px 0 6px;
}

body.search .shop-area.section-padding {
    padding-top: 10px !important;
}

.hnnp-search-hero-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hnnp-search-crumb {
    display: flex;
    align-items: center;
    gap: 5px;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 12px;
    line-height: 1.3;
    color: #64748b;
    scrollbar-width: none;
}

.hnnp-search-crumb::-webkit-scrollbar {
    display: none;
}

.hnnp-search-crumb a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #192334 !important;
    font-weight: 500;
    text-decoration: none !important;
}

.hnnp-search-crumb a:hover {
    color: #2B5ACD !important;
}

.hnnp-search-crumb svg {
    width: 13.5px;
    height: 13.5px;
    flex: 0 0 auto;
}

.hnnp-search-crumb-sep {
    color: #cbd5e1;
}

.hnnp-search-crumb-cur {
    color: #64748b;
}

body .hnnp-search-hero h1.hnnp-search-hero-title {
    margin: 0 !important;
    color: #192334 !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    line-height: 1.35 !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
}

.hnnp-search-hero-title strong {
    color: #192334;
    font-weight: 700;
}

.hnnp-search-hero-title span {
    color: #2B5ACD;
}

.hnnp-search-cats-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.hnnp-search-cat-pill {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    padding: 5px 11px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f3f4f6;
    color: #334155 !important;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.25;
    text-decoration: none !important;
    white-space: nowrap;
    transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}

.hnnp-search-cat-pill:hover {
    border-color: #93b4ff;
    background: #f5f8ff;
    color: #2B5ACD !important;
}

.hnnp-search-cat-pill.is-active {
    border-color: #4A79FF;
    background: #eef3ff;
    color: #2B5ACD !important;
    font-weight: 600;
}

.hnnp-search-sort-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px 12px;
}

.hnnp-search-sort-label {
    color: #475569;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.3;
}

.hnnp-search-sort {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 1px;
    scrollbar-width: none;
}

.hnnp-search-sort::-webkit-scrollbar {
    display: none;
}

.hnnp-search-sort-pill {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 13px;
    border: 1px solid #eceef2;
    border-radius: 999px;
    background: #f5f6f8;
    color: #374151 !important;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.2;
    text-decoration: none !important;
    white-space: nowrap;
    transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}

.hnnp-search-sort-pill svg {
    width: 13.5px;
    height: 13.5px;
    flex: 0 0 auto;
}

.hnnp-search-sort-pill:hover {
    border-color: #c7d9ff;
    background: #f2f6ff;
    color: #2B5ACD !important;
}

.hnnp-search-sort-pill.is-active {
    border-color: #82abff;
    background: #eff5ff;
    color: #3264dc !important;
    font-weight: 600;
}

/* Trạng thái rỗng toàn trang tìm kiếm */
.hnnp-search-empty-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 520px;
    margin: 12px auto 28px;
    padding: 24px 18px;
    border: 1px solid #edf0f5;
    border-radius: 14px;
    background: #fff;
    text-align: center;
}

.hnnp-search-empty-img {
    display: block;
    width: 96px;
    height: 96px;
    margin: 0 0 10px;
    object-fit: contain;
}

.hnnp-search-empty-title {
    margin: 0;
    color: #2B5ACD;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
}

.hnnp-search-empty-desc {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 13px;
    line-height: 1.45;
}

.hnnp-search-empty-desc code {
    padding: 1px 5px;
    border-radius: 4px;
    background: #f1f5f9;
    color: #192334;
    font-size: 12px;
}

.hnnp-search-empty-cats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 14px;
}

@media (max-width: 767px) {
    .hnnp-search-hero {
        padding: 6px 0 4px;
    }

    body.search .shop-area.section-padding {
        padding-top: 8px !important;
    }

    .hnnp-search-hero-inner {
        gap: 6px;
    }

    body .hnnp-search-hero h1.hnnp-search-hero-title {
        font-size: 15px !important;
        line-height: 1.35 !important;
    }

    .hnnp-search-cats-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 1px;
        scrollbar-width: none;
    }

    .hnnp-search-cats-bar::-webkit-scrollbar {
        display: none;
    }

    .hnnp-search-cat-pill {
        padding: 4px 10px;
        font-size: 12px;
    }

    .hnnp-search-sort-row {
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 6px;
    }

    .hnnp-search-sort-label {
        flex: 0 0 auto;
        font-size: 12px;
    }

    .hnnp-search-sort-pill {
        padding: 4px 9px;
        font-size: 12px;
        gap: 4px;
    }

    .hnnp-search-sort-pill svg {
        width: 12.5px;
        height: 12.5px;
    }
}
