/* ============================================================
   Global Live Search — homepage search bar + results dropdown
   Markup: resources/views/website/partials/global-search.blade.php
   Scoped under .gsearch so it cannot affect existing site styles.
   ============================================================ */
.gsearch-wrap {
    --gs-orange: #ff6900;
    --gs-orange-2: #ff8a33;
    --gs-ink: #1c2430;
    --gs-muted: #6b7280;
    --gs-line: #ececf1;
    --gs-bg: #ffffff;
    /* Centered inside the banner hero (below the headline + subtitle). */
    margin: 0 auto 26px;
    max-width: 720px;
}

.gsearch {
    position: relative;
    max-width: 720px;
    margin: 0 auto;
    text-align: left;
    font-family: 'Roboto', 'Segoe UI', sans-serif;
}

/* ---------- Heading above the bar ---------- */
.gsearch-heading {
    margin: 0 0 12px;
}

.gsearch-heading__title {
    margin: 0;
    font-size: clamp(20px, 2.3vw, 26px);
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--gs-ink);
}

.gsearch-heading__title span { color: var(--gs-orange); }

.gsearch-heading__sub {
    margin: 5px 0 0;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--gs-muted);
}

/* ---------- Input box ---------- */
.gsearch__box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--gs-bg);
    border: 1.5px solid #ff8a3d;
    border-radius: 999px;
    padding: 6px 6px 6px 20px;
    box-shadow: 0 6px 20px rgba(255, 106, 19, 0.12), 0 2px 8px rgba(16, 24, 40, 0.05);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gsearch__box:hover { border-color: #ffd3b3; }

.gsearch__box:focus-within {
    border-color: var(--gs-orange);
    box-shadow: 0 14px 34px rgba(255, 105, 0, 0.20);
}

.gsearch__box:focus-within {
    border-color: var(--gs-orange);
    box-shadow: 0 10px 30px rgba(255, 105, 0, 0.18);
}

.gsearch__icon {
    flex: 0 0 22px;
    width: 22px;
    height: 22px;
    color: var(--gs-orange);
}

.gsearch__input {
    flex: 1 1 auto;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    color: var(--gs-ink);
    padding: 12px 0;
}

.gsearch__input::placeholder { color: #9aa3b2; }

/* Hide native search clear (we have our own) */
.gsearch__input::-webkit-search-cancel-button { -webkit-appearance: none; }

.gsearch__spinner {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 105, 0, 0.25);
    border-top-color: var(--gs-orange);
    border-radius: 50%;
    animation: gs-spin 0.7s linear infinite;
    display: none;
}

.gsearch.is-loading .gsearch__spinner { display: inline-block; }

@keyframes gs-spin { to { transform: rotate(360deg); } }

.gsearch__clear {
    flex: 0 0 auto;
    display: none;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 50%;
    background: #f1f3f7;
    color: #6b7280;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.gsearch__clear:hover { background: #ffe3cf; color: var(--gs-orange); }
.gsearch.has-value .gsearch__clear { display: inline-flex; }

/* ---------- Search button (right) ---------- */
.gsearch__submit {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--gs-orange-2), var(--gs-orange));
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    padding: 11px 26px;
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(255, 105, 0, 0.25);
    transition: filter 0.2s ease, transform 0.08s ease;
}

.gsearch__submit:hover { filter: brightness(1.06); color: #fff; }
.gsearch__submit:active { transform: translateY(1px); }
.gsearch__submit:focus-visible { outline: 3px solid rgba(255, 105, 0, 0.35); outline-offset: 2px; }

.gsearch__submit-icon { display: none; width: 20px; height: 20px; } /* text label on desktop/tablet */

/* ---------- Results dropdown ---------- */
.gsearch__panel {
    /* Fixed so the hero's overflow:hidden can't clip it; JS sets top/left/width. */
    position: fixed;
    z-index: 2000;
    background: var(--gs-bg);
    border: 1px solid var(--gs-line);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(16, 24, 40, 0.16);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}

.gsearch.is-open .gsearch__panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.gsearch__results {
    max-height: min(70vh, 460px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.gsearch__group-label {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fafafc;
    color: var(--gs-orange);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 9px 16px;
    border-bottom: 1px solid var(--gs-line);
}

.gsearch__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--gs-ink);
    border-bottom: 1px solid #f4f5f8;
    cursor: pointer;
}

.gsearch__item:last-child { border-bottom: none; }
.gsearch__item:hover,
.gsearch__item.is-active {
    background: #fff4ec;
    color: var(--gs-ink);
    text-decoration: none;
}

.gsearch__thumb {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
    background: #f1f3f7;
    border: 1px solid var(--gs-line);
}

.gsearch__thumb--fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 17px;
    border: none;
    background: linear-gradient(135deg, var(--gs-orange-2), var(--gs-orange));
    text-transform: uppercase;
}

.gsearch__text { min-width: 0; flex: 1 1 auto; }

.gsearch__title {
    display: block;
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gsearch__title mark {
    background: #ffe8cf;
    color: inherit;
    padding: 0 1px;
    border-radius: 3px;
}

.gsearch__desc {
    display: block;
    margin-top: 1px;
    font-size: 12.5px;
    color: var(--gs-muted);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gsearch__badge {
    flex: 0 0 auto;
    align-self: center;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--gs-orange);
    background: #fff1e6;
    border: 1px solid #ffd9bd;
    border-radius: 999px;
    padding: 3px 9px;
    white-space: nowrap;
}

/* ---------- States (no-results / error) — compact ---------- */
.gsearch__state {
    padding: 16px 16px;
    text-align: center;
    color: var(--gs-muted);
    font-size: 12.5px;
    line-height: 1.4;
}

.gsearch__state svg {
    width: 24px;
    height: 24px;
    color: #c7ccd6;
    margin-bottom: 4px;
}

.gsearch__state strong { color: var(--gs-ink); display: block; font-size: 13.5px; margin-bottom: 1px; }

/* ---------- Tablet ---------- */
@media (min-width: 576px) and (max-width: 991.98px) {
    .gsearch { max-width: 600px; }
    .gsearch__submit { padding: 11px 22px; }
}

/* ---------- Mobile ---------- */
@media (max-width: 575.98px) {
    .gsearch-wrap { margin: 14px 0 6px; }
    .gsearch { max-width: 100%; }
    .gsearch__box { gap: 6px; padding: 5px 5px 5px 14px; }
    .gsearch__icon { flex-basis: 20px; width: 20px; height: 20px; }
    .gsearch__input { font-size: 15px; padding: 10px 0; }
    .gsearch__results { max-height: 62vh; }
    .gsearch__thumb { flex-basis: 40px; width: 40px; height: 40px; }
    .gsearch__badge { display: none; } /* keep rows tidy on small screens */
    .gsearch__desc { white-space: normal; }

    /* Compact icon-only Search button to save width on phones */
    .gsearch__submit { padding: 0; width: 42px; height: 42px; border-radius: 50%; }
    .gsearch__submit-text { display: none; }
    .gsearch__submit-icon { display: block; }
}

/* ---------- Very narrow phones ---------- */
@media (max-width: 360px) {
    .gsearch__submit { width: 38px; height: 38px; }
    .gsearch__clear { width: 26px; height: 26px; }
}

@media (prefers-reduced-motion: reduce) {
    .gsearch__panel,
    .gsearch__box { transition: none; }
    .gsearch__spinner { animation-duration: 1.4s; }
}
