/* ============================================
   HCT GPT — Complete Stylesheet
   ============================================ */

:root {
  --navy: #032C87;
  --navy-dark: #021F63;
  --navy-light: #0A3DA8;
  --teal: #1D9E75;
  --teal-light: #47D7AC;
  --teal-pale: #e1f5ee;
  --teal-faint: #f0faf6;
  --sky: #1D6FA8;
  --text: #0F1E2D;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  --border: #E2E8F0;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --surface-3: #F1F5F9;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 60px rgba(3,44,135,0.12), 0 8px 24px rgba(3,44,135,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --font: 'Poppins', sans-serif;
  --sidebar-w: 260px;
  --topbar-h: 58px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  height: 100%;
  overflow: hidden;
}

button { cursor: pointer; font-family: var(--font); border: none; outline: none; }
input, textarea { font-family: var(--font); outline: none; border: none; }

/* ============================================
   SCREENS
   ============================================ */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.screen.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
}

/* ============================================
   SCREEN 1 — LOGIN (light theme)
   ============================================ */
#screen-login {
  align-items: center;
  justify-content: center;
  background: #f0f4f8;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.bg-grid {
  position: absolute;
  inset: 0;
}

.bg-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
}
.blob-1 { width: 500px; height: 500px; background: radial-gradient(circle, #b8cef8 0%, transparent 70%); top: -200px; right: -100px; animation: blobFloat 8s ease-in-out infinite; }
.blob-2 { width: 400px; height: 400px; background: radial-gradient(circle, #a7ecd6 0%, transparent 70%); bottom: -150px; left: -100px; animation: blobFloat 10s ease-in-out infinite reverse; }
.blob-3 { width: 300px; height: 300px; background: radial-gradient(circle, #bdd9f5 0%, transparent 70%); top: 50%; left: 50%; transform: translate(-50%, -50%); animation: blobFloat 6s ease-in-out infinite 2s; }

@keyframes blobFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

.glass-card {
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: var(--radius-xl);
  box-shadow: 0 8px 40px rgba(3,44,135,0.10), 0 2px 8px rgba(3,44,135,0.06);
}

.login-card {
  position: relative;
  z-index: 10;
  width: 400px;
  padding: 44px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: cardUp 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cardUp {
  from { opacity: 0; transform: translateY(40px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 4px;
}

.logo-mark {
  width: 44px;
  height: 44px;
  background: white;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  box-shadow: var(--shadow-sm);
}

.hct-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.logo-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

.logo-gpt-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.05em;
}

.login-tagline {
  display: flex;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 4px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  width: 16px;
  height: 16px;
  color: var(--text-light);
  flex-shrink: 0;
}

.field {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px 12px 42px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  transition: var(--transition);
}
.field::placeholder { color: var(--text-light); }
.field:focus {
  background: white;
  border-color: var(--teal-light);
  box-shadow: 0 0 0 3px rgba(71,215,172,0.15);
}

.eye-btn {
  position: absolute;
  right: 12px;
  background: none;
  padding: 4px;
  color: var(--text-light);
  transition: var(--transition);
}
.eye-btn:hover { color: var(--text-muted); }
.eye-btn svg { width: 16px; height: 16px; }

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-light) 100%);
  color: white;
  border-radius: var(--radius-sm);
  padding: 13px 24px;
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition);
  box-shadow: 0 4px 20px rgba(29,158,117,0.35);
  letter-spacing: 0.01em;
}
.btn-primary svg { width: 16px; height: 16px; transition: transform 0.25s; }
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(29,158,117,0.45);
}
.btn-primary:hover svg { transform: translateX(3px); }
.btn-primary:active { transform: translateY(0); }

.login-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ============================================
   TOPBAR (shared)
   ============================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
  position: relative;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.hamburger-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: var(--transition);
}
.hamburger-btn:hover { background: var(--surface-3); }
.hamburger-btn span {
  width: 16px;
  height: 1.5px;
  background: var(--text-muted);
  border-radius: 1px;
  display: block;
  transition: var(--transition);
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-logo-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.topbar-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

.topbar-gpt {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.05em;
}

.dept-chip {
  background: var(--teal-pale);
  color: var(--teal);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}
.btn-ghost:hover { background: var(--surface-3); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-exit {
  background: var(--navy);
  color: white;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}
.btn-exit:hover { background: var(--navy-dark); }

/* ============================================
   SCREEN 2 — DEPARTMENT SELECTION
   ============================================ */
#screen-dept {
  background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
  flex-direction: column;
}

.dept-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.dept-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  width: 460px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: var(--shadow-lg);
  animation: cardUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.dept-header {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dept-icon-wrap {
  width: 48px;
  height: 48px;
  background: var(--navy);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.dept-icon-wrap svg {
  width: 22px;
  height: 22px;
  color: white;
}

.dept-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.dept-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.dept-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dept-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
  text-align: center;
}
.dept-btn:hover {
  border-color: var(--teal-light);
  background: var(--teal-faint);
  color: var(--teal);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(29,158,117,0.12);
}
.dept-btn.active {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-light) 100%);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 20px rgba(29,158,117,0.3);
  transform: translateY(-2px);
}
.dept-btn.full { grid-column: 1 / -1; flex-direction: row; justify-content: center; }

.dept-btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.7;
}
.dept-btn-icon svg { width: 20px; height: 20px; }
.dept-btn.active .dept-btn-icon { opacity: 1; }
.dept-btn.full .dept-btn-icon { margin-right: 4px; }

/* ============================================
   SCREEN 3/4/5/6 — CHAT INTERFACE
   ============================================ */
#screen-chat {
  flex-direction: column;
  background: var(--surface-2);
}

