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

:root {
  --bg-base:       #0a0b0f;
  --bg-surface:    #10121a;
  --bg-card:       #13151f;
  --bg-elevated:   #1a1d2e;
  --bg-input:      #1e2133;

  --border:        rgba(255,255,255,0.07);
  --border-focus:  rgba(99,102,241,0.5);

  --text-primary:   #f0f1f6;
  --text-secondary: #8b8fa8;
  --text-muted:     #555a72;

  --indigo:        #6366f1;
  --purple:        #a855f7;
  --indigo-dim:    rgba(99,102,241,0.15);
  --purple-dim:    rgba(168,85,247,0.10);

  --gradient-main: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --gradient-glow: linear-gradient(135deg, rgba(99,102,241,0.3) 0%, rgba(168,85,247,0.2) 100%);

  --radius-sm:  8px;
  --radius-md:  14px;
  --radius-lg:  20px;
  --radius-xl:  28px;

  --shadow-card: 0 4px 32px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 40px rgba(99,102,241,0.15);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Screen System ──────────────────────────────────────────── */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  overflow-y: hidden;
}

.screen.active {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.4s ease;
}

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

/* ── Background Mesh ────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(99,102,241,0.12) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(168,85,247,0.08) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Loading Screen ─────────────────────────────────────────── */
#screen-loading {
  align-items: center;
  justify-content: center;
}

.loading-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  z-index: 1;
}

.logo-mark svg {
  width: 64px;
  height: 64px;
  animation: logoPulse 2s ease-in-out infinite;
}

@keyframes logoPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.7; transform: scale(0.95); }
}

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

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

.loading-text {
  color: var(--text-secondary);
  font-size: 14px;
  letter-spacing: 0.02em;
}

/* ── Center Card (Error / Complete) ────────────────────────── */
.center-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  max-width: 480px;
  width: calc(100% - 32px);
  margin: auto;
  z-index: 1;
  text-align: center;
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.error-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: #ef4444;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-weight: 600;
}

.center-card h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 12px;
}

.center-card p {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
}

.error-sub {
  margin-top: 8px;
  font-size: 13px !important;
  color: var(--text-muted) !important;
}

/* ── Interview Layout ───────────────────────────────────────── */
.interview-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 0 16px 20px;
  z-index: 1;
}

/* ── Header ─────────────────────────────────────────────────── */
.interview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border);
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-badge,
.progress-info {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--indigo-dim);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--indigo);
  letter-spacing: 0.02em;
}

.timer-label {
  color: #fb923c;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Progress Track ─────────────────────────────────────────── */
.progress-track {
  height: 3px;
  background: var(--border);
  margin: 0 -16px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-main);
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Welcome Card ───────────────────────────────────────────── */
.welcome-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 40px 36px;
  margin-top: 32px;
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

/* ── AI Avatar ──────────────────────────────────────────────── */
.ai-avatar {
  position: relative;
  width: 56px;
  height: 56px;
  background: var(--gradient-main);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.ai-avatar.large {
  width: 72px;
  height: 72px;
}

.ai-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(99,102,241,0.3);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50%       { transform: scale(1.1); opacity: 0; }
}

/* ── Welcome Typography ─────────────────────────────────────── */
.welcome-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 16px;
  line-height: 1.3;
}

.gradient-text {
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-greeting {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

/* ── Info Grid ──────────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.info-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.info-icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 2px;
}

.info-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}

.info-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

/* ── Tips Box ───────────────────────────────────────────────── */
.tips-box {
  background: var(--indigo-dim);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 28px;
}

.tips-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--indigo);
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}

.tips-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tips-list li {
  font-size: 13px;
  color: var(--text-secondary);
  padding-left: 16px;
  position: relative;
  line-height: 1.5;
}

.tips-list li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--indigo);
  font-size: 11px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--gradient-main);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  letter-spacing: 0.01em;
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: var(--transition);
}

.btn-primary:hover::before {
  background: rgba(255,255,255,0.08);
}

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

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-primary.btn-large {
  width: 100%;
  justify-content: center;
  padding: 16px 24px;
  font-size: 15px;
  border-radius: var(--radius-md);
}

/* ── Chat Area ──────────────────────────────────────────────── */
.chat-area {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 0 32px;
  min-height: 0;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* Custom Scrollbar for Chat Area */
.chat-area::-webkit-scrollbar {
  width: 6px;
}
.chat-area::-webkit-scrollbar-track {
  background: transparent;
}
.chat-area::-webkit-scrollbar-thumb {
  background-color: var(--border-focus);
  border-radius: 10px;
}

/* ── Message Bubbles ────────────────────────────────────────── */
.message {
  display: flex;
  gap: 12px;
  animation: msgIn 0.3s ease;
}

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

.message.ai {
  align-items: flex-start;
}

.message.user {
  align-items: flex-start;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.message.ai .msg-avatar {
  background: var(--gradient-main);
}

.message.user .msg-avatar {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 14px;
}

.msg-content {
  max-width: 80%;
}

.msg-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.message.user .msg-meta {
  text-align: right;
}

.msg-bubble {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 14.5px;
  line-height: 1.65;
}

.message.ai .msg-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  color: var(--text-primary);
}

.message.ai.highlight .msg-bubble {
  background: var(--gradient-glow);
  border-color: rgba(99,102,241,0.3);
}

.message.user .msg-bubble {
  background: var(--indigo-dim);
  border: 1px solid rgba(99,102,241,0.2);
  border-top-right-radius: 4px;
  color: var(--text-primary);
}

/* Question number badge */
.question-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--gradient-main);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 10px;
  letter-spacing: 0.03em;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  border-top-left-radius: 4px;
  width: fit-content;
}

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

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

@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Answer Panel ───────────────────────────────────────────── */
.answer-panel {
  position: relative;
  flex-shrink: 0;
  z-index: 20;
  padding: 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}

.answer-box {
  max-width: 760px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition);
}

.answer-box:focus-within {
  border-color: var(--border-focus);
}

.answer-textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font);
  font-size: 14.5px;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 80px;
  max-height: 160px;
}

.answer-textarea::placeholder {
  color: var(--text-muted);
}

.answer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.char-count {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Completion Screen ──────────────────────────────────────── */
.complete-animation {
  margin-bottom: 28px;
}

.checkmark-circle {
  display: inline-flex;
  animation: scaleIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.complete-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 16px;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.complete-message {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 28px;
}

.complete-stats {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  .welcome-card          { padding: 28px 20px; }
  .info-grid             { grid-template-columns: 1fr; }
  .welcome-title         { font-size: 22px; }
  .msg-content           { max-width: 90%; }
  .center-card           { padding: 36px 24px; }
}

/* ── Embed Mode (.is-embedded) ──────────────────────────────── */
body.is-embedded {
  background: transparent;
}
body.is-embedded::before {
  display: none; /* Hide background mesh */
}
.is-embedded .interview-header {
  display: none; /* Hide header in embed */
}
.is-embedded .interview-layout {
  padding-top: 16px;
}
.is-embedded .welcome-card,
.is-embedded .center-card {
  box-shadow: none;
  border: none;
  padding: 24px 16px;
  background: transparent;
}
.is-embedded .answer-panel {
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
}
.is-embedded .answer-box {
  box-shadow: none;
  background: var(--bg-input);
}
