/* 이 파일은 로그인과 채팅 화면의 레이아웃을 담당한다. CSP를 위해 인라인 스타일은 쓰지 않는다.
   외형 기준: 카카오톡처럼 "방 목록 / 대화"가 나뉘고 내 말풍선과 남의 말풍선이 구분되면 충분하다.
   과하게 꾸미지 않는다. 외부 폰트나 이미지를 불러오지 않는다(CSP·오프라인 안전). */
* { box-sizing: border-box; }

:root {
  --bg: #b2c7d9;          /* 카카오톡 대화 배경 느낌의 차분한 청회색 */
  --side: #ffffff;
  --line: #e3e6ea;
  --text: #1c1e21;
  --muted: #6b7280;
  --mine: #fee500;        /* 내 말풍선 */
  --other: #ffffff;       /* 남의 말풍선 */
  --accent: #3b5bdb;
}

html, body { height: 100%; margin: 0; }
body {
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }

/* ---- 로그인 화면 ----
   클래스 이름은 login.html 이 쓰는 auth-page / auth-shell / auth-panel / form-stack 을 따른다.
   (여기를 login-* 로 바꾸면 로그인 화면 스타일이 통째로 사라진다.) */
.auth-page { min-height: 100%; background: var(--bg); margin: 0; }
.auth-shell {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 16px;
}
.auth-panel {
  background: #fff; padding: 28px; border-radius: 12px;
  width: 100%; max-width: 380px; box-shadow: 0 6px 24px rgba(0,0,0,.12);
}
.auth-panel h1 { margin: 0 0 18px; font-size: 20px; }
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-stack label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form-stack input {
  width: 100%; padding: 11px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 15px; color: var(--text);
}
.form-stack button {
  width: 100%; padding: 12px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 15px; cursor: pointer;
}
#message { color: #b91c1c; font-size: 13px; min-height: 18px; }
#enrollBox img { display: block; margin: 10px auto; max-width: 100%; }
#secretText { display: block; word-break: break-all; font-family: monospace; font-size: 12px; }

/* ---- 앱 전체 레이아웃 ---- */
.app-page { display: flex; height: 100%; background: var(--bg); }

.sidebar {
  width: 300px; flex: 0 0 300px; background: var(--side);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0;
}
.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px; border-bottom: 1px solid var(--line);
}
.me { font-weight: 700; font-size: 15px; }
.sidebar-actions { display: flex; align-items: center; gap: 6px; }
.icon-button { width: 34px; height: 34px; padding: 0; font-size: 16px; line-height: 1; }

.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; padding: 11px 0; border: 0; background: none; cursor: pointer;
  font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent;
}
.tab.active { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }

.pane { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.list { overflow-y: auto; flex: 1; padding: 6px; }

.row-form { display: flex; gap: 6px; padding: 10px; border-bottom: 1px solid var(--line); }
.row-form input { flex: 1; min-width: 0; padding: 9px; border: 1px solid var(--line); border-radius: 8px; }
.row-form select, .chat-head select {
  min-width: 88px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text);
}
.row-form button, .wide, .small {
  border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer;
}
.row-form button { padding: 9px 12px; }
.wide { margin: 10px; padding: 11px; }
.small { padding: 7px 12px; font-size: 13px; flex: 0 0 auto; }
.admin-role-panel { border-top: 1px solid var(--line); }
.admin-role-list { max-height: 240px; flex: 0 0 auto; }
.admin-role-item { cursor: default; }
.admin-role-toggle {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  font-size: 12px; color: var(--muted);
}
.admin-role-toggle input { width: 16px; height: 16px; }
.ghost {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 7px 11px; cursor: pointer; font-size: 13px;
}
.ghost:disabled { opacity: .45; cursor: default; }

