/* ==========================================
   글로벌 네비게이션 바 (모든 페이지 공통)
   ========================================== */

:root {
    --global-nav-height: 42px;
}

/* 글로벌 바 */
.global-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--global-nav-height);
    background: #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 500;
    font-family: 'Noto Sans KR', 'Inter', sans-serif;
}

.global-nav-left {
    display: flex;
    align-items: center;
    gap: 4px;
}

.global-nav-left a {
    text-decoration: none;
    color: #94a3b8;
    font-size: 0.82rem;
    font-weight: 500;
    padding: 5px 14px;
    border-radius: 5px;
    transition: all 0.15s;
    white-space: nowrap;
}

.global-nav-left a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.global-nav-left a.active {
    color: #ffffff;
    font-weight: 600;
}

.global-nav-divider {
    width: 1px;
    height: 14px;
    background: #334155;
    margin: 0 4px;
}

.global-nav-right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.global-nav-right a {
    text-decoration: none;
    color: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 5px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.global-nav-right a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

#globalNavGuest {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 로그인 후 사용자 */
.global-nav-user {
    display: none;
    align-items: center;
    gap: 8px;
}

.global-nav-user .user-name-link {
    text-decoration: none;
    color: #e2e8f0;
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.15s;
}

.global-nav-user .user-name-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.global-nav-user .user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #ffffff;
}

.global-nav-user button {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid #94a3b8;
    color: #e2e8f0;
    font-size: 0.82rem;
    padding: 5px 14px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.global-nav-user button:hover {
    color: #ffffff;
    border-color: #64748b;
}

.global-nav-user .btn-admin-link {
    text-decoration: none;
    color: #e9d5ff;
    font-size: 0.82rem;
    padding: 5px 14px;
    border: 1px solid #a78bfa;
    border-radius: 5px;
    transition: all 0.15s;
    background: rgba(139, 92, 246, 0.25);
    font-weight: 600;
}

.global-nav-user .btn-admin-link:hover {
    background: rgba(139, 92, 246, 0.1);
    color: #c4b5fd;
}

/* ==========================================
   검색 기능
   ========================================== */
.gnav-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.gnav-search-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: all 0.15s;
}

.gnav-search-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.gnav-search-box {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    display: flex;
    align-items: center;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: all 0.2s ease;
    z-index: 600;
}

.gnav-search-box.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.gnav-search-box input {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 14px;
    font-size: 0.85rem;
    font-family: 'Noto Sans KR', sans-serif;
    color: #1e293b;
    background: transparent;
}

.gnav-search-box input::placeholder {
    color: #94a3b8;
}

.gnav-search-box button {
    background: #2563eb;
    border: none;
    color: #ffffff;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: background 0.15s;
}

.gnav-search-box button:hover {
    background: #1d4ed8;
}

/* ==========================================
   햄버거 버튼 (모바일)
   ========================================== */
.gnav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    margin-left: 4px;
}

.gnav-hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: #94a3b8;
    border-radius: 2px;
    transition: all 0.3s;
}

.gnav-hamburger.open span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.gnav-hamburger.open span:nth-child(2) {
    opacity: 0;
}

.gnav-hamburger.open span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

/* ==========================================
   모바일 메뉴 오버레이 & 슬라이드
   ========================================== */
.gnav-mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s;
}

.gnav-mobile-overlay.open {
    opacity: 1;
}

.gnav-mobile-menu {
    display: none;
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100vh;
    background: #ffffff;
    z-index: 999;
    overflow-y: auto;
    transition: right 0.3s ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.1);
}

.gnav-mobile-menu.open {
    right: 0;
}

.gnav-mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
}

.gnav-mobile-header strong {
    font-size: 1rem;
    color: #1e293b;
}

.gnav-mobile-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

/* 모바일 사용자 영역 */
.gnav-mobile-user {
    padding: 20px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.gnav-mobile-guest {
    display: flex;
    gap: 8px;
}

.gnav-mobile-btn-login {
    flex: 1;
    text-align: center;
    padding: 10px;
    background: #2563eb;
    color: #ffffff !important;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
}

.gnav-mobile-btn-signup {
    flex: 1;
    text-align: center;
    padding: 10px;
    background: #ffffff;
    color: #1e293b !important;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.gnav-mobile-logged {
    display: flex;
    align-items: center;
    gap: 12px;
}

.gnav-mobile-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2563eb;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}

.gnav-mobile-logged strong {
    display: block;
    font-size: 0.95rem;
    color: #1e293b;
}

.gnav-mobile-logged small {
    display: block;
    font-size: 0.78rem;
    color: #94a3b8;
    margin-top: 2px;
}

