/* ============================================
   Interview Assist — Stealth Dark Theme
   Optimized for glanceability on second screen
   ============================================ */

/* --- CSS Variables (Design Tokens) --- */
:root {
  /* Background */
  --bg-primary: #07090f;
  --bg-secondary: #0d1117;
  --bg-card: #111827;
  --bg-card-hover: #1a2332;
  --bg-elevated: #161f2e;
  --bg-input: #0f1621;

  /* Accent Colors */
  --accent-blue: #4f8cff;
  --accent-blue-dim: #3a6fd4;
  --accent-purple: #a855f7;
  --accent-green: #00e676;
  --accent-red: #ff4757;
  --accent-orange: #ff9f43;
  --accent-cyan: #06d6a0;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #4f8cff, #a855f7);
  --gradient-code: linear-gradient(135deg, #00e676, #06d6a0);
  --gradient-bg-glow: radial-gradient(ellipse at 50% 0%, rgba(79,140,255,0.08) 0%, transparent 60%);

  /* Text */
  --text-primary: #e8edf5;
  --text-secondary: #8b95a8;
  --text-muted: #5a6577;
  --text-accent: #4f8cff;

  /* Borders */
  --border-subtle: rgba(255,255,255,0.06);
  --border-active: rgba(79,140,255,0.3);

  /* Shadows */
  --shadow-card: 0 2px 12px rgba(0,0,0,0.3);
  --shadow-glow-blue: 0 0 20px rgba(79,140,255,0.15);
  --shadow-glow-green: 0 0 20px rgba(0,230,118,0.15);

  /* Spacing */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.2);
}

/* --- App Layout --- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 100%;
  position: relative;
  background: var(--gradient-bg-glow), var(--bg-primary);
}

/* --- Top Bar --- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 10;
  gap: 12px;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.top-bar-center {
  flex: 1;
  text-align: center;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  letter-spacing: 0.3px;
}

.app-logo {
  color: var(--accent-blue);
}

.mic-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.mic-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}

.mic-dot.listening {
  background: var(--accent-red);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.mic-dot.paused {
  background: var(--accent-orange);
}

.mic-dot.error {
  background: var(--accent-red);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,71,87,0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(255,71,87,0); }
}

.mic-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  transition: color 0.3s;
}

.mic-label.listening {
  color: var(--accent-red);
}

.stats {
  display: flex;
  gap: 8px;
}

.stat-item {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border-color: var(--border-active);
}

/* --- Transcript Strip --- */
.transcript-strip {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  gap: 10px;
  min-height: 38px;
}

.transcript-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  display: flex;
}

.transcript-icon.active {
  color: var(--accent-blue);
}

.transcript-text {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
  transition: color 0.2s;
}

.transcript-text.active {
  color: var(--text-primary);
  font-style: normal;
}

/* Sound Wave Animation */
.sound-wave {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 16px;
  opacity: 0;
  transition: opacity 0.3s;
}

.sound-wave.active {
  opacity: 1;
}

.sound-wave span {
  display: block;
  width: 3px;
  height: 4px;
  background: var(--accent-blue);
  border-radius: 2px;
  animation: none;
}

.sound-wave.active span {
  animation: wave 1s ease-in-out infinite;
}

.sound-wave span:nth-child(1) { animation-delay: 0s; }
.sound-wave span:nth-child(2) { animation-delay: 0.15s; }
.sound-wave span:nth-child(3) { animation-delay: 0.3s; }
.sound-wave span:nth-child(4) { animation-delay: 0.45s; }
.sound-wave span:nth-child(5) { animation-delay: 0.6s; }

@keyframes wave {
  0%, 100% { height: 4px; }
  50% { height: 14px; }
}

/* --- Answer Feed --- */
.answer-feed {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0; /* CRITICAL: Allows flex child to shrink and enable scrolling */
}

/* Welcome Card */
.welcome-card {
  text-align: center;
  padding: 48px 24px;
  margin: auto 0;
}

.welcome-icon {
  margin-bottom: 16px;
  opacity: 0.7;
}

.welcome-card h2 {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.welcome-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 360px;
  margin: 0 auto 24px;
  line-height: 1.5;
}

.shortcut-hints {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.mobile-hints {
  display: none;
}

.shortcut {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  min-width: 28px;
  text-align: center;
}

/* --- QA Card (Chat Message Wrapper) --- */
.qa-card {
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
  animation: slideIn 0.25s ease-out;
  min-width: 0; 
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 8px;
}

.qa-card:hover {
  /* No border hover in chat layout */
}

.qa-card.has-code {
  /* Replaced bordered card styling */
}

.qa-card.general {
  /* Replaced bordered card styling */
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Question Section (User Bubble) */
.qa-question {
  align-self: flex-end;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 20px 20px 4px 20px;
  padding: 12px 18px;
  max-width: 88%;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.qa-question-icon {
  display: none; /* Hide the generic 'Q' */
}

.qa-question-text {
  font-size: 0.95rem;
  color: var(--text-primary);
  line-height: 1.5;
  font-weight: 500;
}

/* Answer Section (AI Response) */
.qa-answer {
  align-self: flex-start;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 0 4px;
  min-width: 0;
}

.qa-answer::before {
  content: '✨';
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.qa-answer-content {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-primary);
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 0;
  width: 100%;
}

.qa-answer-content h1,
.qa-answer-content h2,
.qa-answer-content h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-blue);
  margin: 12px 0 6px;
}

.qa-answer-content h1:first-child,
.qa-answer-content h2:first-child,
.qa-answer-content h3:first-child {
  margin-top: 0;
}

.qa-answer-content p {
  margin: 6px 0;
}

.qa-answer-content ul, .qa-answer-content ol {
  margin: 6px 0;
  padding-left: 20px;
}

.qa-answer-content li {
  margin: 3px 0;
}

.qa-answer-content strong {
  color: #fff;
  font-weight: 600;
}

.qa-answer-content em {
  color: var(--text-secondary);
}

/* Code blocks in answers */
.qa-answer-content pre {
  margin: 10px 0;
  border-radius: var(--radius-md);
  position: relative;
  overflow-x: auto !important;
  max-width: 100%;
}

.qa-answer-content pre code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  tab-size: 4;
}

