/*
 * header-common.css
 * Shared header styles for layout + platform pages.
 * Source: core/style.css + core/mobile-style.css (header-only rules).
 */

:root {
    --platform-header-height: var(--header-height, 80px);
}

body.has-platform-header {
    padding-top: var(--platform-header-height, 80px);
}

/* Header - Enhanced Transparency with Navigation */
.main-header {
    height: var(--header-height, 80px);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    z-index: 1000;
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
}

[data-theme="dark"] .main-header {
    background: rgba(18, 18, 18, 0.7);
}

.main-header.scrolled {
    border-color: var(--border, #e9ecef);
    background: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .main-header.scrolled {
    background: rgba(18, 18, 18, 0.9);
}

.header-inner {
    max-width: 100%;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    /* 양끝 정렬 복구 */
    padding: 0 2rem;
    position: relative;
    /* 자식 요소 absolute 기준점 */
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.logo-image {
    height: 80px;
    width: auto;
    display: block;
}

.brand-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 2;
}

/* 중앙 그룹 (메뉴 + 검색) */
.nav-center-group {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 2rem;
    height: 100%;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 2rem;
    height: 100%;
    /* margin-left 제거 */
}

.nav-link {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary, #121212);
    transition: color 0.2s ease;
    position: relative;
    text-decoration: none;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--text-primary, #121212);
    transition: width 0.3s ease;
}

.nav-link:hover {
    color: var(--text-secondary, #6c757d);
}

.nav-link:hover::after {
    width: 100%;
}

.main-header a {
    text-decoration: none;
    color: inherit;
}

.logo {
    text-decoration: none;
    color: inherit;
}

.search-container {
    flex: 1;
    max-width: 400px;
    margin: 0 2rem;
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid var(--border, #e9ecef);
    border-radius: 100px;
    background-color: var(--bg-secondary, #f8f9fa);
    padding: 0.25rem 0.5rem;
    transition: all 0.2s ease;
}

.search-container:focus-within {
    border-color: var(--text-primary, #121212);
    background-color: var(--bg-primary, #ffffff);
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .search-container:focus-within {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05);
}

.search-input {
    flex: 1;
    width: 100%;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-primary, #121212);
    font-family: var(--font-main, 'Inter', -apple-system, BlinkMacSystemFont, sans-serif);
    font-size: 0.95rem;
}

.search-input:focus {
    outline: none;
    box-shadow: none;
}

.search-submit-btn {
    background: none;
    border: none;
    color: var(--text-secondary, #6c757d);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.search-submit-btn:hover {
    color: var(--text-primary, #121212);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    /* margin-left: auto 제거 -> 부모의 space-between에 의존 */
    height: 100%;
}

.platform-header .nav-actions {
    position: relative;
}

.platform-header .platform-header-owner {
    display: inline-flex;
    align-items: center;
    max-width: min(36vw, 420px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary, #121212);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.platform-header .platform-header-owner a {
    color: inherit;
    text-decoration: none;
    pointer-events: auto;
}

.platform-header .platform-header-owner a:hover {
    opacity: 0.72;
}

[data-theme="dark"] .platform-header .platform-header-owner {
    color: rgba(255, 255, 255, 0.92);
}

.platform-header .shared-header-menu-btn {
    border: none;
    background: transparent;
    padding: 0;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.platform-header .shared-header-menu {
    width: 28px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.platform-header .shared-header-menu i {
    display: block;
    width: 100%;
    height: 2px;
    background: rgba(38, 38, 38, 0.78);
    border-radius: 999px;
}

[data-theme="dark"] .platform-header .shared-header-menu i {
    background: rgba(255, 255, 255, 0.82);
}

.platform-header .shared-header-dropdown {
    position: absolute;
    top: calc(100% - 6px);
    right: 0;
    width: 132px;
    border: 1px solid rgba(38, 38, 38, 0.12);
    border-radius: 14px;
    background: #f3f3f1;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    display: none;
    z-index: 50;
}

[data-theme="dark"] .platform-header .shared-header-dropdown {
    background: rgba(33, 33, 33, 0.96);
    border-color: rgba(255, 255, 255, 0.12);
}

.platform-header .shared-header-dropdown.is-open {
    display: block;
}

.platform-header .shared-header-dropdown-action,
.platform-header .shared-header-dropdown-link,
.platform-header .shared-header-dropdown-form button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border: none;
    border-top: 1px solid rgba(38, 38, 38, 0.12);
    background: transparent;
    color: rgba(38, 38, 38, 0.62);
    text-decoration: none;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

[data-theme="dark"] .platform-header .shared-header-dropdown-action,
[data-theme="dark"] .platform-header .shared-header-dropdown-link,
[data-theme="dark"] .platform-header .shared-header-dropdown-form button {
    border-top-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.72);
}

.platform-header .shared-header-dropdown > :first-child {
    border-top: none;
}

.platform-header .shared-header-dropdown-form {
    margin: 0;
}

.platform-header .shared-header-dropdown-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(38, 38, 38, 0.72);
    flex: 0 0 auto;
}

[data-theme="dark"] .platform-header .shared-header-dropdown-icon {
    color: rgba(255, 255, 255, 0.74);
}

/* Platform Header: hide nav/search, keep auth + hamburger */
.platform-header .nav-center-group {
    display: none !important;
}

.platform-header .mobile-menu-btn {
    display: flex !important;
}

.platform-header-readonly,
.platform-header-readonly * {
    user-select: none;
    -webkit-user-select: none;
}

.platform-header-readonly {
    pointer-events: none !important;
}

.platform-header-readonly a,
.platform-header-readonly button,
.platform-header-readonly input,
.platform-header-readonly [role="button"],
.platform-header-readonly [tabindex] {
    pointer-events: none !important;
    cursor: default !important;
}

.platform-header-readonly-page .platform-header-readonly-overlay {
    display: none !important;
}

.has-platform-header .global-sidebar .sidebar-nav-links {
    display: block;
}

.login-btn {
    height: 40px;
    /* 고정 높이 */
    padding: 0 1.25rem;
    /* 상하 패딩 대신 높이 사용 */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border, #e9ecef);
    border-radius: 100px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    background: transparent;
    color: var(--text-primary, #121212);
    text-decoration: none;
    /* 링크 태그일 경우 대비 */
    box-sizing: border-box;
}

.login-btn:hover {
    background: var(--text-primary, #121212);
    color: var(--bg-primary, #ffffff);
    border-color: var(--text-primary, #121212);
}

.theme-btn {
    background: none;
    border: none;
    color: var(--text-primary, #121212);
    cursor: pointer;
    padding: 0;
    width: 40px;
    /* 고정 크기 */
    height: 40px;
    /* 고정 크기 */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.theme-btn:hover {
    background-color: var(--bg-secondary, #f8f9fa);
}

/* Mobile Menu Toggle Button */
.mobile-menu-btn {
    display: flex;
    background: none;
    border: none;
    color: var(--text-primary, #121212);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.mobile-menu-btn:hover {
    background-color: transparent;
}

/* ========================================
   사이드바 내 네비게이션 링크 (반응형)
   - 기본: 숨김 (헤더 메뉴가 보이므로)
   - 1024px 이하: 표시 (헤더 메뉴가 숨겨지므로)
   ======================================== */
.global-sidebar .sidebar-nav-links {
    display: none;
}

.global-sidebar .sidebar-profile {
    text-align: center;
}

.global-sidebar .sidebar-search-btn {
    margin: 1.25rem auto 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.8rem;
    border-radius: 999px;
    border: 1px solid var(--text-primary, #121212);
    background: var(--text-primary, #121212);
    color: var(--bg-primary, #ffffff);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.global-sidebar .sidebar-search-btn svg {
    width: 18px;
    height: 18px;
}

.global-sidebar .sidebar-search-btn:hover {
    background: #000000;
    border-color: #000000;
}

/* Mobile Styles */
@media (max-width: 1024px) {
    .main-nav {
        display: none;
    }

    /* 헤더 메뉴가 숨겨지면 사이드바에 표시 */
    .global-sidebar .sidebar-nav-links {
        display: block;
    }

    /* 모바일에서는 중앙 정렬 해제 */
    .nav-center-group {
        position: static;
        transform: none;
        display: flex;
        align-items: center;
    }

    .mobile-menu-btn {
        display: block;
    }
}

@media (max-width: 768px) {
    .header-inner {
        padding: 0 10px !important;
        justify-content: space-between !important;
        /* 모바일은 space-between 유지 */
    }

    .brand-wrapper {
        gap: 0.5rem !important;
    }

    .platform-header .platform-header-owner {
        max-width: 46vw;
        font-size: 0.92rem;
    }

    .search-container {
        display: none !important;
    }

    /* 모바일에서는 검색 버튼 텍스트 숨김 */
    .search-pill-btn .search-text {
        display: none !important;
    }

    .search-pill-btn {
        padding: 0.5rem !important;
        /* 원형으로 축소 */
        gap: 0 !important;
        margin-left: 0 !important;
        background: transparent !important;
        border: none !important;
    }

    .nav-actions {
        gap: 0.5rem !important;
        margin-left: 0 !important;
        /* 모바일에서는 자동 마진 제거 */
    }

    .login-btn {
        display: none;
    }

    button,
    a {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 560px) {
    .platform-header .platform-header-owner {
        max-width: 42vw;
        font-size: 0.84rem;
    }
}

@media (min-width: 1025px) {
    body:has(#dashboardSidebar) .mobile-menu-btn {
        display: none !important;
    }
}

/* ========================================
   검색 아이콘 버튼 & 오버레이
   ======================================== */

/* 기존 search-container 숨김 */
.search-container {
    display: none;
}

/* 검색 알약 버튼 (Capsule/Pill Button) */
.search-pill-btn {
    background: var(--bg-secondary, #f8f9fa);
    border: 1px solid transparent;
    cursor: pointer;
    padding: 0 1rem;
    /* 상하 패딩 제거, 높이로 제어 */
    height: 40px;
    /* 고정 높이 40px */
    color: var(--text-secondary, #6c757d);
    display: inline-flex;
    /* flex -> inline-flex */
    align-items: center;
    gap: 0.5rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-left: 1rem;
    box-sizing: border-box;
}

.search-pill-btn:hover {
    background-color: var(--border, #e9ecef);
    color: var(--text-primary, #121212);
}

.search-pill-btn .search-text {
    display: block;
}

[data-theme="dark"] .search-pill-btn {
    background: var(--bg-secondary, #1e1e1e);
    color: var(--text-secondary, #adb5bd);
}

[data-theme="dark"] .search-pill-btn:hover {
    background: #2d2d2d;
    color: #ffffff;
}

/* 검색 오버레이 */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
}


.search-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.search-overlay-content {
    position: relative;
    width: 90%;
    max-width: 600px;
    z-index: 1;
}

.search-overlay-form {
    display: flex;
    align-items: center;
    background: var(--bg-primary, #ffffff);
    border-radius: 16px;
    padding: 1rem 1.5rem;
    gap: 1rem;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .search-overlay-form {
    background: var(--bg-secondary, #1e1e1e);
}

.search-overlay-icon {
    color: var(--text-secondary, #6c757d);
    flex-shrink: 0;
}

.search-overlay-form input {
    flex: 1;
    border: none;
    background: none;
    font-size: 1.25rem;
    outline: none;
    color: var(--text-primary, #121212);
    font-family: var(--font-main, 'Inter', sans-serif);
}

.search-overlay-form input::placeholder {
    color: var(--text-secondary, #6c757d);
}

.search-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary, #6c757d);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.search-close-btn:hover {
    background: var(--bg-secondary, #f8f9fa);
    color: var(--text-primary, #121212);
}

.search-hint {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

/* 모바일에서 검색 오버레이 조정 */
@media (max-width: 768px) {
    .search-overlay-form {
        padding: 0.875rem 1rem;
        border-radius: 12px;
    }

    .search-overlay-form input {
        font-size: 1rem;
    }

    .search-hint {
        font-size: 0.75rem;
    }
}
