/* ========== 슬림 헤더 스타일 ========== */

/* 기존 header 스타일 리셋 */
header.slim-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--color-bg-card);
  padding: 0 24px;
  height: 56px;
  border-radius: 0;
  margin-bottom: 20px;
  box-shadow: none;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: box-shadow 0.2s ease;
}

header.slim-header.scrolled {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] header.slim-header.scrolled {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* 기존 header h1, p 숨기기 */
header.slim-header h1,
header.slim-header p {
  display: none;
}

/* ========== 로고 영역 ========== */
.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.header-logo .logo-img {
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.header-logo .logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.5px;
}

.header-logo:hover .logo-text {
  color: var(--color-primary);
}

/* ========== 네비게이션 ========== */
.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.header-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
  position: relative;
}

.header-nav .nav-item:hover {
  color: var(--color-text-primary);
  background: var(--color-gray-100);
}

.header-nav .nav-item.active {
  color: var(--color-primary);
  background: rgba(99, 102, 241, 0.1);
}

.header-nav .nav-item.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  background: var(--color-primary);
  border-radius: 1px;
}

.header-nav .nav-icon {
  font-size: 16px;
}

.header-nav .nav-label {
  font-size: 13px;
}

/* 데스크톱에서는 모바일 전용 컨트롤을 숨긴다. */
.mobile-menu-toggle,
.nav-submenu-toggle,
.gnb-backdrop {
  display: none;
}

/* ========== GNB 드롭다운 (고객 hover 메뉴) ========== */
.header-nav .nav-dropdown {
  position: relative;
  display: flex;
  align-items: center;
}

.header-nav .nav-submenu {
  position: absolute;
  top: 100%;
  left: 50%;
  margin-top: 6px;
  min-width: 132px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%) translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 1200;
}

/* nav-item 과 서브메뉴 사이 hover 끊김 방지용 투명 브리지 */
.header-nav .nav-submenu::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 0;
  right: 0;
  height: 6px;
}

.header-nav .nav-dropdown:hover .nav-submenu,
.header-nav .nav-dropdown:focus-within .nav-submenu {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.header-nav .nav-submenu-item {
  display: block;
  padding: 9px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.header-nav .nav-submenu-item:hover {
  background: var(--color-gray-100);
  color: var(--color-primary);
}

/* ========== 액션 영역 ========== */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* 헤더 버튼 공통 */
.header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.header-btn:hover {
  background: var(--color-gray-100);
  color: var(--color-text-primary);
}

.header-actions .guide-btn {
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--color-border);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.header-actions .guide-btn[aria-current="page"] {
  color: var(--color-primary);
  background: var(--color-gray-100);
}

.header-actions .guide-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* .header-btn 공통 display 선언보다 우선해 데스크톱에서는 햄버거를 숨긴다. */
header.slim-header .mobile-menu-toggle {
  display: none;
}

/* 알림 버튼 */
.notification-btn {
  position: relative;
}

.notification-btn .btn-icon {
  font-size: 18px;
}

.notification-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--color-danger);
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 피드백/알림 버튼 — 현재 노출 비활성화 (요청 시 다시 노출) */
.feedback-btn,
#notificationDropdown {
  display: none !important;
}

/* 피드백 버튼 (오픈카톡) */
.feedback-btn {
  text-decoration: none;
  padding: 6px 12px;
  background: #FEE500;
  color: #3C1E1E;
  border-radius: 6px;
  font-weight: 500;
}

.feedback-btn:hover {
  background: #F5DC00;
  color: #3C1E1E;
}

.feedback-btn .btn-icon {
  font-size: 14px;
}

.feedback-btn .btn-label {
  font-size: 13px;
}

/* 테마 버튼 (다크모드 비활성화로 숨김) */
.theme-btn {
  display: none !important;
}

.theme-btn .icon-light,
.theme-btn .icon-dark {
  font-size: 18px;
}

/* 라이트 모드: 달 아이콘 표시 */
.theme-btn .icon-light {
  display: none;
}
.theme-btn .icon-dark {
  display: block;
}

/* 다크 모드: 해 아이콘 표시 */
[data-theme="dark"] .theme-btn .icon-light {
  display: block;
}
[data-theme="dark"] .theme-btn .icon-dark {
  display: none;
}

