/* ==========================================================================
   Hira Search — search.css
   Brand colour: #2f6fed (Hira blue)
   ========================================================================== */

:root {
    --hsr-accent:      #2f6fed;
    --hsr-accent-dark: #1e5bc6;
    --hsr-hover-bg:    #eef4fb;
    --hsr-radius:      8px;
    --hsr-shadow:      0 8px 24px rgba(47,111,237,.15);
    --hsr-border:      #d3dce6;
    --hsr-text:        #14304f;
    --hsr-muted:       #8a97a6;
    --hsr-white:       #ffffff;
}

/* --------------------------------------------------------------------------
   Wrapper
   -------------------------------------------------------------------------- */

.hsr-wrap {
    position: relative;
    font-family: inherit;
    color: var(--hsr-text);
    width: 100%;
}

/* --------------------------------------------------------------------------
   Search Row (input + button)
   -------------------------------------------------------------------------- */

.hsr-search-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.hsr-input-wrap {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.hsr-search-input {
    width: 100%;
    height: 44px;
    padding: 0 72px 0 14px;
    border: 1.5px solid var(--hsr-border);
    border-radius: var(--hsr-radius);
    font-size: 15px;
    color: var(--hsr-text);
    background: var(--hsr-white);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.hsr-search-input:focus {
    border-color: var(--hsr-accent);
    box-shadow: 0 0 0 3px rgba(47,111,237,.15);
}

.hsr-search-input::-webkit-search-cancel-button {
    display: none;
}

/* Clear button */
.hsr-clear-btn {
    position: absolute;
    right: 38px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--hsr-muted);
    line-height: 1;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.15s, background-color 0.15s;
}

.hsr-clear-btn:hover {
    color: var(--hsr-text);
    background-color: #eef2f7;
}

/* Spinner */
.hsr-spinner {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    border: 2px solid #e6ebf1;
    border-top-color: var(--hsr-accent);
    border-radius: 50%;
    animation: hsr-spin 0.7s linear infinite;
}

@keyframes hsr-spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Search Button */
.hsr-search-btn {
    height: 44px;
    padding: 0 16px;
    background-color: var(--hsr-accent);
    color: var(--hsr-white);
    border: none;
    border-radius: var(--hsr-radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.hsr-search-btn:hover {
    background-color: var(--hsr-accent-dark);
}

.hsr-search-btn svg {
    display: block;
}

/* --------------------------------------------------------------------------
   Filters Bar
   -------------------------------------------------------------------------- */

.hsr-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.hsr-filter-select,
.hsr-filter-input {
    height: 36px;
    padding: 0 10px;
    border: 1.5px solid var(--hsr-border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--hsr-text);
    background: var(--hsr-white);
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.hsr-filter-select:focus,
.hsr-filter-input:focus {
    border-color: var(--hsr-accent);
    box-shadow: 0 0 0 2px rgba(47,111,237,.1);
}

.hsr-filter-select {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.hsr-filter-price {
    display: flex;
    align-items: center;
    gap: 6px;
}

.hsr-filter-price .hsr-filter-input {
    width: 80px;
}

.hsr-price-sep {
    color: var(--hsr-muted);
    font-size: 13px;
}

/* --------------------------------------------------------------------------
   Results Dropdown
   -------------------------------------------------------------------------- */

.hsr-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--hsr-white);
    border: 1px solid #e6ebf1;
    border-radius: 10px;
    box-shadow: var(--hsr-shadow);
    z-index: 9999;
    max-height: 480px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Scrollbar styling */
.hsr-results::-webkit-scrollbar {
    width: 6px;
}

.hsr-results::-webkit-scrollbar-track {
    background: #f4f8fc;
}

.hsr-results::-webkit-scrollbar-thumb {
    background: #d3dce6;
    border-radius: 3px;
}

/* --------------------------------------------------------------------------
   Result Items
   -------------------------------------------------------------------------- */

.hsr-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #eef2f7;
    transition: background-color 0.15s;
    cursor: pointer;
    outline: none;
}

.hsr-result-item:last-child {
    border-bottom: none;
}

.hsr-result-item:hover,
.hsr-result-item.hsr-active {
    background-color: var(--hsr-hover-bg);
}

/* Thumbnail */
.hsr-result-thumb {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 6px;
    overflow: hidden;
    background: #f4f8fc;
    border: 1px solid #e6ebf1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hsr-result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Content */
.hsr-result-content {
    flex: 1;
    min-width: 0;
}

.hsr-result-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--hsr-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
    margin-bottom: 2px;
}

.hsr-result-title mark {
    background: rgba(47,111,237,.15);
    color: var(--hsr-accent);
    border-radius: 2px;
    padding: 0 1px;
}

.hsr-result-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.hsr-result-price {
    font-size: 13px;
    font-weight: 600;
    color: var(--hsr-accent);
}

.hsr-result-price .woocommerce-Price-amount {
    color: var(--hsr-accent);
}

.hsr-result-price del {
    color: var(--hsr-muted);
    font-weight: 400;
}

.hsr-result-sku {
    font-size: 11px;
    color: var(--hsr-muted);
    font-family: monospace;
}

/* Rating */
.hsr-result-rating {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    color: #f59e0b;
}

.hsr-result-rating span {
    color: var(--hsr-muted);
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */

.hsr-badge {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1.4;
    color: #fff;
    white-space: nowrap;
}

.hsr-badge-sale {
    background-color: #ef4444;
}

.hsr-badge-stock {
    background-color: #22c55e;
}

.hsr-badge-stock.hsr-out-stock {
    background-color: #9ca3af;
}

/* --------------------------------------------------------------------------
   No Results / Status Messages
   -------------------------------------------------------------------------- */

.hsr-no-results,
.hsr-searching-msg {
    padding: 20px 16px;
    text-align: center;
    color: var(--hsr-muted);
    font-size: 14px;
}

.hsr-no-results svg,
.hsr-searching-msg svg {
    display: block;
    margin: 0 auto 8px;
    opacity: 0.4;
}

/* --------------------------------------------------------------------------
   View All Link
   -------------------------------------------------------------------------- */

.hsr-view-all-wrap {
    border-top: 1px solid #eef2f7;
    padding: 8px 12px;
}

.hsr-view-all {
    display: block;
    width: 100%;
    padding: 9px 14px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--hsr-accent);
    background-color: var(--hsr-hover-bg);
    border-radius: 6px;
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
}

.hsr-view-all:hover {
    background-color: #dce8fb;
    color: var(--hsr-accent-dark);
    text-decoration: none;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media ( max-width: 640px ) {
    .hsr-search-row {
        flex-direction: column;
        gap: 6px;
    }

    .hsr-search-btn {
        width: 100%;
        height: 40px;
        justify-content: center;
        gap: 6px;
    }

    .hsr-search-input {
        height: 40px;
        font-size: 14px;
    }

    .hsr-filters {
        flex-direction: column;
    }

    .hsr-filter-select,
    .hsr-filter-price {
        width: 100%;
    }

    .hsr-filter-price .hsr-filter-input {
        flex: 1;
        width: auto;
    }

    .hsr-results {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 16px 16px 0 0;
        max-height: 65vh;
        box-shadow: 0 -4px 20px rgba(0,0,0,.12);
    }

    .hsr-result-item {
        padding: 10px 12px;
    }
}

@media ( max-width: 400px ) {
    .hsr-result-thumb {
        width: 42px;
        height: 42px;
    }
}