/* 모바일 메뉴 링크 */
.gnav-mobile-links {
    display: flex;
    flex-direction: column;
    padding: 12px 0;
}

.gnav-mobile-links a {
    display: block;
    padding: 14px 20px;
    font-size: 0.95rem;
    color: #374151;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.15s;
}

.gnav-mobile-links a:hover,
.gnav-mobile-links a.active {
    background: #f1f5f9;
    color: #2563eb;
}

.gnav-mobile-extra {
    border-top: 1px solid #e2e8f0;
    padding: 12px 0;
}

.gnav-mobile-extra a {
    display: block;
    padding: 14px 20px;
    font-size: 0.95rem;
    color: #374151;
    text-decoration: none;
    font-weight: 500;
}

.gnav-mobile-extra a:hover {
    background: #f1f5f9;
}

.gnav-mobile-extra button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 14px 20px;
    font-size: 0.95rem;
    color: #dc2626;
    background: none;
    border: none;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
}

.gnav-mobile-extra button:hover {
    background: #fef2f2;
}

/* ==========================================
   기존 레이아웃 오프셋
   ========================================== */
body.has-global-nav .left-sidebar {
    top: var(--global-nav-height);
    height: calc(100vh - var(--global-nav-height));
}

body.has-global-nav .right-sidebar {
    top: var(--global-nav-height);
    height: calc(100vh - var(--global-nav-height));
}

body.has-global-nav .top-header {
    top: var(--global-nav-height);
}

body.has-global-nav .machine-selection-bar {
    top: calc(var(--global-nav-height) + var(--header-height));
}

body.has-global-nav .main-wrapper {
    padding-top: calc(var(--global-nav-height) + var(--header-height) + var(--selection-bar-height));
}

body.has-global-nav.standalone-page {
    display: block;
    padding-top: var(--global-nav-height);
}

/* ==========================================
   반응형 - 태블릿
   ========================================== */
@media (max-width: 1024px) {
    .global-nav {
        padding: 0 16px;
    }

    body.has-global-nav .left-sidebar {
        top: var(--global-nav-height);
        height: auto;
    }

    body.has-global-nav .main-wrapper {
        padding-top: 0;
    }
}

/* ==========================================
   반응형 - 모바일 (768px 이하)
   ========================================== */
@media (max-width: 768px) {
    .global-nav {
        padding: 0 12px;
    }

    .global-nav-left a {
        font-size: 0.68rem;
        padding: 4px 6px;
    }

    .global-nav-divider {
        display: none;
    }

    /* 데스크톱 전용 숨기기 */
    .gnav-desktop-only {
        display: none !important;
    }

    /* 햄버거 표시 */
    .gnav-hamburger {
        display: flex;
    }

    /* 모바일 메뉴/오버레이 표시 가능하게 */
    .gnav-mobile-overlay {
        display: block;
        pointer-events: none;
    }

    .gnav-mobile-overlay.open {
        pointer-events: auto;
    }

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

    .gnav-search-box {
        width: 260px;
        right: -8px;
    }

    /* 글로벌 네비가 있을 때 대시보드 레이아웃 모바일 대응 */
    body.has-global-nav .left-sidebar {
        display: none;
    }

    body.has-global-nav .right-sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 24px 20px;
        justify-content: flex-start;
        border-left: none;
        border-top: 1px solid #e2e8f0;
    }

    body.has-global-nav .right-sidebar .panel-header {
        font-size: 0.7rem;
        margin-bottom: 10px;
    }

    body.has-global-nav .right-sidebar .inquiry-box h3 {
        font-size: 1.2rem;
        margin-bottom: 6px;
    }

    body.has-global-nav .right-sidebar .inquiry-box p {
        font-size: 0.85rem;
        margin-bottom: 16px;
    }

    body.has-global-nav .right-sidebar .contact-info {
        margin-top: 16px;
        font-size: 0.85rem;
    }

    body.has-global-nav .right-sidebar .btn-inquiry {
        padding: 14px;
        font-size: 0.95rem;
        max-width: 320px;
        margin: 0 auto;
    }

    body.has-global-nav .main-wrapper {
        margin-left: 0;
        margin-right: 0;
        padding-top: var(--global-nav-height);
    }

    body.has-global-nav .top-header {
        left: 0;
        right: 0;
        top: var(--global-nav-height);
    }

    body.has-global-nav .machine-selection-bar {
        left: 0;
        right: 0;
    }
}

/* ==========================================
   반응형 - 소형 모바일 (480px 이하)
   ========================================== */
@media (max-width: 480px) {
    .global-nav-left {
        gap: 0;
    }

    .global-nav-left a {
        font-size: 0.65rem;
        padding: 4px 5px;
    }

    .gnav-search-box {
        width: 220px;
    }
}
