/* layout.css — 앱 셸(사이드바 / 헤더 / 본문).
 * 구 app/(app)/layout.tsx + app-shell/* 의 Tailwind 클래스 이식.
 *
 * 반응형 기준선은 구버전 Tailwind 의 md(768px) 를 그대로 쓴다.
 *   768px 이상 : 사이드바 고정 노출, 햄버거 숨김
 *   768px 미만 : 사이드바를 drawer 로, 헤더에 햄버거 노출
 */

/* ── 사이드바 ─────────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  /* 폭은 sidebar-resizer.js 가 --sidebar-w 로 조절한다(localStorage 유지). */
  width: var(--sidebar-w, 220px);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--background);
}

.sidebar-contents {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}

.brand-text {
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  padding: 1px 6px;
  border: 1.5px solid var(--foreground);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1;
  vertical-align: middle;
}

.sidebar-body {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.sidebar-label {
  padding: 8px 16px;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}
.sidebar-label-gap {
  margin-top: 8px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-left: 3px solid transparent;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  transition: background-color 0.15s, color 0.15s;
}

.sidebar-item:hover {
  background: var(--accent);
  color: var(--foreground);
}

.sidebar-item.is-active {
  border-left-color: var(--foreground);
  background: var(--accent);
  color: var(--foreground);
  font-weight: 600;
}

.sidebar-item-label {
  flex: 1;
}

.sidebar-icon-trailing {
  opacity: 0.6;
}

/* ── 사이드바 푸터(고객센터 + 관리자 자물쇠) ─────────────── */
.sidebar-footer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}

.support-info {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.support-title {
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}

.support-email {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  text-align: left;
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  transition: color 0.15s;
}
.support-email:hover {
  color: var(--foreground);
}

.support-copied {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--foreground);
}

.admin-lock-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  color: var(--muted-foreground);
  transition: background-color 0.15s, color 0.15s;
}
.admin-lock-btn:hover {
  background: var(--accent);
  color: var(--foreground);
}
.admin-lock-btn.is-admin {
  color: var(--foreground);
}

/* 관리자 팝오버 — 구 Radix Popover(side="top" align="end") 대체 */
.admin-popover {
  position: absolute;
  right: 12px;
  bottom: calc(100% + 6px);
  width: 256px;
}

/* ── 모바일 drawer ────────────────────────────────────────── */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(0 0 0 / 0.4);
}

@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .sidebar.is-open {
    transform: translateX(0);
  }
}

@media (min-width: 768px) {
  .sidebar-overlay {
    display: none !important;
  }
}

/* ── 메인 ─────────────────────────────────────────────────── */
.main-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  /* min-*: 0 이 핵심 — flex item 의 min-size 기본값이 auto 라 컨텐츠가 부모보다
     커지면 부모를 밀어 늘리고, 내부 스크롤 영역이 자기 안에서 스크롤하지 못한다.
     column flex chain 각 단계에 명시한다(구버전 layout.tsx 주석과 동일한 이유). */
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: color-mix(in oklab, var(--muted) 30%, transparent);
}

.top-bar {
  display: flex;
  height: 52px;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--background);
}

.top-bar-left {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.page-title {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
}

/* 햄버거 — 데스크탑에서는 숨긴다(사이드바가 항상 보이므로).
   `.top-bar` 를 앞에 붙여 특이도를 올린다: components.css 가 layout.css 보다
   나중에 로드돼 같은 특이도면 `.icon-btn { display: inline-flex }` 가 이긴다. */
@media (min-width: 768px) {
  .top-bar .menu-btn { display: none; }
  .top-bar { padding: 0 24px; }
}

.page-slot {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* 의견 보내기 — 사이드바 하단 (footer 위) 고정 섹션 */
.sidebar-opinion {
  padding: 6px 0;
  border-top: 1px solid var(--border);
}


/* ── 사이드바 너비 조절 핸들 (sidebar-resizer.js) ─────────────── */
.sidebar-resizer {
  flex: 0 0 5px;
  cursor: col-resize;
  background: transparent;
  position: relative;
  /* 얇은 요소라 잡기 어렵다 — 가상요소로 히트 영역만 좌우로 넓힌다. */
  touch-action: none;
}

.sidebar-resizer::before {
  content: "";
  position: absolute;
  inset: 0 -4px;
}

.sidebar-resizer::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 2px;
  width: 1px;
  background: transparent;
  transition: background 0.12s ease;
}

.sidebar-resizer:hover::after,
.sidebar-resizer:focus-visible::after,
.sidebar-resizer.is-dragging::after {
  background: var(--primary, #2563eb);
  width: 2px;
}

.sidebar-resizer:focus-visible {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: -2px;
}

/* 드래그 중 본문 텍스트 선택·커서 깜빡임 방지 */
body.is-resizing-sidebar {
  user-select: none;
  cursor: col-resize;
}

/* 모바일은 사이드바가 drawer 라 폭 조절이 의미 없다. */
@media (max-width: 767px) {
  .sidebar-resizer { display: none; }
  .sidebar { width: 256px; }
}
