/* chat 캐스케이드 4/6 — 사이드바 룸 리스트·룸 컨텍스트 메뉴·받은 초대 패널·레거시 세션 섹션.
   chat-voice-report.css 바로 다음에 로드된다. 로드 순서가 곧 캐스케이드다. */

/* ===== Sidebar Room List (T1 substrate — CAP04) ===== */
.room-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* 사이드바(.sidebar-sessions flex column)의 남은 세로 공간을 모두 채우고 내부 스크롤 —
     이전 max-height:160px 캡은 목록이 짧아 좌측이 비어 보이던 원인 */
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  margin-bottom: 8px;
}

.room-row {
  width: 100%;
}

/* ===== Room Context Menu (우클릭/모바일 long-press — 이름 변경/멤버 초대/나가기) ===== */
.room-context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 140px;
  padding: 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
}

.room-context-menu-item {
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}

.room-context-menu-item:hover {
  background: var(--bg-hover);
}

.room-context-menu-item-danger {
  color: var(--accent-pink);
}

.room-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-family);
  transition: all 150ms ease;
}

.room-item:hover {
  background: var(--bg-hover);
}

.room-type-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-radius: var(--radius-full);
  padding: 1px 6px;
}

.room-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== 받은 초대 패널 (Phase 4) ===== */
.invitation-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.invitation-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
}

.invitation-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.invitation-inviter {
  font-size: 11px;
  color: var(--text-muted);
}

.invitation-accept-btn,
.invitation-decline-btn {
  padding: 3px 8px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: 11px;
  cursor: pointer;
}

.invitation-accept-btn {
  background: var(--accent);
  color: var(--neutral-white);
}

.invitation-decline-btn {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

/* 룸 미소속 레거시 세션 — 접힌 보조 섹션(D07) */
.legacy-sessions {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.legacy-sessions[open] {
  flex: 1;
  min-height: 0;
}

.legacy-sessions .session-list {
  min-height: 0;
}

.legacy-sessions-summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 8px 8px;
  list-style: none;
}

.legacy-sessions-summary::before {
  content: "▶ ";
  font-size: 0.8em;
}

.legacy-sessions[open] .legacy-sessions-summary::before {
  content: "▼ ";
}

/* ===== Room file drawer (BigtionAX file substrate T1) ===== */
.view-chat {
  position: relative;
  /* 서랍 폭의 단일 소스. room-file-drawer.ts가 저장된 값으로 인라인 덮어쓴다. */
  --room-file-drawer-width: 360px;
}

.room-file-drawer-toggle {
  flex-shrink: 0;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.room-file-drawer-toggle:hover,
.room-file-drawer-toggle[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.room-file-drawer {
  position: absolute;
  z-index: 40;
  top: 49px;
  right: 0;
  bottom: 0;
  width: min(var(--room-file-drawer-width), 100%);
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--surface-panel);
  box-shadow: var(--shadow-md);
}

/* 서랍 안이 아니라 형제로 둔다 — 서랍은 overflow-y: auto 스크롤 컨테이너라 그 안의
   absolute 자식은 목록과 함께 스크롤되어 경계에서 떨어져 나간다. */
.room-file-drawer-resizer {
  position: absolute;
  z-index: 41;
  top: 49px;
  right: min(var(--room-file-drawer-width), 100%);
  bottom: 0;
  width: 15px;
  margin-right: -7px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}

/* 강조 경계선 — 평상시엔 서랍 자신의 border-left가 선 역할을 하므로 투명이고,
   잡을 수 있다는 신호가 필요한 순간(hover/포커스/드래그)에만 나타난다. */
.room-file-drawer-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  margin-left: -1px;
  background: transparent;
  transition: background 120ms;
}

/* 그립 — 항상 보인다. 투명한 히트 영역만 두면 손잡이의 존재 자체를 알 수 없어
   조절 기능이 없는 것과 같아진다. */
.room-file-drawer-resizer::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 46px;
  margin: -23px 0 0 -3px;
  border-radius: var(--radius-full);
  background: var(--text-muted);
  transition: background 120ms;
}

.room-file-drawer-resizer:hover::before,
.room-file-drawer-resizer:focus-visible::before,
.room-file-drawer-resizer[data-dragging="true"]::before {
  background: var(--accent);
}

.room-file-drawer-resizer:hover::after,
.room-file-drawer-resizer:focus-visible::after,
.room-file-drawer-resizer[data-dragging="true"]::after {
  background: var(--accent);
}

.room-file-drawer-header {
  position: sticky;
  z-index: 1;
  top: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-panel);
}

.room-file-drawer-header h2 {
  margin: 0;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 700;
}

.room-file-drawer-status {
  min-height: 16px;
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 11px;
}

.room-file-drawer-status[data-kind="success"] { color: var(--status-success); }
.room-file-drawer-status[data-kind="error"] { color: var(--status-error); }

.room-file-drawer-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-primary);
  color: var(--text-secondary);
  font: inherit;
  font-size: 18px;
  cursor: pointer;
}

/* 암시적 auto 트랙은 가장 긴 파일명의 max-content로 부풀어 서랍 폭을 넘긴다 —
   .room-file-name이 nowrap이라 min-content == max-content이기 때문이다. 서랍은
   overflow-y: auto라 overflow-x가 auto로 계산되므로 그 초과분이 그대로 가로 스크롤이
   된다. 목록과 카드 양쪽 트랙을 minmax(0, 1fr)로 고정해 폭을 서랍에 종속시킨다. */
.room-file-drawer-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 12px;
}

.room-file-drawer-message {
  margin: 0;
  padding: 22px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.room-file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
}

.room-file-thumb {
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  cursor: pointer;
}

.room-file-thumb img {
  display: block;
  width: 100%;
  height: 116px;
  object-fit: cover;
}

.room-file-thumb:hover { border-color: var(--accent); }

.room-file-item-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.room-file-name {
  flex: 1;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.4;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.room-file-name:hover:not(:disabled) { color: var(--accent); }
.room-file-name:disabled { color: var(--text-muted); cursor: not-allowed; }

.room-file-state {
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
}

.room-file-state--available,
.room-file-state--archived {
  background: var(--status-success-soft);
  color: var(--status-success);
}

.room-file-state--review_pending,
.room-file-state--archiving {
  background: var(--status-warning-soft);
  color: var(--status-warning);
}

/* 공유 링크가 살아 있다는 사실은 지금까지 철회/재발급 버튼의 존재로만 유추할 수 있었다 —
   shareState === "active"를 배지 옆에 명시적으로 드러낸다. */
.room-file-share-chip {
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background: var(--accent-light);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
}

.room-file-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
}

.room-file-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.room-file-action {
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--neutral-white);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.room-file-action--quiet {
  border-color: var(--border);
  background: var(--bg-primary);
  color: var(--text-secondary);
}

.room-file-action:disabled {
  border-color: var(--border);
  background: var(--bg-tertiary);
  color: var(--text-muted);
  cursor: not-allowed;
}

@media (max-width: 767px) {
  .room-file-drawer {
    position: fixed;
    top: 48px;
    width: 100%;
  }

  /* 모바일에서 서랍은 전폭 고정이라 조절할 폭 자체가 없다. */
  .room-file-drawer-resizer {
    display: none;
  }
}
