/* ─── 전역 리셋 & 변수 ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── 컬러 팔레트 (light blue/indigo SaaS) ── */
  --bg:            #F6F8FC;
  --bg-card:       #FFFFFF;
  --bg-card2:      #F7F9FD;
  --bg-hover:      #EEF4FF;

  --border:        #E4EAF4;
  --border-light:  #EDF1F9;

  --text:          #1A2332;
  --text-sub:      #4A5568;
  --text-muted:    #8FA0B8;

  /* 프라이머리 - 인디고/블루 */
  --accent:        #3B69F5;
  --accent-grad:   linear-gradient(135deg, #3B69F5 0%, #5A4CF7 100%);
  --accent-light:  #EEF3FF;
  --accent-dark:   #2A54E0;
  --accent2:       #5A4CF7;

  /* 시맨틱 컬러 */
  --green:         #16A34A;
  --green-light:   #DCFCE7;
  --green-grad:    linear-gradient(135deg, #22C55E, #16A34A);
  --red:           #E03C3C;
  --red-light:     #FEE2E2;
  --yellow:        #D97706;
  --yellow-light:  #FEF3C7;
  --cyan:          #0EA5E9;
  --purple:        #7C3AED;
  --purple-light:  #EDE9FE;

  /* 그림자 */
  --shadow-sm:     0 1px 3px rgba(30,45,90,.06), 0 1px 2px rgba(30,45,90,.04);
  --shadow:        0 3px 12px rgba(30,45,90,.08), 0 1px 4px rgba(30,45,90,.04);
  --shadow-md:     0 6px 20px rgba(30,45,90,.10), 0 2px 8px rgba(30,45,90,.06);
  --shadow-blue:   0 4px 16px rgba(59,105,245,.18);

  /* 모서리 */
  --radius:        10px;
  --radius-lg:     14px;
  --radius-xl:     18px;

  /* 폰트 */
  --font:  'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  --mono:  'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
}

/* ─── 상단 바 ──────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 58px;
  box-shadow: 0 1px 4px rgba(30,45,90,.06);
}
.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-left  { display: flex; align-items: center; gap: 10px; }

/* 로고 이미지 */
.logo-img {
  height: 36px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}
.logo-text {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.3px;
}
.logo-text strong {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-sub {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 6px;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

/* WS 상태 */
.ws-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all .3s;
  display: inline-block;
}
.ws-dot.connected {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(22,163,74,.18);
  animation: pulse-dot 2.5s infinite;
}
.ws-dot.disconnected { background: var(--red); }

@keyframes pulse-dot {
  0%,100% { box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
  50%      { box-shadow: 0 0 0 5px rgba(22,163,74,.08); }
}

.ws-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ─── 메인 레이아웃 ────────────────────────────────── */
.main-content {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 64px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ─── 카드 행 (2열) ────────────────────────────────── */
.cards-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
@media (max-width: 768px) {
  .cards-row { grid-template-columns: 1fr; }
  .main-content { padding: 16px; }
}

/* ─── 카드 공통 ────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  transition: box-shadow .2s;
}
.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
  letter-spacing: -.2px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.card-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--accent-grad);
  border-radius: 2px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title-row .card-title { margin-bottom: 0; }

/* ─── 상태 테이블 ──────────────────────────────────── */
.status-table {
  width: 100%;
  border-collapse: collapse;
}
.status-table tr {
  border-bottom: 1px solid var(--border-light);
  transition: background .1s;
}
.status-table tr:last-child { border-bottom: none; }
.status-table tr:hover { background: var(--bg-hover); border-radius: 6px; }
.status-table td {
  padding: 10px 8px;
  vertical-align: middle;
}
.stat-label {
  color: var(--text-sub);
  width: 50%;
  font-size: 13px;
}
.stat-value {
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* ─── 뱃지 ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
}
.badge-on {
  background: var(--green-light);
  color: var(--green);
}
.badge-off {
  background: #F0F4FA;
  color: var(--text-muted);
}

/* ─── 카드 버튼 영역 ───────────────────────────────── */
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

/* ─── 버튼 ─────────────────────────────────────────── */
.btn {
  cursor: pointer;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-sub);
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 600;
  transition: all .15s;
  font-family: var(--font);
  letter-spacing: .1px;
  box-shadow: var(--shadow-sm);
}
.btn:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.btn:active {
  transform: scale(.98);
  box-shadow: var(--shadow-sm);
}
.btn.btn-sm { padding: 5px 14px; font-size: 12px; }

.btn.btn-primary {
  background: var(--accent-grad);
  border-color: transparent;
  color: #FFFFFF;
  box-shadow: var(--shadow-blue);
}
.btn.btn-primary:hover {
  background: linear-gradient(135deg, #2A54E0 0%, #4A3CE0 100%);
  border-color: transparent;
  color: #FFFFFF;
  box-shadow: 0 6px 18px rgba(59,105,245,.28);
  transform: translateY(-1px);
}
.btn.btn-danger {
  border-color: #F5C6C6;
  color: var(--red);
  background: #FFFFFF;
}
.btn.btn-danger:hover {
  background: var(--red-light);
  border-color: var(--red);
  box-shadow: 0 2px 8px rgba(224,60,60,.15);
}

/* ─── 세션 목록 ────────────────────────────────────── */
.empty-msg {
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 4px;
  text-align: center;
}

.session-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  transition: all .15s;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.session-item::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent-grad);
  border-radius: 0 2px 2px 0;
}
.session-item:last-child { margin-bottom: 0; }
.session-item:hover {
  border-color: #C0D0F8;
  background: var(--accent-light);
  box-shadow: var(--shadow);
  transform: translateX(2px);
}

.session-icon { font-size: 20px; line-height: 1; }
.session-info { display: flex; flex-direction: column; gap: 3px; }
.session-caller { font-weight: 700; font-size: 14px; color: var(--text); }
.session-meta   { font-size: 11px; color: var(--text-muted); }
.session-duration {
  font-size: 13px;
  font-weight: 700;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: var(--mono);
  white-space: nowrap;
}

/* ─── 로그 패널 ────────────────────────────────────── */
.log-card { flex-shrink: 0; }

.log-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}
.toggle-label input { accent-color: var(--accent); cursor: pointer; }

/* 로그 뷰어 — 다크 유지 (가독성) */
.log-viewer {
  background: #0F172A;
  border: 1px solid #1C2C4A;
  border-radius: var(--radius);
  padding: 14px 16px;
  height: 280px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
  box-shadow: inset 0 2px 8px rgba(0,0,0,.25);
}

.log-line { display: block; }
.log-line.INFO  { color: #9EADC8; }
.log-line.WARN  { color: #FCD34D; }
.log-line.ERROR { color: #FB7185; }
.log-line.DEBUG { color: #475569; }

/* ─── 대화창 패널 ──────────────────────────────────── */
.chat-card { margin-bottom: 0; }

.chat-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* 대화창 그리드 */
.chat-windows {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
  margin-top: 14px;
}

/* 개별 대화창 */
.chat-window {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: all .25s;
  animation: slide-in .25s ease;
}
@keyframes slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-window:hover {
  border-color: #C0D0F8;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.chat-window.ending {
  opacity: .6;
  border-color: var(--border-light);
  box-shadow: var(--shadow-sm);
}

/* 대화창 헤더 */
.chat-win-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: linear-gradient(90deg, #F0F5FF 0%, #F7F9FD 100%);
  border-bottom: 1px solid var(--border);
}
.chat-win-icon { font-size: 18px; flex-shrink: 0; }
.chat-win-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.chat-win-caller {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.chat-win-id {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-win-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.chat-win-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--green-light);
  color: var(--green);
  white-space: nowrap;
}
.chat-win-badge-ended {
  background: #F0F4FA;
  color: var(--text-muted);
}
.chat-win-countdown {
  font-size: 10px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-weight: 600;
  white-space: nowrap;
}
.chat-win-countdown.urgent {
  color: var(--yellow);
  animation: blink .6s infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: .35; }
}

/* 메시지 스크롤 영역 */
.chat-messages {
  flex: 1;
  padding: 14px 16px;
  overflow-y: auto;
  min-height: 180px;
  max-height: 300px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #F9FAFB;
}

/* 말풍선 공통 */
.chat-bubble {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  animation: bubble-in .18s ease;
}
@keyframes bubble-in {
  from { opacity: 0; transform: scale(.96) translateY(4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.chat-bubble-text {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}
.chat-bubble-time {
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 5px;
  font-weight: 500;
}

/* 사용자 — 오른쪽 (인디고/블루 그라데이션) */
.chat-bubble-user {
  align-self: flex-end;
  align-items: flex-end;
}
.chat-bubble-user .chat-bubble-text {
  background: var(--accent-grad);
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 10px rgba(59,105,245,.22);
}

/* AI — 왼쪽 (흰색 카드 스타일) */
.chat-bubble-ai {
  align-self: flex-start;
  align-items: flex-start;
}
.chat-bubble-ai .chat-bubble-text {
  background: #FFFFFF;
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.chat-bubble-ai .chat-bubble-text::before {
  content: '🤖 ';
  font-size: 11px;
}

/* ─── 스크롤바 ──────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #C8D5E8;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: #A0B4CC; }