/* 사용자 버튼 */
.user-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg-card);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.user-btn:hover {
  background: var(--color-gray-50, #f8f9fa);
  border-color: var(--color-text-light);
}

.user-btn .user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-btn .user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
  min-width: 0;
}

.user-btn .user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-btn .user-role {
  font-size: 10px;
  font-weight: 500;
  color: var(--color-text-light);
  margin-top: 2px;
}

.user-btn .user-role:empty {
  display: none;
}

.user-btn .dropdown-arrow {
  font-size: 11px;
  color: var(--color-text-light);
  transition: transform 0.2s;
  margin-left: 2px;
}

.header-dropdown.open .dropdown-arrow {
  transform: rotate(180deg);
}

/* 사용자 메뉴 드롭다운 */
.user-dropdown .dropdown-menu.user-menu {
  min-width: 200px;
  padding: 6px;
}

.user-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--color-text-primary);
  text-decoration: none;
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
  text-align: left;
}

.user-menu .dropdown-item:hover {
  background: var(--color-gray-100);
}

.user-menu .dropdown-icon {
  font-size: 15px;
  width: 18px;
  display: inline-flex;
  justify-content: center;
}

.user-menu .dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: 4px 2px;
}

.user-menu .dropdown-item.logout-item {
  color: var(--color-danger);
}

.user-menu .dropdown-item.logout-item:hover {
  background: rgba(239, 68, 68, 0.08);
}

/* 모바일 — 이름/역할 텍스트 숨기고 아바타만 노출 */
@media (max-width: 640px) {
  .user-btn .user-info,
  .user-btn .dropdown-arrow {
    display: none;
  }
  .user-btn {
    padding: 4px;
    border-radius: 50%;
  }
}

/* ========== 드롭다운 메뉴 공통 ========== */
.header-dropdown {
  position: relative;
}

/* 헤더 드롭다운 메뉴 — styles.css의 레거시 `.dropdown-menu { display:none }`을 덮으려고
   `.header-dropdown` 스코프로 specificity 올림. display는 항상 block, 가시성은 opacity+visibility로 토글. */
.header-dropdown .dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: auto;
  right: 0;
  min-width: 200px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  display: block;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 1000;
  pointer-events: none;
}

[data-theme="dark"] .header-dropdown .dropdown-menu {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.header-dropdown.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.dropdown-header .btn-text {
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--color-primary);
  cursor: pointer;
}

.dropdown-header .btn-text:hover {
  text-decoration: underline;
}

.dropdown-body {
  max-height: 300px;
  overflow-y: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  color: var(--color-text-primary);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}

.dropdown-item:hover {
  background: var(--color-gray-100);
}

.dropdown-item.logout-item {
  color: var(--color-danger);
}

.dropdown-divider {
  height: 1px;
  background: var(--color-border);
  margin: 4px 0;
}

/* ========== 알림 드롭다운 ========== */
.notification-menu {
  width: 320px;
}

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-table-border);
  cursor: pointer;
  transition: background 0.15s;
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-item:hover {
  background: var(--color-gray-50);
}

.notification-item.unread {
  background: rgba(99, 102, 241, 0.05);
}

.notification-item.unread::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  background: var(--color-primary);
  border-radius: 50%;
}

.notification-item .notif-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.notification-item .notif-content {
  flex: 1;
  min-width: 0;
}

.notification-item .notif-message {
  font-size: 13px;
  color: var(--color-text-primary);
  line-height: 1.4;
  margin-bottom: 4px;
}

.notification-item .notif-time {
  font-size: 11px;
  color: var(--color-text-light);
}

.empty-notification {
  padding: 24px 16px;
  text-align: center;
  color: var(--color-text-light);
  font-size: 13px;
}

