@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.85);
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-amber: #f59e0b;
  --glow-shadow: 0 0 25px rgba(59, 130, 246, 0.35);
  --recording-glow: 0 0 35px rgba(239, 68, 68, 0.6);
  --font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  font-family: var(--font-family);
  direction: rtl;
  text-align: right;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  user-select: none;
}

/* Background aesthetic gradient */
.bg-ambient {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  background: radial-gradient(circle at 15% 15%, rgba(59, 130, 246, 0.15) 0%, transparent 40%),
              radial-gradient(circle at 85% 85%, rgba(16, 185, 129, 0.12) 0%, transparent 45%);
  z-index: 0;
}

.app-container {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 780px;
  padding: 24px;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 36px 32px;
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
}

/* Header */
.interview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

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

.logo-badge .icon-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.logo-text h1 {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.logo-text p {
  font-size: 13px;
  color: var(--text-muted);
}

.candidate-pill {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  color: #93c5fd;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Strict warning alert box */
.focus-alert-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fca5a5;
  font-size: 13.5px;
  line-height: 1.6;
}

.focus-alert-box.active-monitoring {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--accent-red);
  box-shadow: 0 0 10px var(--accent-red);
  animation: pulse 1.5s infinite;
  flex-shrink: 0;
}

.pulse-dot.green {
  background-color: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Sections visibility */
.section {
  display: none;
}
.section.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Waiting Screen */
.waiting-box {
  text-align: center;
  padding: 40px 10px;
}

.waiting-spinner {
  width: 68px;
  height: 68px;
  border: 4px solid rgba(59, 130, 246, 0.2);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 24px;
}

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

.waiting-box h2 {
  font-size: 22px;
  margin-bottom: 12px;
  color: #fff;
}

.waiting-box p {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 480px;
  margin: 0 auto 16px;
  line-height: 1.7;
}

.token-badge {
  display: inline-block;
  background: #334155;
  color: #cbd5e1;
  padding: 4px 12px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 14px;
}

/* Question Section */
.question-container {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 28px;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  transition: all 0.3s ease;
}

.question-badge-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.question-badge {
  background: var(--accent-blue);
  color: white;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.question-placeholder {
  color: var(--text-muted);
  font-size: 16px;
  text-align: center;
  line-height: 1.8;
}

.question-content {
  display: none;
}

.question-content.visible {
  display: block;
  animation: slideUp 0.3s ease;
}

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

.question-title {
  font-size: 17px;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 8px;
}

.question-prompt {
  font-size: 18px;
  font-weight: 500;
  color: #ffffff;
  line-height: 1.8;
}

/* Audio visualizer canvas */
.visualizer-wrapper {
  margin: 20px 0;
  text-align: center;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#visualizerCanvas {
  width: 100%;
  max-width: 450px;
  height: 60px;
  border-radius: 10px;
}

/* Live transcript preview */
.transcript-preview {
  min-height: 24px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #cbd5e1;
  text-align: center;
  font-style: italic;
  opacity: 0.85;
}

/* Hold-to-Talk Record Button */
.button-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 10px;
}

.record-btn {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 4px solid #3b82f6;
  background: radial-gradient(circle, #2563eb 0%, #1d4ed8 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  outline: none;
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.record-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 12px 30px rgba(37, 99, 235, 0.5);
}

.record-btn:active, .record-btn.recording {
  border-color: #ef4444;
  background: radial-gradient(circle, #dc2626 0%, #b91c1c 100%);
  transform: scale(1.12);
  box-shadow: var(--recording-glow);
  animation: recordPulse 1.2s infinite alternate ease-in-out;
}

@keyframes recordPulse {
  0% { box-shadow: 0 0 20px rgba(239, 68, 68, 0.5); }
  100% { box-shadow: 0 0 45px rgba(239, 68, 68, 0.9); }
}

.record-btn .btn-icon {
  font-size: 34px;
}

.record-btn .btn-label {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.recording-timer {
  font-size: 15px;
  font-family: monospace;
  font-weight: 700;
  color: #f87171;
  display: none;
}
.recording-timer.visible {
  display: block;
}

.instruction-text {
  font-size: 15px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

.permission-banner {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fde68a;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 20px;
  display: none;
  text-align: center;
}
.permission-banner.show {
  display: block;
}

/* Result Screen */
.result-box {
  text-align: center;
  padding: 30px 10px;
}

.result-badge {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  margin: 0 auto 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
}

.result-badge.passed {
  background: rgba(16, 185, 129, 0.15);
  border: 3px solid var(--accent-green);
  color: var(--accent-green);
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.35);
}

.result-badge.failed {
  background: rgba(245, 158, 11, 0.15);
  border: 3px solid var(--accent-amber);
  color: var(--accent-amber);
}

.result-badge.rejected {
  background: rgba(239, 68, 68, 0.15);
  border: 3px solid var(--accent-red);
  color: var(--accent-red);
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.4);
}

.score-display {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -1px;
}

.score-display span {
  font-size: 24px;
  color: var(--text-muted);
  font-weight: 400;
}

.result-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 16px;
}

.result-message {
  font-size: 17px;
  line-height: 1.8;
  max-width: 540px;
  margin: 0 auto 28px;
  color: #e2e8f0;
}

/* Fullscreen Rejection Overlay for Focus Loss */
.disqualification-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(14px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.disqualification-overlay.show {
  display: flex;
  animation: fadeIn 0.4s ease;
}

.disqualification-card {
  max-width: 520px;
  width: 100%;
  background: #1e1e2d;
  border: 2px solid var(--accent-red);
  box-shadow: 0 0 60px rgba(239, 68, 68, 0.4);
  border-radius: 20px;
  padding: 36px 28px;
  text-align: center;
}

.disqualification-card .alert-icon {
  font-size: 54px;
  color: var(--accent-red);
  margin-bottom: 16px;
}

.disqualification-card h2 {
  font-size: 24px;
  color: #fff;
  margin-bottom: 14px;
}

.disqualification-card p {
  color: #cbd5e1;
  font-size: 15px;
  line-height: 1.8;
  margin-bottom: 24px;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .app-container {
    padding: 16px;
  }
  .card {
    padding: 24px 18px;
    border-radius: 18px;
  }
  .record-btn {
    width: 120px;
    height: 120px;
  }
  .question-prompt {
    font-size: 16px;
  }
  .score-display {
    font-size: 40px;
  }
}
