:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #24344d;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --accent-primary: #2563eb;
  --accent-hover: #1d4ed8;
  --border-color: #334155;
  --user-bubble: #1d4ed8;
  --assistant-bubble: #1e293b;
  --code-bg: #0f172a;
  --success: #10b981;
  --warning: #f59e0b;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* Header */
.header {
  height: 64px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 10;
}

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

.logo-icon {
  font-size: 24px;
  background: #1e3a8a;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-left h1 {
  font-size: 16px;
  font-weight: 600;
}

.subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

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

.model-select-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.model-select, .custom-model-input {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.model-select:focus, .custom-model-input:focus {
  border-color: var(--accent-primary);
}

.btn {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

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

.btn-primary {
  background-color: var(--accent-primary);
  color: #fff;
}

.btn-primary:hover {
  background-color: #2563eb;
}

/* Layout */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message {
  display: flex;
  gap: 14px;
  max-width: 88%;
  line-height: 1.6;
}

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

.assistant-message {
  align-self: flex-start;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  background-color: var(--bg-card);
  flex-shrink: 0;
}

.user-message .avatar {
  background-color: var(--accent-primary);
}

.message-content {
  background-color: var(--assistant-bubble);
  border: 1px solid var(--border-color);
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  color: #e2e8f0;
}

.user-message .message-content {
  background-color: var(--user-bubble);
  border-color: #2563eb;
  color: #ffffff;
}

.welcome-message {
  max-width: 100%;
}

.welcome-message h3 {
  margin-bottom: 8px;
  color: #60a5fa;
}

.suggested-queries {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.query-pill {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.query-pill:hover {
  background-color: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

/* --- TEMPORARILY DISABLED FOR COMPANY TESTING: Sources UI & Attached Images --- */
.message-sources,
.attached-image {
  display: none !important;
}

.message-sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-secondary);
}

.source-tag {
  display: inline-block;
  background: #0f172a;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 6px;
  margin-bottom: 4px;
  border: 1px solid var(--border-color);
}

.attached-image {
  margin-top: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  max-width: 100%;
  max-height: 280px;
  display: block;
}

/* Markdown formatting in messages */
.message-content p {
  margin-bottom: 8px;
}
.message-content p:last-child {
  margin-bottom: 0;
}
.message-content ol, .message-content ul {
  margin-left: 20px;
  margin-bottom: 8px;
}
.message-content li {
  margin-bottom: 4px;
}
.message-content code {
  font-family: 'Fira Code', monospace;
  background-color: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.message-content strong {
  color: #93c5fd;
}

/* Input Form */
.input-container {
  padding: 16px 20px;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.chat-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}

.chat-form:focus-within {
  border-color: var(--accent-primary);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  resize: none;
  max-height: 140px;
  outline: none;
  line-height: 1.5;
}

.mic-btn {
  background-color: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  height: 35px;
  box-sizing: border-box;
}

.mic-btn:hover {
  background-color: #2b394f;
  color: var(--text-primary);
  border-color: #475569;
}

.mic-btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 1px;
}

.mic-btn.listening {
  background-color: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: #ef4444;
  animation: mic-pulse 1.5s infinite;
}

@keyframes mic-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

.send-btn {
  background-color: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  height: 35px;
  box-sizing: border-box;
}

.send-btn:hover {
  background-color: var(--accent-hover);
}

.input-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-secondary);
  padding: 0 4px;
}

.voice-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.voice-status.listening {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.12);
}

.voice-status.listening::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: #ef4444;
  animation: pulse-dot 1s infinite alternate;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  from { opacity: 0.3; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.1); }
}

.voice-status.success {
  color: #10b981;
  background-color: rgba(16, 185, 129, 0.12);
}

.voice-status.error {
  color: #f87171;
  background-color: rgba(239, 68, 68, 0.12);
}

.voice-status.info {
  color: #60a5fa;
  background-color: rgba(96, 165, 250, 0.12);
}

.voice-status.hidden {
  display: none !important;
}

.session-badge code {
  font-family: 'Fira Code', monospace;
  color: #60a5fa;
}

/* Diagnostics Panel */
.debug-panel {
  width: 360px;
  background-color: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.2s ease;
}

.debug-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.debug-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: #38bdf8;
}

.close-debug-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
}

.debug-content {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-size: 12px;
}

.debug-section h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.debug-box {
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px;
  font-family: 'Fira Code', monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 220px;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

/* Loading Dots */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}
.typing-indicator span {
  width: 6px;
  height: 6px;
  background-color: var(--text-secondary);
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* --- Tester Feedback / Note-taking UI --- */
.message-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.btn-approve-answer {
  background: transparent;
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-approve-answer:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: #10b981;
  color: #6ee7b7;
}

.btn-approve-answer.is-approved {
  background: rgba(16, 185, 129, 0.25);
  color: #a7f3d0;
  border-color: #10b981;
  cursor: default;
}

.btn-add-note {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-add-note:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.btn-add-note.has-note {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: #10b981;
}

.btn-add-note.has-note:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: #34d399;
}

.feedback-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #065f46;
  border: 1px solid #10b981;
  color: #ecfdf5;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  z-index: 2000;
  transition: all 0.3s ease;
}

.feedback-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.feedback-modal {
  background: #1e293b !important;
  background-color: #1e293b !important;
  opacity: 1 !important;
  border: 1px solid #475569 !important;
  border-radius: 12px;
  width: 92%;
  max-width: 520px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.9) !important;
  padding: 24px;
  color: #f8fafc;
}

.feedback-modal h3 {
  margin: 0 0 14px 0;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #ffffff;
}

.feedback-turn-preview {
  background: #0f172a !important;
  border: 1px solid #334155 !important;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.4;
  color: #cbd5e1;
  max-height: 90px;
  overflow-y: auto;
}

.feedback-turn-preview strong {
  color: #93c5fd;
}

.feedback-form-group {
  margin-bottom: 14px;
}

.feedback-form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #f1f5f9;
}

.feedback-form-group select,
.feedback-form-group input,
.feedback-form-group textarea {
  width: 100%;
  background: #0f172a !important;
  border: 1px solid #475569 !important;
  border-radius: 6px;
  padding: 9px 12px;
  color: #ffffff !important;
  font-size: 13px;
  box-sizing: border-box;
}

.feedback-form-group select option {
  background: #0f172a;
  color: #ffffff;
}

.feedback-form-group select:focus,
.feedback-form-group input:focus,
.feedback-form-group textarea:focus {
  outline: none;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35);
}

.feedback-form-group textarea::placeholder,
.feedback-form-group input::placeholder {
  color: #94a3b8;
}

.feedback-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

.feedback-form-group select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background-color: #1e293b !important;
  color: #94a3b8 !important;
}