/* SIDEBAR */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.sidebar-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 300;
  display: flex;
  flex-direction: column;
  padding: 0;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 24px rgba(0,0,0,0.08);
}
.sidebar.open { transform: translateX(0); }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}
.sidebar-close {
  background: none;
  color: var(--text-light);
  padding: 4px;
  transition: var(--transition);
}
.sidebar-close:hover { color: var(--text-muted); }
.sidebar-close svg { width: 16px; height: 16px; }

.new-chat-btn {
  margin: 14px 14px 8px;
  background: var(--navy);
  color: white;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}
.new-chat-btn svg { width: 16px; height: 16px; }
.new-chat-btn:hover { background: var(--navy-light); }

.sidebar-section-label {
  padding: 12px 18px 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-history { flex: 1; overflow-y: auto; padding: 4px 8px; }

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.history-item:hover { background: var(--surface-3); }

.history-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal-light);
  flex-shrink: 0;
}

.history-item span {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-dept-badge {
  width: 32px;
  height: 32px;
  background: var(--navy);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.sidebar-dept-name {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* CHAT LAYOUT */
.chat-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.chat-and-avatar {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* MESSAGES */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 0;
  scroll-behavior: smooth;
}
.messages-area::-webkit-scrollbar { width: 4px; }
.messages-area::-webkit-scrollbar-track { background: transparent; }
.messages-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* EMPTY STATE */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  animation: fadeIn 0.5s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty-orb {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
}

.orb-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid;
  animation: orbPulse 3s ease-in-out infinite;
}
.ring-1 { width: 100%; height: 100%; border-color: rgba(29,158,117,0.2); animation-delay: 0s; }
.ring-2 { width: 75%; height: 75%; border-color: rgba(29,158,117,0.3); animation-delay: 0.3s; }
.ring-3 { width: 52%; height: 52%; border-color: rgba(29,158,117,0.5); animation-delay: 0.6s; }

@keyframes orbPulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.06); opacity: 1; }
}

.orb-core {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-light) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(29,158,117,0.4);
}
.orb-core svg { width: 18px; height: 18px; color: white; }

.empty-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.empty-sub {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  max-width: 320px;
  margin-bottom: 24px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.chip {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  transition: var(--transition);
}
.chip:hover {
  border-color: var(--teal-light);
  background: var(--teal-faint);
  color: var(--teal);
}

/* MESSAGE BUBBLES */
#messagesList {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.message-row {
  display: flex;
  margin-bottom: 16px;
  animation: msgIn 0.3s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.message-row.user { justify-content: flex-end; }
.message-row.bot { justify-content: flex-start; }

.bubble {
  max-width: 72%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
  position: relative;
}

.bubble.user {
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-light) 100%);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(29,158,117,0.25);
}

.bubble.bot {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
  padding-left: 30px;
  padding-right: 30px;
}

/* SOURCE CITATION */
.source-block {
  margin: -8px 0 12px;
  padding: 0 4px 0 0;
  animation: msgIn 0.3s ease 0.1s both;
}

.source-box {
  background: var(--surface-2);
  border-left: 3px solid var(--teal-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.9;
  display: inline-block;
  max-width: 500px;
}

.source-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.source-toggle-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  transition: var(--transition);
}

.source-toggle-btn.hide {
  background: var(--teal-light);
  color: white;
}
.source-toggle-btn.hide:hover { background: var(--teal); }

.source-toggle-btn.show {
  background: var(--navy);
  color: white;
}
.source-toggle-btn.show:hover { background: var(--navy-dark); }

.feedback-btn {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.feedback-btn svg { width: 13px; height: 13px; }
.feedback-btn:hover { background: var(--surface-3); border-color: var(--text-light); }
.feedback-btn.active-up { background: var(--teal-pale); border-color: var(--teal); }
.feedback-btn.active-down { background: #fee2e2; border-color: #f87171; }

/* TYPING INDICATOR */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px 4px;
  transition: var(--transition);
}
.typing-indicator.hidden { opacity: 0; height: 0; padding: 0 20px; overflow: hidden; }

.typing-avatar {
  width: 30px;
  height: 30px;
  background: white;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  flex-shrink: 0;
}
.typing-avatar img { width: 100%; height: 100%; object-fit: contain; }

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 14px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-light);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* INPUT BAR */
.input-bar {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--surface);
  flex-shrink: 0;
}