/* 목록 항목 (방·사원 공용) */
.item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px; border: 0; background: none; border-radius: 10px;
  text-align: left; cursor: pointer; font: inherit; color: inherit;
}
.item:hover { background: #f5f6f8; }
.item.active { background: #eef1fb; }
.item-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.item-title { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.item-sub, .item-note {
  color: var(--muted); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item-note { color: #b45309; }   /* "아직 응답하지 않음" 안내는 눈에 띄게 */

.avatar {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 12px;
  background: #dfe3e8; display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.avatar.agent { background: #e7edff; }   /* AI 사원은 색을 달리해 한눈에 구분 */
.room-avatar { background: #d9e7dd; font-weight: 700; font-size: 16px; }

.badge { font-size: 11px; padding: 1px 6px; border-radius: 999px; font-weight: 600; }
.badge.wait { background: #fef3c7; color: #92400e; }
.badge.me-badge { background: #e5e7eb; color: #374151; }
.badge.active { background: #dcfce7; color: #166534; }
.badge.inactive { background: #fee2e2; color: #991b1b; }

.group { margin: 12px 8px 4px; font-size: 12px; color: var(--muted); }
.hint { margin: 6px 10px; font-size: 12px; color: var(--muted); }
.member-group {
  margin: 18px 8px 8px; padding: 9px 10px 7px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 800; color: #111827; background: #f9fafb;
}
.member-group.agent { background: #eef4ff; border-color: #c7d2fe; }
.member-group-note {
  margin: 0 8px 8px; padding: 8px 10px;
  border-left: 3px solid #f59e0b; background: #fffbeb; color: #7c2d12;
}

/* ---- 대화 영역 ---- */
.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: #fff; border-bottom: 1px solid var(--line);
}
.chat-title { flex: 1; min-width: 0; }
.chat-head h1 { margin: 0; font-size: 16px; }
.sub {
  display: block; color: var(--muted); font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }

.msg { display: flex; gap: 8px; align-items: flex-start; max-width: 78%; }
.msg.mine { align-self: flex-end; }
.msg-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.msg-name { font-size: 12px; color: #374151; }
.msg-line { display: flex; align-items: flex-end; gap: 5px; }

.bubble {
  background: var(--other); padding: 8px 11px; border-radius: 14px;
  white-space: pre-wrap; word-break: break-word; line-height: 1.45;
  box-shadow: 0 1px 1px rgba(0,0,0,.06);
}
.msg.mine .bubble { background: var(--mine); }
.msg-time { font-size: 11px; color: #4b5563; flex: 0 0 auto; }

.message-form { display: flex; gap: 8px; padding: 10px; background: #fff; border-top: 1px solid var(--line); }
.message-form textarea {
  flex: 1; resize: none; padding: 10px; border: 1px solid var(--line);
  border-radius: 10px; font: inherit; max-height: 120px;
}
.message-form button { border: 0; border-radius: 10px; background: var(--accent); color: #fff; padding: 0 18px; cursor: pointer; }

/* ---- 모달 ---- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10;
}
.modal-box {
  background: #fff; border-radius: 12px; padding: 20px;
  width: 100%; max-width: 420px; max-height: 85vh; overflow-y: auto;
}
.modal-box h2 { margin: 0 0 8px; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.settings-tabs { margin: 4px 0 10px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.settings-section { border-top: 1px solid var(--line); padding-top: 6px; }
.settings-section:first-of-type { border-top: 0; padding-top: 0; }
.item-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.fold-toggle {
  width: 100%; margin-top: 8px; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #f9fafb; color: var(--text); text-align: left; cursor: pointer;
}
.fold-toggle[aria-expanded="true"] { background: #eef1fb; border-color: #c7d2fe; }
.fold-toggle.member-group {
  width: calc(100% - 16px); box-sizing: border-box;
  margin: 18px 8px 8px; border-radius: 0;
  font-size: 14px; font-weight: 800;
}
.fold-toggle.member-group.agent { background: #eef4ff; border-color: #c7d2fe; }
.fold-toggle.member-group.room-category { background: #f8fafc; }
.fold-toggle.member-group.room-category.uncategorized { background: #f3f4f6; }
.fold-toggle.member-group[aria-expanded="true"] { background: #f9fafb; border-color: var(--line); }
.fold-toggle.member-group.agent[aria-expanded="true"] { background: #eef4ff; border-color: #c7d2fe; }
.fold-toggle.member-group.room-category[aria-expanded="true"] { background: #f8fafc; }
.fold-toggle.member-group.room-category.uncategorized[aria-expanded="true"] { background: #f3f4f6; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.stack input { padding: 9px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; color: var(--text); }
.stack button { padding: 11px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; cursor: pointer; }
/* 모달 안내문은 .notice 로 따로 둔다.
   처음엔 이것도 .msg 로 썼는데, 대화 말풍선의 .msg 와 이름이 겹쳐
   안내문이 말풍선 레이아웃(flex·max-width)을 물려받아 깨졌다. */
.notice { color: #b91c1c; font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.temp-pw { margin-top: 12px; padding: 10px; background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; font-size: 13px; }
.temp-pw code { display: block; margin-top: 6px; font-size: 15px; word-break: break-all; font-weight: 700; }

/* ---- 모바일 ---- */
.only-mobile { display: none; }
@media (max-width: 720px) {
  /* 좁은 화면에서는 목록과 대화를 한 번에 하나만 보여 준다(카카오톡과 같은 방식). */
  .sidebar { width: 100%; flex: 1 1 auto; border-right: 0; }
  .chat { display: none; }
  body.chat-open .sidebar { display: none; }
  body.chat-open .chat { display: flex; }
  .only-mobile { display: inline-block; }
}
