/* ============================================================
   v34 — 2단 사이드바 + 풀와이드 콘텐츠 + 브레드크럼
   1차 사이드바 (아이콘+라벨) → 2차 사이드 패널 (수직) → 콘텐츠 (풀와이드)
   ============================================================ */

/* ── 그리드 재정의: nav + sub-nav + topbar/main ── */
.app {
  grid-template-areas:
    "nav subnav top"
    "nav subnav main";
  grid-template-columns: var(--nav-w) var(--sub-nav-w, 0px) 1fr;
  grid-template-rows: var(--top-h) 1fr;
}
.app[data-nav="collapsed"] {
  grid-template-columns: var(--nav-w-collapsed) var(--sub-nav-w, 0px) 1fr;
}

/* ── 2차 사이드 패널 ── */
.sub-nav-panel {
  grid-area: subnav;
  display: none;
  flex-direction: column;
  background: var(--c-surface);
  border-right: 1px solid var(--c-line-soft);
  overflow-y: auto;
  overflow-x: hidden;
  height: 100dvh;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 40;
  width: 180px;
  transition: width 0.2s ease;
}
@supports (height: 100dvh) {
  .sub-nav-panel { height: 100dvh; }
}
.sub-nav-panel.show {
  display: flex;
}

.sub-nav-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-primary-strong);
  border-bottom: 1px solid var(--c-line-soft);
  flex-shrink: 0;
}
.sub-nav-header i { color: var(--c-primary); }

.sub-nav-list {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  gap: 1px;
  flex: 1;
  overflow-y: auto;
}

.sub-nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  margin: 0 6px;
  border: none;
  background: transparent;
  color: var(--c-text-soft);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  border-radius: var(--r-1);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
  position: relative;
}
.sub-nav-btn:hover {
  background: var(--c-sidebar-hover);
  color: var(--c-text);
}
.sub-nav-btn.active {
  background: var(--c-primary-soft);
  color: var(--c-primary-strong);
  font-weight: 700;
}
.sub-nav-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: var(--grad-lime);
}
.sub-nav-ico {
  width: 15px;
  height: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── 콘텐츠 영역: 풀와이드 (좌우 50px 패딩) ── */
.view-root {
  max-width: none !important;
  padding: var(--sp-4) 50px !important;
  width: 100%;
}

/* 기존 sub-nav-strip (가로 2차메뉴) 숨기기 — 수직 패널로 대체 */
.sub-nav-strip {
  display: none !important;
  max-height: 0 !important;
  opacity: 0 !important;
}

/* ── 브레드크럼 — 제거됨 ── */
.breadcrumb-bar { display: none !important; }
.bc-trail {
  display: flex;
  align-items: center;
  gap: 2px;
}
.bc-sep {
  display: inline-flex;
  align-items: center;
  color: var(--c-text-mute);
  padding: 0 2px;
}
.bc-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-soft);
  cursor: pointer;
  position: relative;
  transition: all 0.12s;
  user-select: none;
}
.bc-item:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
}
.bc-item i { flex-shrink: 0; }

/* 브레드크럼 드롭다운 */
.bc-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 180px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-2);
  box-shadow: var(--sh-3);
  z-index: 100;
  padding: 4px 0;
}
.bc-dropdown.open {
  display: block;
}
.bc-dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 14px;
  border: none;
  background: transparent;
  color: var(--c-text-soft);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.12s;
}
.bc-dd-item:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
}
.bc-dd-item.active {
  color: var(--c-primary-strong);
  font-weight: 700;
  background: var(--c-primary-soft);
}
.bc-dd-item i { flex-shrink: 0; }

/* ── 다크모드 보정 ── */
[data-theme="dark"] .sub-nav-panel {
  background: var(--c-surface);
  border-right-color: var(--c-line);
}
[data-theme="dark"] .sub-nav-header {
  border-bottom-color: var(--c-line);
}
[data-theme="dark"] .bc-dropdown {
  background: var(--c-surface);
  border-color: var(--c-line);
}

/* ── 1차 사이드바 arrow 아이콘 숨기기 (2차가 패널로 분리되었으므로) ── */
.nav-arrow { display: none !important; }

/* ── 모바일 대응 (< 900px) ── */
@media (max-width: 899px) {
  .app {
    grid-template-areas: "top" "main" !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: var(--top-h) 1fr !important;
  }

  /* 2차 패널: 모바일에서는 사이드바 드로어 안에 표시 */
  .sub-nav-panel {
    display: none !important;
  }

  .view-root {
    padding: 12px !important;
    max-width: none !important;
  }

  /* 브레드크럼: 모바일에서는 상단 왼쪽에 작게 */
  .breadcrumb-bar {
    justify-content: flex-start;
    margin-bottom: 8px;
  }
  .bc-item { font-size: 11px; padding: 3px 8px; }
}

@media (max-width: 599px) {
  .view-root {
    padding: 10px !important;
  }
  .breadcrumb-bar { margin-bottom: 6px; }
}

/* ── 태블릿 (900 ~ 1200px): 2차 패널 좀 더 좁게 ── */
@media (min-width: 900px) and (max-width: 1200px) {
  .sub-nav-panel { width: 160px; }
  .view-root {
    padding: var(--sp-4) 30px !important;
  }
}

/* ── 와이드 스크린 (1600px+): 좌우 여백 약간 더 ── */
@media (min-width: 1600px) {
  .view-root {
    padding: var(--sp-4) 60px !important;
  }
}

/* ── 모바일 사이드 드로어 내부 서브메뉴 ── */
.mobile-sub-menu {
  display: flex;
  flex-direction: column;
  padding: 2px 0 6px 18px;
  gap: 1px;
  background: var(--c-surface-2);
  border-radius: 0 0 var(--r-1) var(--r-1);
  margin: 0 8px 4px;
  animation: slideDown 0.15s ease;
}
@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 500px; }
}
.mobile-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--c-text-soft);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  border-radius: var(--r-1);
  cursor: pointer;
  transition: all 0.12s;
}
.mobile-sub-item:hover {
  background: var(--c-sidebar-hover);
  color: var(--c-text);
}
.mobile-sub-item.active {
  color: var(--c-primary-strong);
  font-weight: 700;
  background: var(--c-primary-soft);
}