.input-wrap-bar {
  flex: 1;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 2px 6px;
  transition: var(--transition);
}
.input-wrap-bar:focus-within {
  border-color: var(--teal-light);
  background: white;
  box-shadow: 0 0 0 3px rgba(71,215,172,0.12);
}

.chat-input {
  width: 100%;
  background: transparent;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text);
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  display: block;
}
/* ── Auto-direction for chat input ── */
.chat-input[dir="rtl"] {
  direction: rtl;
  text-align: right;
}
.chat-input::placeholder { color: var(--text-light); }

.input-action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}
.input-action-btn svg { width: 17px; height: 17px; }

.mic-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}
.mic-btn:hover { background: var(--surface-3); }
.mic-btn.active {
  background: #fee2e2;
  border-color: #f87171;
  color: #ef4444;
  animation: micPulse 1.5s ease-in-out infinite;
}
@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
  50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}

.send-btn {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: white;
  box-shadow: 0 2px 10px rgba(3,44,135,0.25);
}
.send-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 16px rgba(3,44,135,0.35);
}
.send-btn:active { transform: scale(0.96); }

.avatar-toggle-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
}
.avatar-toggle-btn:hover { background: var(--surface-3); }
.avatar-toggle-btn.active {
  background: var(--teal-pale);
  border-color: var(--teal-light);
  color: var(--teal);
}

/* ============================================
   AVATAR PANEL
   ============================================ */
.avatar-panel {
  width: 0;
  overflow: hidden;
  border-left: 0 solid var(--border);
  background: var(--surface-2);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), border-width 0.4s;
  flex-shrink: 0;
}
.avatar-panel.open {
  width: 200px;
  border-left-width: 1px;
}

.avatar-panel-inner {
  width: 200px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px;
  gap: 14px;
}

.avatar-figure-wrap {
  position: relative;
  width: 140px;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.avatar-bg-glow {
  position: absolute;
  bottom: 0;
  width: 100px;
  height: 60px;
  background: radial-gradient(ellipse, rgba(29,158,117,0.2) 0%, transparent 70%);
  border-radius: 50%;
}

.avatar-figure {
  position: relative;
  z-index: 1;
  width: 110px;
}

.avatar-svg {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 8px 24px rgba(3,44,135,0.15));
  animation: avatarIdle 4s ease-in-out infinite;
}

@keyframes avatarIdle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.avatar-panel.speaking .avatar-svg {
  animation: avatarTalk 0.3s ease-in-out infinite alternate;
}
@keyframes avatarTalk {
  from { transform: translateY(0) rotate(-0.5deg); }
  to { transform: translateY(-2px) rotate(0.5deg); }
}

.avatar-status {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.status-dot.idle { background: var(--text-light); }
.status-dot.listening { background: #3b82f6; animation: statusPulse 1s ease-in-out infinite; }
.status-dot.speaking { background: var(--teal); animation: statusPulse 0.6s ease-in-out infinite; }

@keyframes statusPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.audio-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 24px;
  opacity: 0;
  transition: opacity 0.3s;
}
.audio-bars.active { opacity: 1; }

.audio-bar {
  width: 4px;
  border-radius: 2px;
  background: var(--teal);
  animation: barWave 0.8s ease-in-out infinite alternate;
  animation-delay: var(--delay);
  min-height: 4px;
}
@keyframes barWave {
  from { height: 4px; }
  to { height: 20px; }
}

.avatar-controls {
  display: flex;
  gap: 6px;
  width: 100%;
}

.btn-stop {
  flex: 1;
  background: var(--navy);
  color: white;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  transition: var(--transition);
}
.btn-stop:hover { background: var(--navy-dark); }

/* ============================================
   UTILITIES
   ============================================ */
.hidden { display: none !important; }

/* Scrollbar for chat */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

/* Responsive */
@media (max-width: 600px) {
  .login-card { width: 90%; padding: 36px 28px; }
  .dept-card { width: 95%; padding: 32px 24px; }
  .bubble { max-width: 88%; }
  .avatar-panel.open { width: 160px; }
  .avatar-panel-inner { width: 160px; padding: 14px 12px; }
}
/******************* new styles************************* */
/* ── Source block wrapper ── */
.sources-block {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
}

/* ── Toggle button ── */
.source-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  margin-bottom: 6px;
}

/* ── Detail panel ── */
.source-detail {
  display: flex;
  flex-direction: column;   /* FIX 2: stacked, not side-by-side grid */
  gap: 10px;
  margin-top: 4px;
  animation: fadeIn 0.15s ease;
}
.source-detail.hidden { display: none; }

/* ── Individual source card ── */
.source-card {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  border-left: 3px solid #2bb591;   /* teal accent */
  box-sizing: border-box;
}
.source-card-num {
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 6px;
  opacity: 0.85;
}
.source-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.source-card-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  flex-wrap: wrap;
}
.source-card-lbl {
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.source-card-val {
  opacity: 0.75;
  word-break: break-word;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
