/**
 * Tiger Search — complete front-end stylesheet.
 *
 * Strategy: targeted per-element resets instead of blanket `all: unset` on
 * .tg-search-wrap button (which was fighting specificity with .tg-search__submit).
 * Each component resets only what it needs and re-declares its own styles.
 */

/* ═══════════════════════════════════════════════════════
   BOX-SIZING ISOLATION
═══════════════════════════════════════════════════════ */

.tg-search-wrap *,
.tg-search-wrap *::before,
.tg-search-wrap *::after,
.tg-search-popup *,
.tg-search-popup *::before,
.tg-search-popup *::after {
    box-sizing: border-box;
}

/* ═══════════════════════════════════════════════════════
   WRAPPER
═══════════════════════════════════════════════════════ */

.tg-search-wrap {
    position: relative;
    display: flex;
    align-items: stretch;
    max-width: 100%;
    gap: 8px;           /* gap between form + outside button */
}
.tg-search-wrap--inline { width: 100%; }
.tg-search-wrap--popup  { display: inline-flex; }

/* ═══════════════════════════════════════════════════════
   INLINE — FORM
═══════════════════════════════════════════════════════ */

.tg-search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

/* Magnifier icon */
.tg-search__icon-wrap {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    pointer-events: none;
    color: #9ca3af;
    z-index: 1;
    font-size: 16px;
    transition: color .18s;
}
.tg-search__icon-wrap svg { width: 1em; height: 1em; }
/* Icon turns accent on focus — using focus-within since icon precedes input in DOM */
.tg-search:focus-within .tg-search__icon-wrap { color: #ec7002; }

/* Input */
/* `.tg-search-wrap` ancestor raises specificity to 0,2,0 so it beats a theme
   reset like `input[type="search"]{padding:.5rem 1rem}` (0,1,1) that would
   otherwise clobber the 44px left padding reserved for the search icon. */
.tg-search-wrap .tg-search__input {
    display: block;
    width: 100%;
    height: 48px;
    padding: 0 18px;
    /* Left clearance for the absolutely-positioned search icon. !important on
       JUST the left so a theme reset (e.g. input[type=search]{padding:.5rem 1rem})
       can't push the placeholder under the icon. Right/top/bottom stay normal so
       the native-inside right-padding reset and the user's Padding control still win. */
    padding-left: 44px !important;
    border: 1.5px solid #e5e7eb;
    border-radius: 999px;
    background: #ffffff;
    color: #111827;
    font: inherit;
    font-size: .94rem;
    line-height: 1.4;
    outline: none;
    transition: border-color .18s, box-shadow .18s, background .18s;
    -webkit-appearance: none;
    appearance: none;
}
.tg-search__input::placeholder { color: #9ca3af; }
.tg-search__input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.tg-search__input:focus {
    border-color: #ec7002;
    box-shadow: 0 0 0 2px rgba(236,112,2,.16);
}

/* ── Search icon: right-positioned variant ── */
.tg-search--icon-right .tg-search__icon-wrap {
    left: auto;
    right: 14px;
}
/* Higher specificity (0,3,0) than the base padding rule so the clearance flips
   to the correct side. */
.tg-search-wrap .tg-search--icon-right .tg-search__input {
    padding-left: 18px !important;
    padding-right: 44px !important;
}

/* ── Search icon hidden: reclaim the reserved clearance ── */
.tg-search-wrap .tg-search--icon-hidden .tg-search__input {
    padding-left: 18px !important;
}
.tg-search-wrap .tg-search--icon-hidden.tg-search--icon-right .tg-search__input {
    padding-right: 18px !important;
}

/* ── Native "inside" — input + button share one pill ── */
.tg-search--native-inside {
    border-radius: 999px;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    transition: border-color .18s, box-shadow .18s;
    overflow: hidden;
}
.tg-search--native-inside:focus-within {
    border-color: #ec7002;
    box-shadow: 0 0 0 2px rgba(236,112,2,.16);
}
.tg-search--native-inside .tg-search__input {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    padding-right: 12px;
}
.tg-search--native-inside .tg-search__submit {
    border: none !important;
    border-left: 1.5px solid rgba(15,23,42,.10) !important;
    margin: 5px 5px 5px 0;
    height: calc(100% - 10px);
    border-radius: 999px !important;
    font-size: .875rem;
    padding: 0 18px;
}

/* ── Native "outside" — normal pill input, button separate ── */
.tg-search--native-outside .tg-search__input {
    border-radius: 999px;
}

/* ═══════════════════════════════════════════════════════
   SUBMIT BUTTON (native)
═══════════════════════════════════════════════════════ */

.tg-search__submit {
    /* Reset first — targeted, not blanket */
    -webkit-appearance: none;
    appearance: none;
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
    /* Actual styles */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 48px;
    padding: 0 22px;
    background-color: #ec7002;
    color: #ffffff;
    border: 1.5px solid #ec7002;
    font-size: .9rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color .15s, border-color .15s, box-shadow .15s;
    flex-shrink: 0;
    line-height: 1;
}
.tg-search__submit:hover {
    background-color: #d2630a;
    border-color: #d2630a;
}
.tg-search__submit:active {
    background-color: #b85608;
    border-color: #b85608;
    transform: scale(.97);
}
.tg-search__submit:focus-visible {
    outline: 2px solid #ec7002;
    outline-offset: 2px;
}

/* Submit icon SVG */
.tg-search__submit-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    font-size: 15px;
    line-height: 0;
}
.tg-search__submit-icon svg { width: 1em; height: 1em; }

/* Outside: button is a separate pill */
.tg-search-wrap--btn-outside .tg-search__submit {
    border-radius: 999px;
    flex-shrink: 0;
    align-self: stretch;
    height: auto;
}

/* Popup native: full-width button */
.tg-search-popup__native-form .tg-search__submit {
    width: 100%;
    height: 52px;
    border-radius: 14px;
    font-size: 1rem;
    border: none;
}

/* ═══════════════════════════════════════════════════════
   INLINE RESULTS DROPDOWN
═══════════════════════════════════════════════════════ */

.tg-search__results {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,.08);
    box-shadow:
        0 1px 0 rgba(0,0,0,.04),
        0 4px 12px rgba(15,23,42,.07),
        0 20px 52px rgba(15,23,42,.13);
    max-height: min(70vh, 480px);
    overflow-y: auto;
    z-index: 1001;
    overscroll-behavior: contain;
    padding: 4px 0;
    /* Entrance micro-animation */
    animation: tg-results-in .14s ease both;
}
@keyframes tg-results-in {
    from { opacity: 0; transform: translateY(-6px) scale(.99); }
    to   { opacity: 1; transform: translateY(0)    scale(1);   }
}
.tg-search__results[hidden] { display: none; }
/* Custom scrollbar */
.tg-search__results::-webkit-scrollbar { width: 5px; }
.tg-search__results::-webkit-scrollbar-track { background: transparent; }
.tg-search__results::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 3px; }
.tg-search__results::-webkit-scrollbar-thumb:hover { background: #d1d5db; }

/* ═══════════════════════════════════════════════════════
   STATUS / LOADING / EMPTY
═══════════════════════════════════════════════════════ */

.tg-search__status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    color: #9ca3af;
    font-size: .9em;
    text-align: center;
}
.tg-search__status.is-loading::before {
    content: '';
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #e5e7eb;
    border-top-color: #ec7002;
    animation: tg-spin .65s linear infinite;
}
@keyframes tg-spin { to { transform: rotate(360deg); } }

