/**
 * 검색어 추천 드롭다운 스타일
 */

/* 검색 wrapper */
.search-suggest-wrapper {
    position: relative;
}

/* 드롭다운 컨테이너 */
.search-suggest-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* 드롭다운 헤더 */
.search-suggest-header {
    padding: 10px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.search-suggest-header .suggest-title {
    font-size: 12px;
    color: #666;
    font-weight: 600;
}

/* 추천 검색어 리스트 */
.search-suggest-dropdown .search-suggest-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.search-suggest-dropdown .search-suggest-list li {
    margin: 0;
    padding: 0;
}

.search-suggest-dropdown .search-suggest-list li a {
    display: block;
    padding: 12px 15px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    border-bottom: 1px solid #f0f0f0;
    /* 텍스트 말줄임 처리 */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-suggest-dropdown .search-suggest-list li a:hover,
.search-suggest-dropdown .search-suggest-list li a:focus {
    background: #f5f5f5;
    color: #007bff;
}

.search-suggest-dropdown .search-suggest-list li a:before {
    content: "\f002";
    font-family: FontAwesome;
    margin-right: 10px;
    color: #999;
    font-size: 12px;
}

.search-suggest-dropdown .search-suggest-list li:last-child a {
    border-bottom: none;
}

/* 모바일 검색창 드롭다운 스타일 */
.m_fsearch.search-suggest-wrapper {
    position: relative;
}

.m_fsearch .search-suggest-dropdown {
    left: 0;
    right: 0;
    border-radius: 0 0 8px 8px;
}

.m_fsearch .search-suggest-dropdown .search-suggest-list li a {
    padding: 14px 15px;
    font-size: 15px;
}

/* 애니메이션 */
.search-suggest-dropdown.show {
    display: block !important;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* PC 헤더 검색창 특화 스타일 */
.pc-header .header-search .search-suggest-dropdown {
    min-width: 280px;
}

/* ===== 모바일 반응형 스타일 ===== */
@media (max-width: 768px) {
    /* 모바일에서 드롭다운을 검색창 바로 아래에 표시 (화면 전체를 덮지 않음) */
    .search-suggest-dropdown {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-top: 4px;
        border-radius: 0 0 12px 12px;
        border: 1px solid #e0e0e0;
        border-top: none;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
        max-height: 200px; /* 키보드와 겹치지 않도록 더 작게 조정 */
        overflow-x: hidden;
        overflow-y: auto;
        box-sizing: border-box;
        background: #fff;
    }

    /* 모바일 검색창 wrapper 위치 조정 - 검색창 아래로 */
    .m_fsearch.search-suggest-wrapper .search-suggest-dropdown,
    .m_search .search-suggest-dropdown,
    .header_search .search-suggest-dropdown {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* 모바일 추천 검색어 항목 - 컴팩트하게 수정 */
    .search-suggest-dropdown .search-suggest-list li a {
        padding: 8px 12px; /* 패딩 축소 */
        line-height: 1.2; /* 줄 간격 좁게 */
        font-size: 13px; /* 폰트 크기 약간 축소 */
        min-height: 36px; /* 최소 높이 축소 (터치 영역 유지) */
        /* 텍스트가 넘치지 않도록 처리 */
        word-break: break-word;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: flex;
        align-items: center;
    }

    /* m_fsearch 내부 항목도 컴팩트하게 */
    .m_fsearch .search-suggest-dropdown .search-suggest-list li a {
        padding: 8px 12px;
        line-height: 1.2;
        font-size: 13px;
        min-height: 36px;
    }

    .search-suggest-header {
        padding: 8px 12px; /* 헤더도 컴팩트하게 */
        background: #f8f9fa;
        border-radius: 0;
        border-bottom: 1px solid #eee;
    }

    .search-suggest-header .suggest-title {
        font-size: 11px;
        color: #666;
        font-weight: 600;
    }
}

/* 더 작은 모바일 기기 (375px 이하) */
@media (max-width: 375px) {
    .search-suggest-dropdown {
        max-height: 180px; /* 더 작은 화면에서는 더 축소 */
    }

    .search-suggest-dropdown .search-suggest-list li a {
        padding: 7px 10px;
        font-size: 12px;
        line-height: 1.2;
        min-height: 32px;
    }

    .m_fsearch .search-suggest-dropdown .search-suggest-list li a {
        padding: 7px 10px;
        font-size: 12px;
        line-height: 1.2;
        min-height: 32px;
    }

    .search-suggest-header {
        padding: 6px 10px;
    }

    .search-suggest-header .suggest-title {
        font-size: 10px;
    }
}

/* 검색창 포커스 시 테두리 강조 */
.search-suggest-input:focus {
    outline: none;
    border-color: #007bff;
}

/* 로딩 상태 */
.search-suggest-dropdown.loading .search-suggest-list:after {
    content: "로딩 중...";
    display: block;
    padding: 15px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* 데이터 없음 상태 */
.search-suggest-dropdown .no-data {
    padding: 20px 15px;
    text-align: center;
    color: #999;
    font-size: 13px;
}

/* ===== 모바일 검색창 테두리 및 디자인 개선 ===== */

/* 모바일 검색창 wrapper */
.m_fsearch {
    position: relative;
}

/* 모바일 검색창 input */
.m_fsearch .input_text,
.m_fsearch input[name="stx"],
.header_search .input_text,
.header_search input[name="stx"] {
    width: calc(100% - 90px);
    height: 42px;
    padding: 0 15px;
    border: 1px solid #ddd;
    border-radius: 21px;
    background: #fff;
    font-size: 14px;
    color: #333;
    outline: none;
    transition: all 0.25s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* 모바일 검색창 포커스 상태 */
.m_fsearch .input_text:focus,
.m_fsearch input[name="stx"]:focus,
.header_search .input_text:focus,
.header_search input[name="stx"]:focus {
    border-color: #ff6600;
    box-shadow: 0 2px 10px rgba(255, 102, 0, 0.2);
}

/* 모바일 검색창 placeholder */
.m_fsearch .input_text::placeholder,
.m_fsearch input[name="stx"]::placeholder,
.header_search .input_text::placeholder,
.header_search input[name="stx"]::placeholder {
    color: #aaa;
    font-size: 13px;
}

/* 모바일 검색 버튼 */
.m_fsearch button[type="submit"],
.header_search .m_search button[type="submit"] {
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6600 0%, #ff8533 100%);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(255, 102, 0, 0.3);
}

.m_fsearch button[type="submit"]:hover,
.header_search .m_search button[type="submit"]:hover {
    background: linear-gradient(135deg, #e55c00 0%, #ff6600 100%);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 3px 10px rgba(255, 102, 0, 0.4);
}

/* 모바일 검색창 form 레이아웃 */
.m_fsearch form {
    display: flex;
    align-items: center;
    position: relative;
    width: 100%;
}

/* 외부 클릭 시 드롭다운 닫기를 위한 오버레이 */
.search-suggest-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9998;
    background: transparent;
}

/* 드롭다운이 열렸을 때 z-index 조정 */
.search-suggest-dropdown.show {
    z-index: 9999;
}

/* ===== 모바일 검색창 버튼 레이아웃 개선 (2024-01-26) ===== */
/* 돋보기 버튼과 인기 검색어 버튼이 겹치지 않도록 수정 */

@media (max-width: 768px) {
    /* 모바일 검색 폼 레이아웃 - flexbox로 재구성 */
    .m_fsearch form,
    .m_search form {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        position: relative;
    }
    
    /* 검색 입력창 - flex-grow로 나머지 공간 채우기 */
    .m_fsearch .input_text,
    .m_fsearch input[name="stx"],
    .m_search .input_text,
    .m_search input[name="stx"] {
        flex: 1;
        min-width: 0;
        width: auto !important;
        height: 40px;
        padding: 0 12px;
        border: 1px solid #e0e0e0;
        border-radius: 20px;
        background: #fff;
        font-size: 14px;
        color: #333;
        outline: none;
        transition: all 0.25s ease;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    }
    
    /* 검색 버튼 - 절대 위치 제거하고 flex 아이템으로 배치 */
    .m_fsearch button[type="submit"],
    .m_search button[type="submit"] {
        position: static !important;
        transform: none !important;
        flex-shrink: 0;
        width: 40px;
        height: 40px;
        border: none;
        border-radius: 50%;
        background: linear-gradient(135deg, #ff6600 0%, #ff8533 100%);
        color: #fff;
        font-size: 16px;
        cursor: pointer;
        transition: all 0.25s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 2px 8px rgba(255, 102, 0, 0.3);
        padding: 0;
        margin: 0;
    }
    
    .m_fsearch button[type="submit"]:hover,
    .m_search button[type="submit"]:hover {
        transform: scale(1.05) !important;
        box-shadow: 0 4px 12px rgba(255, 102, 0, 0.4);
    }
    
    /* 인기 검색어 버튼 wrapper - flex 아이템으로 배치 */
    .m_fsearch .popular-keywords-btn-wrapper,
    .m_search .popular-keywords-btn-wrapper {
        flex-shrink: 0;
        position: relative;
        display: flex !important;
        align-items: center;
        margin: 0;
    }
    
    /* 인기 검색어 버튼 - 돋보기 버튼과 크기 맞춤 */
    .m_fsearch .popular-keywords-btn,
    .m_search .popular-keywords-btn {
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: 50%;
        background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
        color: #fff !important;
        font-size: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        cursor: pointer;
        transition: all 0.25s ease;
        box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    }
    
    .m_fsearch .popular-keywords-btn:hover,
    .m_search .popular-keywords-btn:hover {
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    }
    
    .m_fsearch .popular-keywords-btn i,
    .m_search .popular-keywords-btn i {
        margin: 0;
        font-size: 16px;
    }
}

/* 더 작은 모바일 기기 (375px 이하) */
@media (max-width: 375px) {
    .m_fsearch form,
    .m_search form {
        gap: 6px;
    }
    
    .m_fsearch .input_text,
    .m_fsearch input[name="stx"],
    .m_search .input_text,
    .m_search input[name="stx"] {
        height: 36px;
        padding: 0 10px;
        font-size: 13px;
        border-radius: 18px;
    }
    
    .m_fsearch button[type="submit"],
    .m_search button[type="submit"] {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    .m_fsearch .popular-keywords-btn,
    .m_search .popular-keywords-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

/* ===== 모바일 검색창 버튼 및 추천검색어 개선 (2026-01-26) ===== */
@media (max-width: 768px) {
    /* 검색 버튼 absolute 위치 제거, flex 레이아웃으로 변경 */
    .m_fsearch button[type="submit"],
    .m_search button[type="submit"],
    .header_search button[type="submit"] {
        position: static !important;
        right: auto !important;
        top: auto !important;
        transform: none !important;
        flex-shrink: 0;
    }

    /* 추천 검색어 헤더 패딩 축소 */
    .search-suggest-dropdown .search-suggest-header {
        padding: 6px 12px !important;
    }

    .search-suggest-dropdown .search-suggest-header .suggest-title {
        font-size: 11px !important;
    }

    /* 추천 검색어 리스트 아이템 패딩 축소 */
    .search-suggest-dropdown .search-suggest-list li a {
        padding: 8px 12px !important;
        min-height: 36px !important;
        font-size: 13px !important;
    }

    /* 추천 검색어 아이콘 마진 축소 */
    .search-suggest-dropdown .search-suggest-list li a:before {
        margin-right: 8px;
    }
}

/* 더 작은 모바일 화면 */
@media (max-width: 375px) {
    .search-suggest-dropdown .search-suggest-header {
        padding: 5px 10px !important;
    }

    .search-suggest-dropdown .search-suggest-list li a {
        padding: 6px 10px !important;
        min-height: 32px !important;
        font-size: 12px !important;
    }
}

/* ===== 모바일 검색창 완전 재구성 (2026-01-26 v2) ===== */
@media (max-width: 768px) {
    /* 검색 폼 컨테이너 - flexbox 레이아웃 */
    .m_fsearch form,
    .header_search .m_fsearch form {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        gap: 6px !important;
        width: 100% !important;
    }

    /* 검색 입력창 - 버튼 공간 확보를 위해 너비 제한 */
    .m_fsearch .input_text,
    .m_fsearch input[name="stx"],
    .header_search .m_fsearch .input_text,
    .header_search .m_fsearch input[name="stx"] {
        flex: 1 1 auto !important;
        width: auto !important;
        max-width: none !important;
        min-width: 100px !important;
        height: 38px !important;
        padding: 0 12px !important;
        border-radius: 19px !important;
    }

    /* 검색 버튼 (돋보기) - 입력창 밖으로 */
    .m_fsearch button[type="submit"],
    .header_search .m_fsearch button[type="submit"] {
        position: static !important;
        right: auto !important;
        top: auto !important;
        transform: none !important;
        flex: 0 0 38px !important;
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        border-radius: 50% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 인기검색어 버튼 wrapper - 입력창 밖으로 */
    .m_fsearch .popular-keywords-btn-wrapper,
    .header_search .m_fsearch .popular-keywords-btn-wrapper {
        position: static !important;
        flex: 0 0 38px !important;
        display: flex !important;
        margin: 0 !important;
    }

    /* 인기검색어 버튼 */
    .m_fsearch .popular-keywords-btn,
    .header_search .m_fsearch .popular-keywords-btn {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* 추천 검색어 헤더 - 높이 축소 */
    .m_fsearch .search-suggest-dropdown .search-suggest-header,
    .header_search .search-suggest-dropdown .search-suggest-header,
    .search-suggest-wrapper .search-suggest-dropdown .search-suggest-header {
        padding: 5px 10px !important;
        margin: 0 !important;
    }

    .m_fsearch .search-suggest-dropdown .search-suggest-header .suggest-title,
    .header_search .search-suggest-dropdown .search-suggest-header .suggest-title,
    .search-suggest-wrapper .search-suggest-dropdown .search-suggest-header .suggest-title {
        font-size: 10px !important;
        line-height: 1.2 !important;
    }
}
