/* ===== 기본 설정 ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #003087;
  --primary-dark: #002060;
  --primary-light: #0050c8;
  --pass: #22c55e;
  --pass-bg: #dcfce7;
  --pass-text: #166534;
  --progress: #f97316;
  --progress-bg: #ffedd5;
  --progress-text: #9a3412;
  --fail: #ef4444;
  --fail-bg: #fee2e2;
  --fail-text: #991b1b;
  --pending: #9ca3af;
  --pending-bg: #f3f4f6;
  --pending-text: #374151;
  --bg: #f0f2f5;
  --white: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Malgun Gothic', '맑은 고딕', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ===== 헤더 ===== */
.header {
  background: var(--primary);
  color: var(--white);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-text {
  flex:0 0 auto;
  width:150px;
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.logo-rotem {
  width:150px;
  font-size: 0px;
  font-weight: 800;
  letter-spacing: 1px;
  overflow:hidden;
}
.logo-rotem > img{
    width:150px;
}

.header-title h1 {
  font-size: 16px;
  font-weight: 700;
}

.header-title p {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-nav {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 3px;
}

.nav-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.75);
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-btn.active,
.nav-btn:hover {
  background: rgba(255,255,255,0.2);
  color: var(--white);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
  flex-shrink: 0;
  transition: background 0.3s;
}

.status-dot.online { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.status-dot.error { background: #ef4444; }

/* ===== 메인 ===== */
.main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ===== 채팅 뷰 ===== */
.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== 메시지 버블 ===== */
.message {
  display: flex;
  max-width: 85%;
}

.bot-message {
  align-self: flex-start;
  max-width: 85%;
}

.bot-message-inner {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-bubble {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  line-height: 1.7;
  font-size: 14px;
}

.bot-message .message-bubble {
  border-top-left-radius: 4px;
}

.user-message .message-bubble {
  background: var(--primary);
  color: var(--white);
  border-top-right-radius: 4px;
}

.message-bubble p {
  margin-bottom: 6px;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

/* ===== 상태 카드 ===== */
.status-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  width: 100%;
}

.status-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 14px;
}

/* 진행률 바 */
.progress-bar-wrap {
  margin-bottom: 14px;
}

.progress-bar {
  display: flex;
  height: 28px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--pending-bg);
}

.progress-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--white);
  transition: width 0.5s ease;
  min-width: 0;
}

.progress-segment.pass { background: var(--pass); }
.progress-segment.in-progress { background: var(--progress); }
.progress-segment.fail { background: var(--fail); }
.progress-segment.pending { background: var(--pending); color: #6b7280; }
.progress-segment span { white-space: nowrap; overflow: hidden; }

/* 품목 배지 */
.items-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.item-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.item-badge.pass {
  background: var(--pass-bg);
  color: var(--pass-text);
  border: 1px solid rgba(34,197,94,0.3);
}

.item-badge.in-progress {
  background: var(--progress-bg);
  color: var(--progress-text);
  border: 1px solid rgba(249,115,22,0.3);
}

.item-badge.fail {
  background: var(--fail-bg);
  color: var(--fail-text);
  border: 1px solid rgba(239,68,68,0.3);
}

.item-badge.pending {
  background: var(--pending-bg);
  color: var(--pending-text);
  border: 1px solid rgba(156,163,175,0.3);
}

.item-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.item-badge.pass .dot { background: var(--pass); }
.item-badge.in-progress .dot { background: var(--progress); }
.item-badge.fail .dot { background: var(--fail); }
.item-badge.pending .dot { background: var(--pending); }

/* ===== 통계 요약 박스 행 ===== */
.stat-summary-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  gap: 2px;
  min-width: 52px;
}

.stat-box span {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.stat-box.pass        { background: var(--pass-bg);     color: var(--pass-text); }
.stat-box.in-progress { background: var(--progress-bg); color: var(--progress-text); }
.stat-box.fail        { background: var(--fail-bg);     color: var(--fail-text); }
.stat-box.pending     { background: var(--pending-bg);  color: var(--pending-text); }
.stat-box.total       { background: #e0e7ff;            color: #3730a3; }

/* ===== 통계 테이블 ===== */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 12px;
}

.stats-table th {
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.stats-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.stats-table tr:last-child td { border-bottom: none; }
.stats-table tr:hover td { background: var(--bg); }

.stats-table .num { text-align: center; font-weight: 600; }
.pass-text { color: var(--pass-text); }
.prog-text { color: var(--progress-text); }
.fail-text { color: var(--fail-text); }

/* 최종 상태 */
.final-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.final-status .label { color: var(--text-muted); }
.final-status .value { font-weight: 600; }
.final-status .value.all-pass { color: var(--pass-text); }
.final-status .value.has-fail { color: var(--fail-text); }
.final-status .value.pending { color: var(--progress-text); }

/* ===== TTS 플레이어 ===== */
.tts-player {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 24px;
  border: 1px solid var(--border);
}

.tts-btn, .tts-vol-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: opacity 0.2s;
}

.tts-btn:hover, .tts-vol-btn:hover { opacity: 0.7; }

.tts-btn svg { width: 16px; height: 16px; fill: var(--primary); stroke: none; }
.tts-vol-btn svg { width: 16px; height: 16px; }

.tts-btn.playing svg {
  /* 일시정지 아이콘 */
}

.tts-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tts-bar {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  cursor: pointer;
}

.tts-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}

.tts-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 60px;
}

/* ===== 입력 영역 ===== */
.chat-input-area {
  padding: 12px 16px 20px;
  background: var(--bg);
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: center;
  background: var(--white);
  border-radius: 28px;
  padding: 6px 6px 6px 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  gap: 8px;
  transition: border-color 0.2s;
}

.input-wrapper:focus-within {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(0,80,200,0.1), var(--shadow-lg);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 14px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
}

.chat-input::placeholder { color: var(--text-muted); }

.mic-btn, .send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.mic-btn {
  background: var(--bg);
  color: var(--text-muted);
}

.mic-btn:hover { background: var(--border); color: var(--text); }

.mic-btn.listening {
  background: #fee2e2;
  color: var(--fail);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

.mic-btn svg, .send-btn svg { width: 16px; height: 16px; }

.send-btn {
  background: var(--primary);
  color: var(--white);
}

.send-btn:hover { background: var(--primary-dark); }
.send-btn:active { transform: scale(0.95); }

/* ===== 로딩 타이핑 표시 ===== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background: var(--white);
  border-radius: var(--radius);
  border-top-left-radius: 4px;
  width: fit-content;
  box-shadow: var(--shadow);
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary-light);
  animation: typing 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ===== 대시보드 뷰 ===== */
.dashboard-view {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.dashboard-header {
  margin-bottom: 24px;
}

.dashboard-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

.dashboard-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.empty-dashboard {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  gap: 16px;
}

.empty-dashboard svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

.empty-dashboard p {
  font-size: 14px;
  line-height: 1.6;
}

.dashboard-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.dashboard-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.dashboard-card-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ===== 로딩 오버레이 ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 48, 135, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-overlay p {
  font-size: 14px;
  color: var(--primary);
  font-weight: 500;
}

/* ===== 반응형 ===== */
@media (max-width: 640px) {
  .header { padding: 0 16px; }
  .header-title p { display: none; }
  .chat-messages { padding: 16px 12px; }
  .message { max-width: 95%; }
  .status-card { max-width: 100%; }
  .dashboard-view { padding: 16px; }
  .dashboard-cards { grid-template-columns: 1fr; }
  .logo-text,
  .logo-rotem {
    width:36px;
    overflow:hidden;
  }
  transition:all 0.5s;
}