.tg-search__empty {
    padding: 40px 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.tg-search__empty-icon { color: #d1d5db; display: flex; }
.tg-search__empty-icon svg { width: 36px; height: 36px; }
.tg-search__empty-msg { color: #9ca3af; font-size: .9rem; margin: 0; }

/* ═══════════════════════════════════════════════════════
   RESULT ITEMS
═══════════════════════════════════════════════════════ */

.tg-search__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none !important;
    color: inherit;
    border-radius: 10px;
    margin: 1px 4px;
    transition: background-color .12s;
    cursor: pointer;
}
.tg-search__item:hover,
.tg-search__item.is-active     { background-color: #f5f3ff; }

/* Thumbnail */
.tg-search__item-thumb {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    overflow: hidden;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.tg-search__item-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tg-search__item-thumb--icon { color: #d1d5db; }
.tg-search__item-thumb--icon svg { width: 20px; height: 20px; }

/* Body */
.tg-search__item-body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1;
}
.tg-search__item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.tg-search__item-type {
    display: inline-block;
    font-size: .67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: #ec7002;
    background: #fff1e6;
    padding: 2px 7px;
    border-radius: 5px;
    flex-shrink: 0;
    line-height: 1.5;
}
.tg-search__item-price {
    font-weight: 700;
    color: #059669;
    font-size: .82rem;
    margin-left: auto;
}
.tg-search__item-title {
    color: #111827;
    font-weight: 600;
    font-size: .9rem;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tg-search__item-excerpt {
    color: #6b7280;
    font-size: .82rem;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hover arrow */
.tg-search__item-arrow {
    flex-shrink: 0;
    color: #ec7002;
    opacity: 0;
    transform: translateX(-5px);
    transition: opacity .12s, transform .12s;
    display: flex;
    align-items: center;
}
.tg-search__item:hover .tg-search__item-arrow,
.tg-search__item.is-active .tg-search__item-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* Keyword highlight */
.tg-search__hl {
    background: #fff1e6;
    color: #b85608;
    padding: 0 2px;
    border-radius: 3px;
}

/* View all */
.tg-search__view-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 4px 4px 4px;
    padding: 10px 16px;
    font-weight: 600;
    font-size: .875rem;
    color: #ec7002 !important;
    text-decoration: none !important;
    border-top: 1px solid rgba(0,0,0,.05);
    border-radius: 0 0 12px 12px;
    background: #fafafa;
    transition: background .12s, color .12s;
}
.tg-search__view-all:hover { background: #fff1e6; color: #b85608 !important; }
.tg-search__view-all-icon { display: flex; align-items: center; opacity: .6; }
.tg-search__view-all-icon svg { width: 14px; height: 14px; }

/* ═══════════════════════════════════════════════════════
   POPUP — TRIGGER BUTTON
═══════════════════════════════════════════════════════ */

.tg-search-trigger {
    /* Per-element reset — avoids blanket reset fighting specificity */
    -webkit-appearance: none;
    appearance: none;
    border: none;
    padding: 0;
    margin: 0;
    background: none;
    font: inherit;
    cursor: pointer;
    /* Actual trigger styles */
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px 9px 12px;
    background-color: #ffffff;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    color: #374151;
    font-size: .875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: border-color .15s, box-shadow .15s, background-color .15s, color .15s;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    line-height: 1;
    text-decoration: none;
}
.tg-search-trigger:hover {
    border-color: #a5b4fc;
    background-color: #fff6ef;
    color: #ec7002;
    box-shadow: 0 1px 8px rgba(236,112,2,.15);
}
.tg-search-trigger:focus-visible {
    outline: 2px solid #ec7002;
    outline-offset: 2px;
}

.tg-search-trigger__icon {
    display: flex;
    align-items: center;
    font-size: 1.1em;
    flex-shrink: 0;
    color: #6b7280;
    transition: color .15s;
}
.tg-search-trigger__icon svg { width: 1em; height: 1em; }
.tg-search-trigger:hover .tg-search-trigger__icon { color: #ec7002; }

.tg-search-trigger__label { flex: 1; text-align: left; }

/* Shortcut badge */
.tg-search-trigger__shortcut {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: 4px;
    padding: 3px 8px;
    font-size: .7rem;
    font-weight: 600;
    color: #9ca3af;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    line-height: 1.3;
    pointer-events: none;
    white-space: nowrap;
    letter-spacing: .02em;
    transition: background .15s, border-color .15s, color .15s;
}
.tg-search-trigger:hover .tg-search-trigger__shortcut {
    background: #fff1e6;
    border-color: #c4b5fd;
    color: #6d28d9;
}

/* ═══════════════════════════════════════════════════════
   POPUP — OVERLAY + PANEL
═══════════════════════════════════════════════════════ */

.tg-search-popup {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(40px, 8vh, 100px) 16px 16px;
    box-sizing: border-box;
}
.tg-search-popup[hidden] { display: none; }

/* Blurred backdrop */
.tg-search-popup__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2,6,23,.5);
    backdrop-filter: blur(8px) saturate(1.6);
    -webkit-backdrop-filter: blur(8px) saturate(1.6);
    opacity: 0;
    transition: opacity .22s ease;
}
.tg-search-popup.is-open .tg-search-popup__backdrop { opacity: 1; }

/* Panel */
.tg-search-popup__panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 640px;
    min-height: 260px;
    background: #ffffff;
    border-radius: 18px;
    box-shadow:
        0 0 0 1px rgba(0,0,0,.06),
        0 8px 24px rgba(2,6,23,.1),
        0 32px 80px rgba(2,6,23,.26);
    display: flex;
    flex-direction: column;
    max-height: min(82vh, 700px);
    overflow: hidden;
    /* Entrance */
    opacity: 0;
    transform: scale(.95) translateY(-14px);
    transition: opacity .22s ease, transform .26s cubic-bezier(.32,.72,0,1);
    will-change: transform, opacity;
}
.tg-search-popup.is-open .tg-search-popup__panel {
    opacity: 1;
    transform: scale(1) translateY(0);
}

/* ── Panel header (input row) ── */
.tg-search-popup__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 12px 2px 18px;
    border-bottom: 1.5px solid #f0f0f5;
    flex-shrink: 0;
    background: #ffffff;
    min-height: 62px;
}

/* Search icon inside popup header */
.tg-search-popup__search-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    color: #ec7002;
    font-size: 18px;
    pointer-events: none;
    transition: color .18s;
}
.tg-search-popup__search-icon svg { width: 1em; height: 1em; }

/* Override base .tg-search__input inside popup */
.tg-search-popup__header .tg-search__input {
    flex: 1;
    min-width: 0;
    width: 100%;
    height: auto;
    border: none !important;
    border-radius: 0 !important;
    padding: 18px 0 !important;
    font-size: 1.05rem !important;
    font-weight: 500 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #111827 !important;
    line-height: 1.4 !important;
}
.tg-search-popup__header .tg-search__input:focus,
.tg-search-popup__header .tg-search__input:focus-visible,
.tg-search-popup__header .tg-search__input:active,
.tg-search-popup__header .tg-search__input:hover {
    outline: none !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
}
/* Themes commonly style inputs with an outline / native search chrome that the
   base reset above (border + background only) doesn't cover — that rendered as a
   stray rounded box around the popup field. Neutralise the native decoration and
   any inherited outline in every state. */
.tg-search-popup__header .tg-search__input {
    -webkit-appearance: none;
    appearance: none;
    outline: none !important;
    outline-offset: 0 !important;
    margin: 0 !important;
}
.tg-search-popup__header .tg-search__input::-webkit-search-decoration,
.tg-search-popup__header .tg-search__input::-webkit-search-cancel-button,
.tg-search-popup__header .tg-search__input::-webkit-search-results-button,
.tg-search-popup__header .tg-search__input::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

/* ── Close button — targeted reset, not blanket ── */
.tg-search-popup__close {
    -webkit-appearance: none;
    appearance: none;
    background: none;
    border: none;
    margin: 0;
    font: inherit;
    cursor: pointer;
    /* Actual styles */
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    padding: 6px 9px;
    background-color: #f3f4f6;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    color: #6b7280;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    transition: background-color .13s, border-color .13s, color .13s;
}
.tg-search-popup__close:hover {
    background-color: #fee2e2;
    border-color: #fca5a5;
    color: #dc2626;
}
.tg-search-popup__close:focus-visible {
    outline: 2px solid #ec7002;
    outline-offset: 2px;
}
.tg-search-popup__esc-badge {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .03em;
    line-height: 1;
    color: inherit;
}
.tg-search-popup__close-icon {
    display: flex;
    align-items: center;
    font-size: 13px;
}
.tg-search-popup__close-icon svg { width: 1em; height: 1em; }

/* ── Results area ── */
.tg-search__results--popup {
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    border: none !important;
    max-height: none !important;
    animation: none !important;

    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    min-height: 0;
    display: block !important;
    padding: 4px 0;
}
/* Custom scrollbar */
.tg-search__results--popup::-webkit-scrollbar { width: 5px; }
.tg-search__results--popup::-webkit-scrollbar-track { background: transparent; }
.tg-search__results--popup::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 3px; }
.tg-search__results--popup::-webkit-scrollbar-thumb:hover { background: #d1d5db; }

/* Popup items slightly larger */
.tg-search__results--popup .tg-search__item { padding: 11px 14px; margin: 1px 6px; }
.tg-search__results--popup .tg-search__item-thumb { flex-basis: 48px; width: 48px; height: 48px; }

/* ── Placeholder (before any query) ── */
.tg-search__placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    min-height: 190px;
    text-align: center;
    gap: 16px;
}
.tg-search__placeholder-icon {
    width: 58px;
    height: 58px;
    background: linear-gradient(135deg, #fff1e6 0%, #cfe6ea 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ec7002;
    font-size: 26px;
}
.tg-search__placeholder-icon svg { width: 1em; height: 1em; }
.tg-search__placeholder p {
    margin: 0;
    font-size: .9rem;
    color: #9ca3af;
    font-weight: 500;
}

/* ── Native popup body ── */
.tg-search-popup__native-body {
    padding: 20px 20px 24px;
    display: flex;
    flex-direction: column;
}
.tg-search-popup__native-form { display: flex; flex-direction: column; }

/* ── Footer keyboard hints ── */
.tg-search-popup__footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-top: 1.5px solid #f0f0f5;
    background: #fafafa;
    flex-shrink: 0;
}
.tg-search-popup__hint {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .71rem;
    color: #9ca3af;
    white-space: nowrap;
    font-family: inherit;
}
/* kbd elements inside footer — targeted reset */
.tg-search-popup__footer kbd {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    padding: 2px 5px;
    font-size: .8em;
    font-family: inherit;
    font-weight: 700;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 5px;
    color: #6b7280;
    line-height: 1.4;
    box-shadow: none;
    text-shadow: none;
}
/* Hint separator dot */
.tg-search-popup__sep {
    display: inline-block;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #d1d5db;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════
   MISC
═══════════════════════════════════════════════════════ */

/* Lock scroll when popup is open */
body.tg-search-popup-open { overflow: hidden; }

/* ═══════════════════════════════════════════════════════
   MOBILE — bottom-sheet popup
═══════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .tg-search-popup {
        padding: 0;
        align-items: flex-end;
    }
    .tg-search-popup__panel {
        max-width: 100%;
        min-height: 240px;
        border-radius: 22px 22px 0 0;
        transform: translateY(32px);
        transition: opacity .2s ease, transform .26s cubic-bezier(.32,.72,0,1);
    }
    .tg-search-popup.is-open .tg-search-popup__panel { transform: translateY(0); }
    /* Drag handle pill */
    .tg-search-popup__header {
        position: relative;
        padding-top: 22px;
    }
    .tg-search-popup__header::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 38px;
        height: 4px;
        background: #e5e7eb;
        border-radius: 2px;
    }
    .tg-search-popup__footer { display: none; }
    .tg-search-trigger__shortcut { display: none; }
}
