/* ========== 공통 헤더 컴포넌트 스타일 ========== */

/* 헤더 기본 스타일 */
.header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: #ffffff;
    border-bottom: 1px solid #4E63D9;
    box-shadow: 0 2px 5px rgba(29, 38, 89, 0.1);
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

/* 로고 스타일 */
.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-mark {
    background: #4E63D9;
    color: #ffffff;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 800;
    border: 2px solid #4E63D9;
    box-shadow: 0 2px 8px rgba(78, 99, 217, 0.3);
    transition: transform 0.2s;
}

.logo:hover .logo-mark {
    transform: scale(1.05);
}

/* 네비게이션 메뉴 - 모바일 우선 */
.nav {
    display: none; /* 기본적으로 숨김 */
    flex-direction: column;
    background: #ffffff;
    width: 100%;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    margin: 0;
    margin-left: 0;
}

.nav.active {
    display: flex;
    max-height: 2000px; /* 충분히 큰 값 */
    width: 100%;
}

.nav-category {
    border-bottom: 1px solid #e8e8e8;
    padding: 0;
}

.nav-category:last-child {
    border-bottom: none;
}

.nav-category-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #4E63D9;
    background: #f8f9ff;
    padding: 0.8rem 1.5rem;
    margin: 0;
    cursor: default;
    user-select: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-left: 3px solid #4E63D9;
}

.nav-category-links {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0;
    background: #ffffff;
}

.nav-category-links a {
    color: #2E3C8C;
    font-weight: 500;
    font-size: 0.95rem;
    text-decoration: none;
    padding: 0.8rem 1.5rem 0.8rem 2.5rem;
    transition: all 0.2s;
    display: block;
    position: relative;
}

.nav-category-links a::before {
    content: '›';
    position: absolute;
    left: 1.5rem;
    color: #4E63D9;
    font-weight: bold;
    opacity: 0;
    transition: all 0.2s;
}

.nav-category-links a:hover,
.nav-category-links a:active {
    background: #f5f7ff;
    color: #4E63D9;
    padding-left: 2.8rem;
}

.nav-category-links a:hover::before,
.nav-category-links a:active::before {
    opacity: 1;
    left: 1.8rem;
}

/* 데스크탑 스타일 */
@media (min-width: 1024px) {
    .nav {
        display: flex !important;
        flex-direction: row;
        max-height: none;
        overflow: visible;
        flex: 1;
        justify-content: center;
        gap: 2.5rem;
        background: transparent;
        width: auto;
    }

    .nav-category {
        position: relative;
        border-bottom: none;
        padding: 0;
        border-left: none;
    }

    .nav-category-title {
        font-size: 0.75rem;
        font-weight: 600;
        color: #4E63D9;
        background: transparent;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin: 0;
        padding: 0.5rem 0.8rem;
        cursor: pointer;
        white-space: nowrap;
        border-left: none;
        border-radius: 6px;
        transition: all 0.2s;
    }

    .nav-category-title:hover {
        background: #f5f7ff;
        color: #2E3C8C;
    }

    .nav-category-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        background: #ffffff;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
        padding: 0.8rem;
        min-width: 200px;
        z-index: 100;
        margin-top: 0.5rem;
    }

    .nav-category:hover .nav-category-links {
        display: flex;
        flex-direction: column;
    }

    .nav-category-links a {
        padding: 0.7rem 1rem;
        white-space: nowrap;
        font-size: 0.9rem;
        border-radius: 6px;
    }

    .nav-category-links a::before {
        display: none;
    }

    .nav-category-links a:hover {
        background: #f5f7ff;
        color: #4E63D9;
        padding-left: 1rem;
        transform: translateX(5px);
    }
}

/* 모바일 토글 버튼 */
.nav-toggle {
    display: flex; /* 기본적으로 표시 (모바일 우선) */
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1001;
    position: relative;
}

.nav-toggle span {
    width: 26px;
    height: 3px;
    background: #1D2659;
    border-radius: 3px;
    transition: all 0.3s ease;
    display: block;
}

.nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* 데스크탑에서 토글 버튼 숨김 */
@media (min-width: 1024px) {
    .nav-toggle {
        display: none;
    }
}

/* 태블릿 & 모바일 반응형 */
@media (max-width: 1023px) {
    .header {
        position: fixed;
        width: 100%;
        top: 0;
        left: 0;
        z-index: 1000;
        background: #ffffff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    .header-inner {
        padding: 0.8rem 1.2rem;
        flex-wrap: wrap;
    }

    .logo-mark {
        font-size: 1rem;
        padding: 0.4rem 0.7rem;
    }

    /* 모바일 메뉴 - 위에서 아래로 펼쳐지는 드롭다운 */
    .nav {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: #ffffff;
        border-top: 1px solid #e0e0e0;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s ease;
        z-index: 999;
    }

    .nav.active {
        max-height: calc(100vh - 56px);
        overflow-y: auto;
    }

    .nav-category {
        border-bottom: 1px solid #e8e8e8;
    }

    .nav-category:last-child {
        border-bottom: none;
    }

    .nav-category-title {
        font-size: 0.8rem;
        font-weight: 700;
        color: #4E63D9;
        background: #f8f9ff;
        padding: 0.8rem 1.5rem;
        border-left: 3px solid #4E63D9;
    }

    .nav-category-links {
        display: flex !important;
        flex-direction: column;
        padding: 0.5rem 0;
        background: #ffffff;
    }

    .nav-category-links a {
        font-size: 0.95rem;
        padding: 0.8rem 1.5rem 0.8rem 2.5rem;
        color: #2E3C8C;
    }

    .nav-category-links a::before {
        content: '›';
        position: absolute;
        left: 1.5rem;
        color: #4E63D9;
        font-weight: bold;
        opacity: 0;
    }

    .nav-category-links a:hover,
    .nav-category-links a:active {
        background: #f5f7ff;
        color: #4E63D9;
        padding-left: 2.8rem;
    }

    .nav-category-links a:hover::before,
    .nav-category-links a:active::before {
        opacity: 1;
        left: 1.8rem;
    }

    /* body에 여백 추가 (고정 헤더 때문에) */
    body {
        padding-top: 56px;
    }
}

/* 작은 모바일 */
@media (max-width: 480px) {
    .header-inner {
        padding: 0.8rem 1rem;
    }

    .logo-mark {
        font-size: 0.9rem;
        padding: 0.35rem 0.6rem;
    }

    .nav-category-title {
        font-size: 0.8rem;
        padding: 0.8rem 1rem 0.4rem;
    }

    .nav-category-links a {
        font-size: 0.9rem;
        padding: 0.65rem 1rem 0.65rem 1.5rem;
    }

    body {
        padding-top: 56px;
    }
}
