/* ==========================================================================
   DanielsHawaii WooCommerce Freetext Search — v2.0
   Consistent dh- prefix throughout, no global side-effects
   ========================================================================== */

/* ── Search form wrapper ────────────────────────────────────────────────── */
.dh-search-form {
    background: #fff;
    border: 1px solid #e4e4e4;
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .06);
    margin-bottom: 28px;
}

/* ── Rows ───────────────────────────────────────────────────────────────── */
.dh-sf-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}
.dh-sf-row:last-child { margin-bottom: 0; }

.dh-sf-row--main    { align-items: stretch; }
.dh-sf-row--filters { border-top: 1px solid #f0f0f0; padding-top: 14px; }
.dh-sf-row--actions { justify-content: flex-end; }

/* ── Shared input reset — high specificity to beat browser/theme defaults ── */
input.dh-sf-input,
select.dh-sf-input,
.dh-sf-input {
    display: block;
    width: 100%;
    min-height: 46px;
    padding: 0 14px;
    border: 1.5px solid #d0d0d0;
    border-radius: 8px;
    font-size: .95rem;
    font-family: inherit;
    line-height: 1.4;
    background: #f8f8f8;
    color: #111;
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
input.dh-sf-input:focus,
select.dh-sf-input:focus,
.dh-sf-input:focus {
    outline: none;
    border-color: #003459;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 52, 89, .1);
}

/* ── Search field — icon via real HTML element (not ::before) ────────────── */
.dh-sf-search-wrap {
    position: relative;
    flex: 2 1 240px;
}
.dh-sf-search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    color: #999;
    pointer-events: none;
    z-index: 1;
}
input.dh-sf-input--search {
    padding-left: 40px;
}

/* ── Island select — custom chevron ──────────────────────────────────────── */
.dh-sf-select--island,
select.dh-sf-select {
    flex: 1 1 170px;
    cursor: pointer;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
}

/* ── Filters row ─────────────────────────────────────────────────────────── */
.dh-sf-filter-group {
    flex: 1 1 160px;
    min-width: 140px;
}
.dh-sf-filter-group label {
    display: block;
    font-size: .78rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.dh-sf-inline {
    display: flex;
    gap: 8px;
}
/* Price min/max — equal width, same style as other inputs */
.dh-sf-inline input.dh-sf-input {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
}

/* ── Submit button ──────────────────────────────────────────────────────── */
.dh-search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 28px;
    border: none;
    border-radius: 8px;
    background: #f7ab4a;
    color: #fff;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .15s;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) and (pointer: fine) {
    .dh-search-btn:hover { background: #ec9b34; transform: translateY(-1px); }
}
.dh-search-btn:active  { transform: none; }
.dh-search-btn:focus-visible { outline: 3px solid #f7ab4a; outline-offset: 2px; }
.dh-search-btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ── Autocomplete dropdown ──────────────────────────────────────────────── */
.dh-autocomplete {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid #003459;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 9999;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .12);
}
.dh-autocomplete[hidden] { display: none; }

.dh-autocomplete__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f4f4f4;
    transition: background .12s;
}
.dh-autocomplete__item:last-child { border-bottom: none; }
.dh-autocomplete__item:hover,
.dh-autocomplete__item.is-active  { background: #f0f6ff; }

.dh-autocomplete__item img {
    width: 40px;
    height: 30px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}
.dh-autocomplete__item span { flex: 1; font-weight: 500; font-size: .9rem; }
.dh-autocomplete__item small { color: #888; font-size: .8rem; }

.dh-autocomplete__loading {
    padding: 10px 14px;
    color: #888;
    font-size: .875rem;
    font-style: italic;
}

/* ── Inline search (shortcode) ──────────────────────────────────────────── */
.dh-inline-search {
    position: relative;
    display: block;
    width: 100%;
}
.dh-inline-search-input {
    display: block;
    width: 100%;
    height: 46px;
    padding: 0 50px 0 14px;
    border: 1.5px solid rgba(0, 0, 0, .14);
    border-radius: 10px;
    font-size: .95rem;
    background: #fafafa;
    color: #111;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color .15s, background .15s;
}
.dh-inline-search-input:focus {
    outline: none;
    border-color: #003459;
    background: #fff;
}
.dh-inline-search-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    padding: 6px;
    cursor: pointer;
    color: #888;
    line-height: 1;
    transition: color .15s;
}
.dh-inline-search-btn:hover { color: #003459; }
.dh-inline-search .dh-autocomplete {
    left: 0;
    right: 0;
    top: calc(100% + 2px);
}

/* ── Loading skeleton ───────────────────────────────────────────────────── */
.dh-loading {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px 0;
}
.dh-loading__bar {
    height: 80px;
    border-radius: 8px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e4e4e4 50%, #f0f0f0 75%);
    background-size: 400% 100%;
    animation: dh-shimmer 1.4s ease infinite;
}
@keyframes dh-shimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* ── Search results container ───────────────────────────────────────────── */
.dh-search-results { margin-top: 4px; }

/* ── Quick navigation ───────────────────────────────────────────────────── */
.dh-search-nav {
    position: sticky;
    top: var(--dh-sticky-offset, 0px);
    z-index: 100;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    background: #003459;
    color: #fff;
    border-radius: 8px;
    margin-bottom: 24px;
    box-shadow: 0 4px 14px rgba(0, 52, 89, .25);
}
.dh-search-nav strong { font-size: .9rem; flex-shrink: 0; }
.dh-search-nav a {
    color: #fff;
    text-decoration: none;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: .85rem;
    font-weight: 500;
    background: rgba(255, 255, 255, .15);
    transition: background .15s;
    -webkit-tap-highlight-color: transparent;
}
.dh-search-nav a:hover { background: rgba(255, 255, 255, .3); }

/* ── Result group (island section) ─────────────────────────────────────── */
.dh-result-group {
    margin-bottom: 32px;
    scroll-margin-top: calc(var(--dh-sticky-offset, 130px) + 8px);
}
.dh-result-group__title {
    margin: 0 0 16px;
    padding-bottom: 10px;
    border-bottom: 3px solid #003459;
    font-size: 1.1rem;
    color: #003459;
    font-weight: 700;
}
.dh-result-group--other .dh-result-group__title {
    border-bottom-color: #aaa;
    color: #666;
}

/* ── Result card ────────────────────────────────────────────────────────── */
.dh-result {
    border: 1px solid #eaeaea;
    border-radius: 10px;
    background: #fff;
    margin-bottom: 14px;
    transition: box-shadow .18s, border-color .18s;
    contain: layout style;
}
@media (hover: hover) and (pointer: fine) {
    .dh-result:hover {
        box-shadow: 0 8px 28px rgba(0, 52, 89, .12);
        border-color: #003459;
    }
}
.dh-result__link {
    display: flex;
    gap: 0;
    text-decoration: none;
    color: inherit;
    border-radius: 10px;
    overflow: hidden;
}

/* ── Result image ───────────────────────────────────────────────────────── */
.dh-result__media {
    flex-shrink: 0;
    width: 160px;
}
.dh-result__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Result content ─────────────────────────────────────────────────────── */
.dh-result__content {
    flex: 1;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.dh-result__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #003459;
    line-height: 1.35;
}
.dh-result__desc {
    margin: 0;
    font-size: .875rem;
    color: #555;
    line-height: 1.55;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Offers / price ─────────────────────────────────────────────────────── */
.dh-result__offers { margin-top: auto; }
.dh-result__price {
    font-size: 1.15rem;
    font-weight: 700;
    color: #f7ab4a;
}

/* ── Meta row (rating + duration) ──────────────────────────────────────── */
.dh-result__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    font-size: .8rem;
    color: #666;
}
.dh-result__stars { color: #f7ab4a; letter-spacing: 1px; }
.dh-result__rating { display: flex; align-items: center; gap: 4px; }
.dh-result__duration { display: flex; align-items: center; gap: 3px; }

/* ── Flags ──────────────────────────────────────────────────────────────── */
.dh-result__flags { display: flex; flex-wrap: wrap; gap: 6px; }
.dh-result__flag {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 3px 10px;
    border-radius: 20px;
    background: #003459;
    color: #fff;
}
.dh-result__flag--featured  { background: #f7ab4a; color: #fff; }
.dh-result__flag--on-sale   { background: #28a745; color: #fff; }

/* ── Empty / error states ───────────────────────────────────────────────── */
.dh-search-no-results,
.dh-search-error {
    text-align: center;
    padding: 32px 20px;
    font-size: .95rem;
    border-radius: 8px;
}
.dh-search-no-results { color: #666; }
.dh-search-error {
    color: #c62828;
    background: #ffebee;
    border: 1px solid #ffcdd2;
}

/* ── Mobile ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .dh-sf-filter-group {
        flex: 0 0 100px;
        min-width: 140px;
    }
}

@media (max-width: 640px) {
    .dh-search-form { padding: 14px; }

    /* Force filter groups side-by-side at exactly half-row width */
    .dh-sf-filter-group {
        flex: 1 1 calc(50% - 5px);
        min-width: 0;
    }

    .dh-search-btn { width: 100%; }

    .dh-result__link { flex-direction: column; }

    .dh-result__media {
        width: 100%;
        height: 160px;
    }

    .dh-result__content { padding: 12px 14px; }

    .dh-result__title { font-size: .95rem; }

    .dh-search-nav {
        flex-wrap: nowrap;
        max-width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .dh-search-nav::-webkit-scrollbar { display: none; }
}
