/**
 * EcoBuild Interface Enhancements Styles
 * 인터페이스 기능 강화를 위한 추가 스타일
 */

/* ============================================
   언어 선택 버튼 Active 상태
   ============================================ */

/* 데스크톱 언어 선택 */
.__lang .lang_box li.__current a {
    font-weight: 700;
    color: #1428a0;
    position: relative;
}

.__lang .lang_box li.__current a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 2px;
    background-color: #1428a0;
}

/* 모바일 언어 선택 */
.__lang-m li.__current a {
    font-weight: 700;
    color: #1428a0;
}

/* 언어 토글 버튼 */
.__lang .__toggle {
    transition: all 0.3s ease;
}

.__lang .__toggle:hover {
    color: #1428a0;
}

/* ============================================
   검색 기능 개선
   ============================================ */

/* 검색 박스 애니메이션 */
.__search-box {
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.__search-box:not(.__active) {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.__search-box.__active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

/* 검색 입력창 스타일 개선 */
.__search-box .__input-box,
.__search-m form {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.__search-box input[name="param1"],
.__search-m input[name="param1"] {
    flex: 1;
    padding-right: 3rem; /* 아이콘 공간 확보 */
}

/* 검색 입력창 포커스 스타일 */
.__search-box input[name="param1"]:focus,
.__search-m input[name="param1"]:focus {
    outline: none;
    border-color: #1428a0;
    box-shadow: 0 0 0 2px rgba(20, 40, 160, 0.1);
}

/* 검색 아이콘 버튼 */
.__search-icon-btn {
    position: absolute;
    right: 5.5rem; /* 검색 버튼 왼쪽에 위치 */
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: color 0.2s ease;
    z-index: 10;
}

.__search-icon-btn:hover {
    color: #1428a0;
}

.__search-icon-btn svg {
    width: 20px;
    height: 20px;
}

/* 검색 버튼 호버 효과 */
.__search-box button[type="submit"]:hover,
.__search-m button[type="submit"]:hover {
    background-color: #0f1d7a;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(20, 40, 160, 0.2);
}

/* 검색 버튼 내부 아이콘 */
.__search-box button[type="submit"] .__search-icon,
.__search-m button[type="submit"] .__search-icon {
    display: inline-flex;
    align-items: center;
    margin-right: 0.25rem;
}

.__search-box button[type="submit"] .__search-icon svg,
.__search-m button[type="submit"] .__search-icon svg {
    width: 16px;
    height: 16px;
}

/* ============================================
   Contact Us 버튼 개선
   ============================================ */

/* Contact Us 링크 호버 효과 */
a:has(span:contains("Contact US")):hover,
.__footer-menu a:has(span:contains("Contact Us")):hover {
    color: #1428a0;
    transition: color 0.3s ease;
}

/* ============================================
   부드러운 스크롤 애니메이션
   ============================================ */

html {
    scroll-behavior: smooth;
}

/* ============================================
   반응형 개선
   ============================================ */

@media screen and (max-width: 768px) {
    /* 모바일에서 언어 선택 */
    .__lang-m li.__current a {
        background-color: rgba(20, 40, 160, 0.05);
        border-radius: 4px;
        padding: 4px 8px;
    }
    
    /* 모바일 검색창 */
    .__search-box input[name="param1"] {
        font-size: 16px; /* iOS zoom 방지 */
    }
}

/* ============================================
   접근성 개선
   ============================================ */

/* 포커스 표시 */
a:focus,
button:focus,
input:focus {
    outline: 2px solid #1428a0;
    outline-offset: 2px;
}

/* 키보드 네비게이션 */
a:focus-visible,
button:focus-visible {
    outline: 2px solid #1428a0;
    outline-offset: 2px;
}

/* ============================================
   로딩 상태 (향후 확장용)
   ============================================ */

.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #1428a0;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   검색 메시지 애니메이션
   ============================================ */

.__search-message {
    animation: slideDown 0.3s ease-out;
}

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

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

/* 검색 버튼 트랜지션 */
.__search-box button[type="submit"] {
    transition: all 0.2s ease;
}

/* 검색창 입력 애니메이션 */
.__search-box input[name="param1"] {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* ============================================
   검색 결과 드롭다운
   ============================================ */

.__search-results-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    max-height: 500px;
    overflow-y: auto;
    z-index: 1000;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

.__search-results-dropdown.__active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

/* 드롭다운 헤더 */
.__search-results-dropdown .__dropdown-header {
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px 8px 0 0;
}

.__search-results-dropdown .__result-count {
    font-size: 0.9rem;
}

.__search-results-dropdown .__result-count strong {
    font-weight: 700;
}

/* 드롭다운 리스트 */
.__search-results-dropdown .__dropdown-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.__search-results-dropdown .__dropdown-item {
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.__search-results-dropdown .__dropdown-item:last-child {
    border-bottom: none;
}

.__search-results-dropdown .__dropdown-item:hover {
    background-color: #f8f9fa;
}

.__search-results-dropdown .__dropdown-item a {
    display: block;
    padding: 1rem 1.25rem;
    text-decoration: none;
    color: inherit;
}

.__search-results-dropdown .__item-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.__search-results-dropdown .__item-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1428a0;
    line-height: 1.4;
}

.__search-results-dropdown .__item-title mark {
    background-color: #fff3cd;
    color: #856404;
    padding: 0 0.2em;
    border-radius: 2px;
    font-weight: 700;
}

.__search-results-dropdown .__item-description {
    margin: 0;
    font-size: 0.875rem;
    color: #666;
    line-height: 1.5;
}

.__search-results-dropdown .__item-category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background-color: #e3f2fd;
    color: #1976d2;
    font-size: 0.75rem;
    border-radius: 12px;
    font-weight: 500;
}

/* 검색 결과 없음 */
.__search-results-dropdown .__dropdown-empty {
    padding: 3rem 2rem;
    text-align: center;
    color: #999;
}

.__search-results-dropdown .__dropdown-empty svg {
    margin-bottom: 1rem;
    color: #ccc;
}

.__search-results-dropdown .__dropdown-empty p {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #666;
}

.__search-results-dropdown .__dropdown-empty small {
    font-size: 0.875rem;
    color: #999;
}

/* 에러 메시지 */
.__search-results-dropdown .__dropdown-error {
    padding: 2rem 1.5rem;
    text-align: center;
    background-color: #fff3cd;
    border-radius: 8px;
}

.__search-results-dropdown .__dropdown-error p {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #856404;
}

.__search-results-dropdown .__dropdown-error small {
    font-size: 0.875rem;
    color: #856404;
    opacity: 0.8;
}

/* 스크롤바 스타일 */
.__search-results-dropdown::-webkit-scrollbar {
    width: 6px;
}

.__search-results-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 8px 8px 0;
}

.__search-results-dropdown::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.__search-results-dropdown::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* 모바일 반응형 */
@media screen and (max-width: 768px) {
    .__search-results-dropdown {
        max-height: 400px;
        border-radius: 6px;
    }
    
    .__search-results-dropdown .__dropdown-header {
        padding: 0.75rem 1rem;
    }
    
    .__search-results-dropdown .__dropdown-item a {
        padding: 0.875rem 1rem;
    }
    
    .__search-results-dropdown .__item-title {
        font-size: 0.9rem;
    }
    
    .__search-results-dropdown .__item-description {
        font-size: 0.8rem;
    }
}
