/* Gold Exchange Header Styles for AI Theme - Based on docs/example */

/* CSS Reset for Header */
.top-bar *, .main-header * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 상단 바 스타일 */
.top-bar {
    background: #333;
    color: #fff;
    padding: 8px 0;
    font-size: 12px;
    border-bottom: 1px solid #444;
}

.top-bar .container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.business-hours {
    font-size: 12px;
    color: #ccc;
    display: flex;
    align-items: center;
    gap: 5px;
}

.center-text {
    font-size: 14px;
    color: #fff;
    font-weight: 500;
}

.top-links {
    display: flex;
    gap: 12px;
    font-size: 12px;
}

.top-links a {
    color: #fff;
    text-decoration: none;
    transition: color 0.3s ease;
    padding: 4px 8px;
    border-radius: 4px;
}

.top-links a:hover {
    color: #d4af37;
    background: rgba(212, 175, 55, 0.1);
}

/* 메인 헤더 스타일 */
.main-header {
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: all 0.3s ease;
}

.main-header.scrolled {
    top: 10px;
    margin:0 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    
}

.header-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}
.main-header.scrolled .header-top {
    border-bottom:0;
}
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 80px;
    border-bottom: 1px solid #eee;
    padding: 0 20px;
    position: relative;
}

/* 오늘의 금시세 (좌측) */
.today-gold-price {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 120px;
}

.price-label {
    font-size: 12px;
    color: #666;
    font-weight: 400;
}

.price-value {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1;
}

.price-change {
    font-size: 11px;
    font-weight: 500;
}

.price-change.up {
    color: #27ae60;
}

.price-change.down {
    color: #e74c3c;
}

/* 로고 (중앙) */
.logo {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    text-decoration: none;
}

.logo-image {
    height: 50px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

/* 검색 영역 (우측) */
.search-area {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 240px;
    padding: 10px 15px 10px 45px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
    cursor: pointer;
}

.search-input:focus {
    border-color: #522F14;
}

.search-input:hover {
    border-color: #522F14;
}

.search-input::placeholder {
    color: #999;
}

.search-btn {
    position: absolute;
    left: 15px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #999;
    transition: color 0.3s;
    z-index: 1;
}

.search-btn:hover {
    color: #d4af37;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #666;
    transition: color 0.3s;
}

/* 모바일 전체 화면 메뉴 */
.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    z-index: 10002;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-100%);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.mobile-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(15px);
    position: sticky;
    top: 0;
    z-index: 1;
}

.mobile-menu-close {
    background: none;
    border: none;
    font-size: 32px;
    cursor: pointer;
    color: #666;
}

.mobile-menu-nav {
    padding: 20px;
    min-height: calc(100vh - 80px);
    padding-bottom: 80px;
}

.mobile-menu-nav > ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mobile-menu-nav > ul > li {
    position: relative;
    border-bottom: 1px solid #f0f0f0;
    opacity: 0;
    transform: translateX(30px);
    animation: slideInLeft 0.5s ease forwards;
}

.mobile-menu-nav > ul > li:last-child {
    border-bottom: none;
}

.mobile-menu-nav > ul > li:nth-child(1) { animation-delay: 0.1s; }
.mobile-menu-nav > ul > li:nth-child(2) { animation-delay: 0.2s; }
.mobile-menu-nav > ul > li:nth-child(3) { animation-delay: 0.3s; }
.mobile-menu-nav > ul > li:nth-child(4) { animation-delay: 0.4s; }
.mobile-menu-nav > ul > li:nth-child(5) { animation-delay: 0.5s; }
.mobile-menu-nav > ul > li:nth-child(6) { animation-delay: 0.6s; }
.mobile-menu-nav > ul > li:nth-child(7) { animation-delay: 0.7s; }

@keyframes slideInLeft {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.mobile-menu-nav > ul > li > a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    font-size: 16px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.mobile-menu-nav > ul > li > a::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: #d4af37;
    transition: width 0.3s ease;
}

.mobile-menu-nav > ul > li > a:hover,
.mobile-menu-nav > ul > li > a.has-active-submenu,
.mobile-menu-nav > ul > li:hover > a,
.mobile-menu-nav > ul > li.active > a,
.mobile-menu-nav > ul > li .mobile-submenu.active ~ a {
    color: #d4af37;
    transform: translateX(10px);
}

.mobile-menu-nav > ul > li > a:hover::before,
.mobile-menu-nav > ul > li > a.has-active-submenu::before,
.mobile-menu-nav > ul > li:hover > a::before,
.mobile-menu-nav > ul > li.active > a::before,
.mobile-menu-nav > ul > li .mobile-submenu.active ~ a::before {
    width: 100%;
}