/* ========== 태블릿/모바일 GNB ========== */
@media (max-width: 1024px) {
  body.gnb-open {
    overflow: hidden;
  }

  header.slim-header {
    gap: 12px;
    padding: 0 14px;
  }

  header.slim-header > .header-actions {
    gap: 6px;
    margin-left: auto;
  }

  header.slim-header .mobile-menu-toggle {
    display: inline-flex;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg-card);
  }

  .mobile-menu-toggle:hover {
    border-color: var(--color-text-light);
  }

  .mobile-menu-toggle:focus-visible,
  .nav-submenu-toggle:focus-visible,
  .header-nav a:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
  }

  .hamburger-lines {
    position: relative;
    display: block;
    width: 19px;
    height: 14px;
  }

  .hamburger-lines span {
    position: absolute;
    left: 0;
    width: 19px;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
    transition: top 0.2s ease, transform 0.2s ease, opacity 0.15s ease;
  }

  .hamburger-lines span:nth-child(1) { top: 0; }
  .hamburger-lines span:nth-child(2) { top: 6px; }
  .hamburger-lines span:nth-child(3) { top: 12px; }

  header.slim-header.nav-open .hamburger-lines span:nth-child(1) {
    top: 6px;
    transform: rotate(45deg);
  }

  header.slim-header.nav-open .hamburger-lines span:nth-child(2) {
    opacity: 0;
  }

  header.slim-header.nav-open .hamburger-lines span:nth-child(3) {
    top: 6px;
    transform: rotate(-45deg);
  }

  .header-nav {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 4px;
    max-height: calc(100dvh - 88px);
    padding: 10px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 2;
  }

  [data-theme="dark"] .header-nav {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  }

  header.slim-header.nav-open .header-nav {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
  }

  .header-nav .nav-item {
    width: 100%;
    min-height: 44px;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 15px;
  }

  .header-nav .nav-item.active::after {
    top: 50%;
    bottom: auto;
    left: 0;
    width: 3px;
    height: 24px;
    transform: translateY(-50%);
    border-radius: 0 2px 2px 0;
  }

  .header-nav .nav-icon {
    display: inline-flex;
    justify-content: center;
    width: 22px;
    font-size: 20px;
  }

  .header-nav .nav-label {
    font-size: 15px;
  }

  .header-nav .nav-dropdown {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: center;
    width: 100%;
  }

  .header-nav .nav-dropdown > .nav-item {
    grid-column: 1;
    grid-row: 1;
  }

  .nav-submenu-toggle {
    display: inline-flex;
    grid-column: 2;
    grid-row: 1;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 17px;
    cursor: pointer;
  }

  .nav-submenu-toggle:hover {
    color: var(--color-text-primary);
    background: var(--color-gray-100);
  }

  .nav-submenu-toggle svg {
    transition: transform 0.2s ease;
  }

  .header-nav .nav-dropdown.submenu-open .nav-submenu-toggle svg {
    transform: rotate(180deg);
  }

  .header-nav .nav-submenu,
  .header-nav .nav-dropdown:hover .nav-submenu,
  .header-nav .nav-dropdown:focus-within .nav-submenu {
    position: static;
    grid-column: 1 / -1;
    min-width: 0;
    max-height: 0;
    margin: 0;
    padding: 0 6px;
    overflow: hidden;
    border: 0;
    border-radius: 8px;
    box-shadow: none;
    background: var(--color-gray-50);
    opacity: 0;
    visibility: hidden;
    transform: none;
    transition: max-height 0.2s ease, margin 0.2s ease, padding 0.2s ease, opacity 0.15s ease, visibility 0.2s;
  }

  .header-nav .nav-dropdown.submenu-open .nav-submenu,
  .header-nav .nav-dropdown.submenu-open:hover .nav-submenu,
  .header-nav .nav-dropdown.submenu-open:focus-within .nav-submenu {
    max-height: 120px;
    margin: 2px 0 4px;
    padding: 6px;
    opacity: 1;
    visibility: visible;
  }

  .header-nav .nav-submenu::before {
    display: none;
  }

  .header-nav .nav-submenu-item {
    min-height: 40px;
    padding: 10px 12px 10px 46px;
    font-size: 14px;
  }

  .gnb-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: block;
    background: rgba(15, 23, 42, 0.4);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s;
  }

  .gnb-backdrop.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

@media (max-width: 340px) {
  header.slim-header {
    height: 52px;
    padding: 0 10px;
  }

  .header-logo .logo-text {
    display: none;
  }

  .header-logo .logo-img {
    width: 30px;
    height: 30px;
  }

  .header-nav {
    max-height: calc(100dvh - 80px);
  }

  .mobile-menu-toggle {
    width: 38px;
    height: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .header-nav,
  .gnb-backdrop,
  .hamburger-lines span,
  .nav-submenu-toggle svg,
  .header-nav .nav-submenu {
    transition: none;
  }
}