.qa-answer-content code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  background: rgba(79,140,255,0.1);
  color: var(--accent-blue);
  padding: 1px 5px;
  border-radius: 4px;
  word-break: break-word;
}

/* Code Block Wrapper */
.code-block-wrapper {
  position: relative;
  margin: 10px 0;
  max-width: 100%;
  width: 100%;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #1a1f2e;
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-size: 0.7rem;
}

.code-lang-badge {
  color: var(--accent-green);
  font-weight: 600;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.copy-btn {
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.68rem;
  font-family: var(--font-sans);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.copy-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

.copy-btn.copied {
  color: var(--accent-green);
  border-color: var(--accent-green);
}

.code-block-wrapper pre {
  margin: 0 !important;
  border-radius: 0 0 var(--radius-md) var(--radius-md) !important;
  border: 1px solid var(--border-subtle);
  border-top: none;
  overflow-x: auto !important;
  max-width: 100%;
}

/* Complexity badge */
.complexity-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 4px 10px;
  background: rgba(0,230,118,0.08);
  border: 1px solid rgba(0,230,118,0.15);
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--accent-green);
}

/* Loading indicator */
.qa-loading {
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.typing-dots {
  display: flex;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--accent-blue);
  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%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

.typing-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* --- Bottom Bar --- */
.bottom-bar {
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Mic Button */
.mic-button {
  position: relative;
  height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  background: var(--bg-elevated);
  border: 2px solid var(--accent-blue);
  color: var(--accent-blue);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  transition: all 0.3s;
  z-index: 1;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

.mic-button:hover {
  background: rgba(79,140,255,0.08);
}

.mic-button.active {
  border-color: var(--accent-red);
  color: #fff;
  background: var(--accent-red);
  box-shadow: 0 0 20px rgba(255,71,87,0.3);
}

.mic-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 30px;
  border: 2px solid var(--accent-red);
  opacity: 0;
  pointer-events: none;
}

.mic-button.active .mic-pulse {
  animation: micPulse 1.5s ease-out infinite;
}

@keyframes micPulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Text Input */
.text-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s;
}

.text-input-wrap:focus-within {
  border-color: var(--border-active);
}

#textInput {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  outline: none;
}

#textInput::placeholder {
  color: var(--text-muted);
}

.send-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

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

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.modal-overlay.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 90%;
  max-width: 420px;
  text-align: center;
  transform: scale(0.95);
  transition: transform 0.3s;
}

.modal-overlay.visible .modal {
  transform: scale(1);
}

.modal-icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.modal h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.modal p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal a {
  color: var(--accent-blue);
  text-decoration: none;
}

.modal a:hover {
  text-decoration: underline;
}

.input-group {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.input-group input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: var(--border-active);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--gradient-primary);
  border: none;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s, transform 0.1s;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary.loading span {
  opacity: 0.5;
}

.btn-loader {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-primary.loading .btn-loader {
  display: block;
}

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

.modal-note {
  font-size: 0.7rem !important;
  color: var(--text-muted) !important;
  margin-top: 12px !important;
  margin-bottom: 0 !important;
}

.modal-error {
  font-size: 0.78rem;
  color: var(--accent-red);
  margin: 8px 0 0;
  min-height: 0;
  transition: all 0.2s;
}

.modal-error:empty {
  display: none;
}

.btn-secondary {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-family: var(--font-sans);
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border-active);
  color: var(--text-primary);
}

/* --- Error Toast --- */
.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  background: var(--bg-card);
  border: 1px solid var(--accent-red);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  z-index: 2000;
  animation: toastIn 0.3s ease-out;
  max-width: 360px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.toast.success {
  border-color: var(--accent-green);
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .top-bar {
    padding: 6px 10px;
  }

  .stats {
    display: none;
  }

  .desktop-hints {
    display: none !important;
  }

  .mobile-hints {
    display: flex !important;
  }

  .answer-feed {
    padding: 10px;
  }

  .qa-answer {
    padding: 10px;
  }

  .bottom-bar {
    padding: 8px 10px;
  }
}

@media (max-width: 400px) {
  .app-title {
    font-size: 0.82rem;
  }

  .top-bar-center {
    display: none;
  }
}

/* --- Utility Classes --- */
.hidden {
  display: none !important;
}