.mobile-menu-nav .mobile-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.mobile-menu-nav .mobile-submenu.active {
    margin: 10px 0;
    max-height: none;
    opacity: 1;
    transform: translateY(0);
}

.mobile-menu-nav .mobile-submenu > li {
    position: relative;
    border-bottom: 1px solid #eee;
}

.mobile-menu-nav .mobile-submenu > li:last-child {
    border-bottom: none;
}

.mobile-menu-nav .mobile-submenu > li > a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    font-size: 14px;
    color: #666;
    text-decoration: none;
}

.mobile-menu-nav .mobile-submenu > li > a:hover {
    background: #f0f0f0;
    color: #d4af37;
}

.mobile-submenu-toggle {
    cursor: pointer;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.mobile-submenu-toggle svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    transition: transform 0.3s ease;
}

.mobile-submenu-toggle.active svg {
    transform: rotate(180deg);
}

/* 네비게이션 메뉴 */
.nav-content {
    /* background: #fff; */
    border-top: 1px solid #eee;
}

.nav-menu {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 10px;
    display: flex;
    justify-content: center;
    list-style: none;
    gap: 0;
}

.nav-menu > li {
    position: relative;
}

.nav-menu > li > a {
    display: block;
    padding: 8px 20px;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    font-size: 15px;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.nav-menu > li > a:hover,
.nav-menu > li > a.active,
.nav-menu > li:hover > a {
    color: #d4af37;
    border-bottom-color: #d4af37;
}

/* 드롭다운 메뉴 */


.has-dropdown:hover > a::after {
    transform: rotate(180deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    background: #fff;
    min-width: 200px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border-radius: 8px;
    /* overflow: hidden; */
    opacity: 0;
    visibility: hidden;
    transform: translate(-50% , 4px);
    /* transition: all 0.3s ease; */
    z-index: 1000;
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.has-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    /* transform: translateY(0); */
}

.dropdown-menu li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    color: #555;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s ease;
}

.dropdown-menu li a:hover {
    background: #f8f9fa;
    color: #d4af37;
    padding-left: 25px;
}

/* 3차 서브메뉴 스타일 */
.dropdown-menu .has-submenu {
    position: relative;
}

.dropdown-submenu {
    position: absolute;
    top: 0;
    left: 100%;
    background: #fff;
    min-width: 180px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border-radius: 8px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translate(4px, 0);
    transition: all 0.3s ease;
    z-index: 1001;
    list-style: none;
    margin: 0;
    padding: 8px 0;
}

.has-submenu:hover .dropdown-submenu {
    opacity: 1;
    visibility: visible;
    /* transform: translate(0, 0); */
}

.dropdown-submenu li a {
    display: block;
    padding: 10px 16px;
    color: #555;
    text-decoration: none;
    font-size: 13px;
    transition: all 0.3s ease;
}

.dropdown-submenu li a:hover {
    background: #f8f9fa;
    color: #d4af37;
    padding-left: 20px;
}

.submenu-arrow {
    width: 16px;
    height: 16px;
    color: #9ca3af;
    transition: transform 0.2s;
    margin-left: 10px;
}

.has-submenu:hover .submenu-arrow {
    color: #d4af37;
}

/* 모바일 메뉴 3차 메뉴 스타일 */
.mobile-sub-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-third-toggle {
    width: 20px;
    height: 20px;
    color: #9ca3af;
    transition: transform 0.3s ease, color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-third-toggle svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.mobile-third-menu {
    max-height: 0;
    overflow: hidden;
    list-style: none;
    padding: 0;
    margin: 0;
    border-radius: 8px;
    margin-left: 10px;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.mobile-third-menu.active {
    max-height: none;
    margin: 4px 0;
    margin-left: 20px;
}

.mobile-third-menu li a {
    display: block;
    padding: 10px 20px;
    color: #666;
    font-size: 14px;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
}

.mobile-third-menu li a:hover {
    color: #d4af37;
}

.mobile-third-toggle.active {
    transform: rotate(180deg);
    color: #d4af37;
}

/* 3차 메뉴가 활성화되었을 때 2차 메뉴 링크에 보더 바텀 */
.mobile-sub-link.has-active-third {
    border-bottom: 1px solid #d4af37 !important;
    background: #f0f0f0 !important;
    color: #d4af37 !important;
}

/* 모바일 2차 메뉴 호버 스타일 유지 (3차 메뉴 활성화시) */
.mobile-sub-link.has-active-third .mobile-third-toggle {
    color: #d4af37 !important;
}

/* 모바일 1차 메뉴 활성화 상태 (2차 메뉴가 열려있을 때) */


/* 1차 메뉴 활성화 시 토글 스타일은 active 클래스로 처리됨 */

/* 모바일 3차 메뉴 내부 링크 클릭시 2차 메뉴 활성화 해제 */
.mobile-third-menu.auto-close-parent .mobile-sub-link {
    border-bottom: none !important;
    background: transparent !important;
    color: inherit !important;
}

.mobile-third-menu.auto-close-parent .mobile-third-toggle {
    color: #9ca3af !important;
    transform: rotate(0deg) !important;
}

/* 디버깅용 - 모든 mobile-sub-link 요소 확인 */
.mobile-sub-link {
    transition: all 0.3s ease;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 2차 메뉴 호버 스타일 */
.has-submenu:hover > a {
    background: #f8f9fa;
    color: #d4af37;
    padding-left: 25px;
}

.has-submenu:hover .submenu-arrow {
    color: #d4af37;
}

.has-submenu:hover .dropdown-submenu {
    opacity: 1;
    visibility: visible;
}

/* 3차 메뉴 호버시 부모 2차 메뉴 활성화 클래스 */
.has-submenu.submenu-parent-active > a {
    background: #f8f9fa;
    color: #d4af37;
    padding-left: 25px;
}

.has-submenu.submenu-parent-active .submenu-arrow {
    color: #d4af37;
}

.has-submenu.submenu-parent-active .dropdown-submenu {
    opacity: 1;
    visibility: visible;
}

/* 검색 모달 - 원본 구조 */
.search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-modal.active {
    opacity: 1;
    visibility: visible;
}

.search-modal-content {
    background: #fff;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    padding: 40px;
    position: relative;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.search-modal.active .search-modal-content {
    transform: translateY(0);
}

.search-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 30px;
    color: #999;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.search-modal-close:hover {
    color: #666;
}

.search-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #333;
    margin: 0 0 30px 0;
    text-align: center;
}

.search-modal-container {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    position: relative;
}

.search-modal-box {
    flex: 1;
    height: 50px;
    border: 2px solid #eee;
    border-radius: 25px;
    padding: 0 20px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.search-modal-box:focus {
    outline: none;
    border-color: #d4af37;
}

.search-modal-btn {
    background: #d4af37;
    color: #fff;
    border: none;
    border-radius: 25px;
    width: 50px;
    height: 50px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-modal-btn:hover {
    background: #b8941f;
    transform: scale(1.05);
}

.search-suggestions {
    text-align: center;
}

.suggestions-title {
    font-size: 14px;
    color: #666;
    font-weight: 600;
    margin-bottom: 15px;
}

.suggestion-tags {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.suggestion-tag {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
}

.suggestion-tag:hover {
    background: #d4af37;
    color: #fff;
    border-color: #d4af37;
    transform: translateY(-2px);
}

/* ai_theme 기존 스타일과 충돌 방지 */
.main-header .container {
    max-width: none;
    padding: 0;
}

/* 반응형 디자인 */
@media screen and (max-width: 768px) {
    .top-bar .container {
        padding: 0 15px;
    }

    .center-text {
        display: none;
    }

    .top-links {
        gap: 4px;
        font-size: 11px;
    }

    .header-top {
        height: 70px;
        padding: 0 15px;
    }

    .today-gold-price {
        display: none;
    }

    .logo {
        position: static;
        transform: none;
    }

    .logo-image {
        height: 40px;
    }

    .search-area {
        min-width: auto;
    }

    .search-input {
        display: none;
    }

    .search-btn {
        display: none;
    }

    .mobile-menu-btn {
        display: block;
    }

    .nav-content {
        display: none;
    }

    .mobile-menu-btn {
        display: block;
    }
}

@media screen and (max-width: 480px) {
    .top-bar .container {
        justify-content: center;
    }
    .top-bar {
        font-size: 11px;
    }

    .business-hours span {
        display: none;
    }

    .modal-content {
        width: 95%;
        top: 15%;
    }

    .modal-header {
        padding: 15px 20px;
    }

    .modal-body {
        padding: 20px;
    }
}

/* 모바일 메뉴 열렸을 때 body 스크롤 방지 - 모바일 전용 */
@media screen and (max-width: 768px) {
    body.mobile-menu-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100vh !important;
        top: var(--scroll-y, 0) !important;
        left: 0 !important;
        touch-action: none !important;
    }

    html.mobile-menu-open {
        overflow: hidden !important;
        touch-action: none !important;
    }
}

/* 데스크톱에서는 기존 방식 */
@media screen and (min-width: 769px) {
    body.mobile-menu-open {
        overflow: hidden !important;
    }
}