/**
 * IGE Korean Search - Autocomplete Styles
 * 2026-02-06 - 히어로 검색 자동완성
 * 2026-02-16 - 상단 검색바 자동완성 추가
 */

/* ============================================
   기본 자동완성 드롭다운 (공통)
   ============================================ */

/* 검색 입력 래퍼 */
.search-input-wrap {
    position: relative;
    width: 100%;
}

/* 자동완성 드롭다운 */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 4px;
}

.search-suggestions.active {
    display: block;
}

/* 자동완성 아이템 */
.suggestion-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.active {
    background: #f8f9fa;
}

/* 타입 뱃지 */
.suggestion-type {
    background: #3b82f6;
    color: #fff;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    margin-right: 12px;
    min-width: 50px;
    text-align: center;
    flex-shrink: 0;
}

.suggestion-type.district {
    background: #10b981;
}

/* 키워드 영역 */
.suggestion-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.suggestion-keyword {
    color: #333;
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestion-official {
    color: #888;
    font-size: 12px;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestion-location {
    color: #10b981;
    font-size: 11px;
    margin-top: 2px;
}

/* 로딩 상태 */
.search-suggestions.loading::after {
    content: '';
    display: block;
    padding: 20px;
    text-align: center;
}

/* 검색 없음 */
.suggestion-empty {
    padding: 20px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

/* 전체 검색 결과 보기 링크 */
.suggestion-search-all {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #e5e8eb;
    color: #176AD9;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.suggestion-search-all:hover {
    background: #f0f6ff;
}
.suggestion-search-all .material-symbols-outlined {
    font-size: 18px;
}

/* 모바일 검색 활성화 시 배경 스크롤 차단 */
body.search-active {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}


/* ============================================
   상단/모바일 검색바 - body에 append되는 fixed 드롭다운
   JS가 position:fixed + top/left/width를 동적으로 설정
   ============================================ */

.search-suggestions-fixed {
    position: fixed;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    border: 1px solid #e0e0e0;
    border-top: none;
    background: #fff;
    z-index: 10000;
    max-height: 400px;
    overflow-y: auto;
}


/* ============================================
   모바일 대응 (768px 이하)
   ============================================ */

@media (max-width: 768px) {
    /* 히어로: 포커스 시 검색 래퍼 상단 고정 */
    .search-input-wrap.focused {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1002;
        padding: 12px 16px;
        padding-top: max(12px, env(safe-area-inset-top));
        background: linear-gradient(135deg, #1a237e 0%, #0d47a1 100%);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        margin: 0;
        border-radius: 0;
    }

    /* 고정 시 입력창 스타일 유지 */
    .search-input-wrap.focused input {
        background: #fff;
        border-radius: 8px;
        width: 100%;
    }

    /* 히어로 자동완성: 검색창 바로 아래 */
    .search-input-wrap .search-suggestions {
        position: absolute;
        top: 68px;
        top: calc(68px + env(safe-area-inset-top));
        left: 0;
        right: 0;
        bottom: auto;
        max-height: 300px;
        border-radius: 0;
        margin: 0;
        border-top: 1px solid rgba(0, 0, 0, 0.1);
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* 모바일 상단 검색바 드롭다운 */
    .fixed-top-search .search-suggestions {
        max-height: 60vh;
        border-radius: 0 0 12px 12px;
    }

    /* 터치 영역 확대 */
    .suggestion-item {
        padding: 16px 20px;
        min-height: 56px;
    }

    .suggestion-type {
        padding: 4px 10px;
        font-size: 12px;
    }

    .suggestion-keyword {
        font-size: 16px;
    }

    .suggestion-official {
        font-size: 13px;
    }

    .suggestion-location {
        font-size: 12px;
    }

    .suggestion-empty {
        padding: 24px 20px;
        font-size: 15px;
    }
}

/* 모바일 가로 모드 */
@media (max-width: 768px) and (orientation: landscape) {
    .search-suggestions {
        max-height: calc(100vh - 60px);
    }

    .suggestion-item {
        padding: 12px 16px;
        min-height: 48px;
    }
}
