
/* === 검색 모달 v5 — fullscreen + 흰 backdrop + brand pink ===
   --bf-search-brand: #ff5a8a (보자기카드 brand pink, chatbot 와 일관)
   --bf-search-brand-2: #ff3c70 (gradient end)
   레이아웃: fullscreen modal + 흰 살짝 비치는 backdrop + center content */
.bf-search-modal { position: fixed; inset: 0; z-index: 2147483646;
    font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    /* v6: 보자기카드 brand color = #1b2631 (dark navy, 헤더 톤). 핑크 → dark navy 정돈 */
    --bf-search-brand: #1b2631;
    --bf-search-brand-2: #2a3441;
    --bf-search-brand-soft: rgba(27,38,49,0.05);
    --bf-search-brand-deep: #0f1419; }
.bf-search-modal.open { display: block !important; }
/* backdrop — 거의 투명 (panel 가 fullscreen 라 직접 효과 X, 보조용) */
.bf-search-backdrop { position: absolute; inset: 0;
    background: transparent;
    animation: bf-sf-fade .2s ease; }
@keyframes bf-sf-fade { from { opacity: 0; } to { opacity: 1; } }
/* Fullscreen panel — fixed + 최상위 z-index (PC 헤더 fixed 위 덮음) */
.bf-search-panel { position: fixed; inset: 0;
    padding-top: env(safe-area-inset-top, 0px);  /* 노치 기기 안전영역 */
    width: 100vw; max-width: 100vw; max-height: 100vh;
    background: var(--bj-surface, #fff);
    border-radius: 0;
    box-shadow: none;
    z-index: 2147483647;
    display: flex; flex-direction: column; overflow: hidden;
    animation: bf-sf-slide .25s cubic-bezier(.2,.9,.3,1); }
@keyframes bf-sf-slide { from { transform: translateY(10px); opacity: 0; }
                        to   { transform: translateY(0);     opacity: 1; } }

/* 상단 input row — 큰 사이즈 + center 정렬 (fullscreen 에 어울리게) */
/* v15: input row bg/blur 제거 — panel frosted 그대로 (results 와 동일 톤) */
.bf-search-input-row {
    padding: 24px max(40px, calc((100vw - 1000px) / 2)) 20px;  /* 검색바+X 합산 1000px 정렬 */
    background: transparent;
    border-bottom: 0;
    width: 100%; box-sizing: border-box;
    display: flex; align-items: center; gap: 14px;
}
/* pill 형 input wrapper (둥근 라운드 search bar) */
.bf-search-input-box {
    flex: 1; min-width: 0;
    display: flex; align-items: center; gap: 14px;
    padding: 14px 22px;
    background: #fff;
    border: 1.5px solid #e3e6eb;
    border-radius: 999px;
    transition: border-color .15s, box-shadow .15s;
}
.bf-search-input-box:focus-within {
    border-color: var(--bf-search-brand);
    box-shadow: 0 0 0 4px rgba(27,38,49,0.05);
}
.bf-search-icon { width: 22px; height: 22px; color: #8a93a0; flex-shrink: 0;
    stroke-width: 2; }
.bf-search-input-box:focus-within .bf-search-icon { color: var(--bf-search-brand); }
#bf-search-input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
    font-size: 17px; font-family: inherit; color: #1a1a1a;
    letter-spacing: -0.012em; font-weight: 500; line-height: 1.4; }
#bf-search-input::placeholder { color: #b0b6bf; font-weight: 400; }
/* v16: × close button — frosted glass 위 명확히 보이도록 (회색 원형 + 진한 navy) */
.bf-search-close { background: rgba(27,38,49,0.08); border: 1px solid rgba(27,38,49,0.12);
    width: 44px; height: 44px;
    border-radius: 50%; cursor: pointer; padding: 0;
    display: flex; align-items: center; justify-content: center;
    color: #1b2631; transition: all .15s ease; flex-shrink: 0; }
.bf-search-close svg { width: 22px; height: 22px; stroke-width: 2.2; }
.bf-search-close:hover { background: #1b2631; color: #fff; border-color: #1b2631;
    transform: scale(1.05); box-shadow: 0 6px 16px rgba(27,38,49,0.28); }
.bf-search-close:active { transform: scale(0.96); }

.bf-search-results { flex: 1; overflow-y: auto; padding: 8px 0 4px;
    background: transparent;
    max-width: 1000px; margin: 0 auto; width: 100%; box-sizing: border-box; }

/* 빈 상태 */
.bf-search-empty { padding: 32px 40px 16px; }
.bf-search-hint { margin: 0 0 22px; color: var(--bj-text-muted, #77716e); font-size: 13px; line-height: 1.5; }
.bf-search-section { margin-bottom: 28px; }
.bf-search-section-title { font-size: 12.5px; font-weight: 600; color: #8a93a0;
    text-transform: uppercase; letter-spacing: 0.08em;
    margin-bottom: 14px; }
.bf-search-chips { display: flex; flex-wrap: wrap; gap: 10px; }
/* 흰 + brand pink outline hover */
.bf-search-chip { background: #fff; border: 1px solid #e3e6eb; color: #44444a;
    padding: 10px 18px; border-radius: 999px;
    font-size: 13.5px; font-weight: 500;
    cursor: pointer; font-family: inherit;
    transition: all .15s ease; letter-spacing: -0.005em; }
.bf-search-chip:hover {
    border-color: var(--bf-search-brand);
    color: var(--bf-search-brand);
    background: var(--bf-search-brand-soft);
}
.bf-search-no-hist { font-size: 13px; color: var(--bj-muted, #66635e); padding: 4px 0; }

/* 결과 그룹 */
.bf-search-group { padding: 4px 0 16px; }
.bf-search-group-head { font-size: 12.5px; font-weight: 600; color: #8a93a0;
    text-transform: uppercase; letter-spacing: 0.08em;
    padding: 20px 40px 12px; }
.bf-search-group-head .bf-count {
    color: var(--bf-search-brand); font-weight: 700;
    margin-left: 6px; font-size: 13px;
}

/* PRODUCT grid — responsive (1/2/3/4/5-col), gap 더 시원하게 */
.bf-search-group.bf-grp-product .bf-search-items {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px;
    padding: 4px 40px 16px;
}
@media (min-width: 1600px) {
    .bf-search-group.bf-grp-product .bf-search-items { grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 1100px) {
    .bf-search-group.bf-grp-product .bf-search-items { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
    /* v20 모바일·태블릿 — PC와 같은 전체검색, 좁은 폭 컴팩트 튜닝 */
    .bf-search-group.bf-grp-product .bf-search-items { grid-template-columns: repeat(3, 1fr); padding: 4px 16px 12px; gap: 10px; }
    .bf-search-input-row { padding: 14px 16px 12px; gap: 10px; }
    .bf-search-input-box { padding: 11px 16px; gap: 10px; }
    #bf-search-input { font-size: 16px; }
    .bf-search-icon { width: 20px; height: 20px; }
    .bf-search-empty { padding: 18px 16px 8px; }
    .bf-search-group-head { padding: 14px 16px 8px; }
    .bf-search-group:not(.bf-grp-product) .bf-search-item { padding: 12px 16px; gap: 12px; }
    .bf-search-group.bf-grp-product .bf-search-item { gap: 8px; }
    .bf-search-group.bf-grp-product .bf-search-name { font-size: 12px; }
    .bf-search-close { width: 42px; height: 42px; }
}
@media (max-width: 480px) {
    /* v20 폰 — 3열 소형 썸네일 (통 이미지 금지, 앱 검색 톤) */
    .bf-search-group.bf-grp-product .bf-search-items { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 2px 14px 10px; }
    .bf-search-group.bf-grp-product .bf-search-thumb { border-radius: 10px; }
    .bf-search-group.bf-grp-product .bf-search-item { gap: 6px; }
    .bf-search-group.bf-grp-product .bf-search-name { font-size: 11.5px; }
    .bf-search-group.bf-grp-product .bf-search-sub { font-size: 10.5px; }
    .bf-search-input-row { padding: 12px 12px 10px; gap: 8px; }
    #bf-search-input { font-size: 16px; }
    .bf-search-empty { padding: 14px 14px 6px; }
    .bf-search-group-head { padding: 12px 14px 6px; font-size: 11.5px; }
    .bf-search-group:not(.bf-grp-product) .bf-search-item { padding: 11px 14px; }
    .bf-search-close { width: 44px; height: 44px; }
    .bf-search-close svg { width: 20px; height: 20px; }
}
/* v14: 카드 = thumb 영역만 + info 외부. 상품사이트 스타일 (네이버쇼핑 / 쿠팡 등) */
.bf-search-group.bf-grp-product .bf-search-item {
    display: flex; flex-direction: column; align-items: stretch; gap: 12px;
    padding: 0; border-radius: 0;
    border: 0; background: transparent;
    transition: transform .2s cubic-bezier(.2,.9,.3,1.2);
    position: relative;
}
.bf-search-group.bf-grp-product .bf-search-item:hover {
    transform: translateY(-3px);
}
.bf-search-group.bf-grp-product .bf-search-item:hover .bf-search-thumb,
.bf-search-group.bf-grp-product .bf-search-item.bf-active .bf-search-thumb {
    box-shadow: 0 14px 30px -10px rgba(15,17,21,0.22),
                0 4px 10px -4px rgba(15,17,21,0.08);
}
.bf-search-group.bf-grp-product .bf-search-item.bf-active .bf-search-thumb {
    outline: 2px solid var(--bf-search-brand);
    outline-offset: -1px;
}
/* v10: ✓ 선택 badge 제거 — active 시 border + shadow 만으로 충분 */
.bf-search-group.bf-grp-product .bf-search-thumb {
    width: 100%; aspect-ratio: 3 / 4; border-radius: 12px;
    background: #f4f5f7; overflow: hidden;
    border: 1px solid #f0f2f5; position: relative;
    transition: box-shadow .25s ease, outline-color .15s ease;
}
/* v13: object-fit cover (꽉 채움, 흰 여백 X) — 사용자 요청 */
.bf-search-group.bf-grp-product .bf-search-thumb-img {
    position: absolute; inset: 0;
    width: 100%; height: 100%; object-fit: cover; display: block;
    z-index: 2;
}
/* 가로형 이미지 (영상/16:9 썸네일 등) — cover 로 3:4 셀 가득 채움 (여백 0)
   img.onload 가 naturalWidth/naturalHeight 비교해 자동 부여 */
.bf-search-group.bf-grp-product .bf-search-thumb-img.is-landscape {
    object-fit: cover;
    padding: 0;
}
/* fallback — 코드 prefix 색 gradient + 코드 텍스트 (img 뒤) */
.bf-search-thumb-fallback {
    position: absolute; inset: 0; z-index: 1;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700; letter-spacing: 0.04em;
    color: rgba(255,255,255,0.95); font-family: inherit;
    background: linear-gradient(135deg, #b0b6bf 0%, #8a93a0 100%);
}
/* prefix 별 컬러 (DB code 시리즈 매핑) */
.bf-search-thumb-fallback[data-prefix="GB"] { background: linear-gradient(135deg, #6b8e9e 0%, #4a6b78 100%); }
.bf-search-thumb-fallback[data-prefix="PB"] { background: linear-gradient(135deg, #b89a8a 0%, #8a6e60 100%); }
.bf-search-thumb-fallback[data-prefix="KB"] { background: linear-gradient(135deg, #c9a87a 0%, #9c7d4d 100%); }
.bf-search-thumb-fallback[data-prefix="TB"] { background: linear-gradient(135deg, #8a6e8c 0%, #645068 100%); }
.bf-search-thumb-fallback[data-prefix="OP"] { background: linear-gradient(135deg, #9eb0a8 0%, #6f8278 100%); }
.bf-search-thumb-fallback[data-prefix="MV"] { background: linear-gradient(135deg, #4a5468 0%, #2a3441 100%); }
.bf-search-thumb-fallback[data-prefix="MC"] { background: linear-gradient(135deg, #d4a09e 0%, #a87a78 100%); }
.bf-search-thumb-fallback[data-prefix="ST"] { background: linear-gradient(135deg, #b8c4d4 0%, #8a96a6 100%); }
.bf-search-thumb-fallback[data-prefix="NB"] { background: linear-gradient(135deg, #c4b8a0 0%, #968a72 100%); }

/* NEW badge */
.bf-search-new {
    position: absolute; top: 8px; right: 8px;
    background: #1b2631; color: #fff;
    font-size: 9.5px; font-weight: 700; letter-spacing: 0.05em;
    padding: 3px 7px; border-radius: 3px; line-height: 1.3;
    z-index: 2;
}
/* price strong */
.bf-search-group.bf-grp-product .bf-search-sub b {
    color: #1b2631; font-weight: 700; margin-left: 4px;
}
/* v14: info 영역 — 카드 thumb 외부, 상품사이트 스타일 */
.bf-search-group.bf-grp-product .bf-search-info {
    flex: none; padding: 2px 4px 0;
}
.bf-search-group.bf-grp-product .bf-search-name {
    font-size: 14px; font-weight: 600; color: #1a1a1a;
    line-height: 1.4; white-space: normal;
    display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
    overflow: hidden; text-overflow: ellipsis;
    letter-spacing: -0.012em;
}
.bf-search-group.bf-grp-product .bf-search-item:hover .bf-search-name {
    color: var(--bf-search-brand);
}
.bf-search-group.bf-grp-product .bf-search-sub {
    font-size: 12px; color: #8a93a0; margin-top: 4px;
    font-weight: 400; letter-spacing: 0.01em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bf-search-group.bf-grp-product .bf-search-arrow { display: none; }

/* EVENT / SERVICE — list */
.bf-search-group:not(.bf-grp-product) .bf-search-items {
    display: flex; flex-direction: column;
}
.bf-search-group:not(.bf-grp-product) .bf-search-item {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 40px; cursor: pointer; transition: background .1s;
    text-decoration: none; color: inherit; position: relative;
}
.bf-search-group:not(.bf-grp-product) .bf-search-item:hover,
.bf-search-group:not(.bf-grp-product) .bf-search-item.bf-active {
    background: var(--bf-search-brand-soft);
}
.bf-search-group:not(.bf-grp-product) .bf-search-item.bf-active::before {
    content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 4px; height: 32px;
    background: linear-gradient(180deg, var(--bf-search-brand), var(--bf-search-brand-2));
    border-radius: 0 2px 2px 0;
}
.bf-search-group:not(.bf-grp-product) .bf-search-thumb {
    width: 44px; height: 44px; flex-shrink: 0;
    border-radius: 10px; background: #f4f5f7;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: #c4c8d0; overflow: hidden;
}
.bf-search-group:not(.bf-grp-product) .bf-search-info { flex: 1; min-width: 0; }
.bf-search-group:not(.bf-grp-product) .bf-search-name {
    font-size: 15px; font-weight: 600; color: #1b2631;
    letter-spacing: -0.005em; line-height: 1.4;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bf-search-group:not(.bf-grp-product) .bf-search-item:hover .bf-search-name,
.bf-search-group:not(.bf-grp-product) .bf-search-item.bf-active .bf-search-name {
    color: var(--bf-search-brand);
}
.bf-search-group:not(.bf-grp-product) .bf-search-sub {
    font-size: 12px; color: #6b727d; margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bf-search-group:not(.bf-grp-product) .bf-search-arrow {
    color: #c4c8d0; font-size: 16px; flex-shrink: 0;
    transition: transform .15s, color .15s;
}
.bf-search-group:not(.bf-grp-product) .bf-search-item:hover .bf-search-arrow,
.bf-search-group:not(.bf-grp-product) .bf-search-item.bf-active .bf-search-arrow {
    color: var(--bf-search-brand); transform: translateX(4px);
}

/* 무결과 */
.bf-search-noresult { padding: 80px 40px; text-align: center; color: #888; font-size: 15px; }
.bf-search-noresult b { color: var(--bf-search-brand); }
.bf-search-loading { padding: 60px 40px; text-align: center; color: #888; font-size: 13px; }
.bf-search-loading::before {
    content: ''; display: inline-block; width: 16px; height: 16px;
    border: 2px solid #e3e6eb; border-top-color: var(--bf-search-brand);
    border-radius: 50%; animation: bf-spin 0.7s linear infinite;
    vertical-align: middle; margin-right: 10px;
}
@keyframes bf-spin { to { transform: rotate(360deg); } }

/* v8: footer 제거됨 — 키보드 힌트/took 모두 hidden */

/* v17: 카테고리 그룹 (이모지 아이콘 + 큰 thumb) */
.bf-search-group.bf-grp-category { padding-top: 8px; }
.bf-search-group.bf-grp-category .bf-search-items {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 8px; padding: 4px 40px 16px;
}
@media (max-width: 768px) {
    .bf-search-group.bf-grp-category .bf-search-items {
        grid-template-columns: 1fr; padding: 4px 20px 12px;
    }
}
.bf-cat-item { background: linear-gradient(135deg, rgba(27,38,49,0.02), rgba(27,38,49,0.05)) !important; }
.bf-cat-item:hover { background: linear-gradient(135deg, rgba(27,38,49,0.06), rgba(27,38,49,0.10)) !important; }
.bf-cat-thumb {
    background: #fff !important; border: 1px solid rgba(27,38,49,0.08);
    width: 44px !important; height: 44px !important; border-radius: 12px !important;
    display: flex !important; align-items: center !important; justify-content: center !important;
}
.bf-search-cat-icon { font-size: 22px; line-height: 1; }

/* v17: 이벤트 종료 배지 + dim */
.bf-search-ended-badge {
    display: inline-block; padding: 2px 8px; margin-right: 6px;
    background: #f4f5f7; color: #8a93a0;
    font-size: 11px; font-weight: 600; border-radius: 4px;
    letter-spacing: 0; vertical-align: middle;
}
.bf-event-ended .bf-search-name { color: #8a93a0; }
.bf-event-ended .bf-search-sub { color: #b0b6bf; }
.bf-event-ended .bf-search-thumb { opacity: 0.55; }

/* v17: FAQ 그룹 — 카테고리 chip + 짧은 답변 preview */
.bf-search-faq-cat {
    display: inline-block; padding: 2px 8px; margin-right: 8px;
    background: rgba(27,38,49,0.06); color: var(--bf-search-brand);
    font-size: 11px; font-weight: 600; border-radius: 4px;
    letter-spacing: 0; vertical-align: middle;
}
.bf-faq-item .bf-search-name { font-size: 14px; }
.bf-faq-sub {
    -webkit-line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical;
    overflow: hidden; white-space: normal !important;
    color: #8a93a0 !important; line-height: 1.5; font-size: 12.5px !important;
    margin-top: 4px;
}

/* 옛 #head_search dropdown 폐기 */
#head_search { display: none !important; }
