/* ─── CallBill Client — Mobile-First Survey Page ─────────────────────────── */

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

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --accent: #6366f1;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --green: #10b981;
  --red: #ef4444;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: rgba(255,255,255,0.08);
  --radius: 16px;
  --font: 'Inter', -apple-system, sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ─── Screens ─────────────────────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ─── Loading Screen ──────────────────────────────────────────────────────── */
.logo-wrap {
  text-align: center;
  margin-bottom: 48px;
}

.logo-icon {
  font-size: 56px;
  margin-bottom: 12px;
  animation: float 3s ease-in-out infinite;
}

.logo-text {
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, #6366f1, #8b5cf6, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

.loading-msg {
  color: var(--text-muted);
  font-size: 14px;
}

/* ─── Error Screen ────────────────────────────────────────────────────────── */
.error-wrap {
  text-align: center;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius);
  padding: 40px 32px;
  max-width: 360px;
  width: 100%;
}

.error-icon { font-size: 48px; margin-bottom: 16px; }

.error-wrap h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 8px;
}

.error-wrap p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

/* ─── Permission Screen ───────────────────────────────────────────────────── */
.perm-wrap {
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.perm-icon {
  font-size: 56px;
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}

.perm-wrap h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}

.perm-wrap > p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.7;
  margin-bottom: 24px;
}

.perm-list {
  list-style: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 28px;
  text-align: left;
}

.perm-list li {
  font-size: 14px;
  padding: 6px 0;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.perm-list li:last-child { border-bottom: none; }

/* ─── Button ──────────────────────────────────────────────────────────────── */
.btn {
  width: 100%;
  padding: 14px 24px;
  border: none;
  border-radius: 12px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
  box-shadow: 0 4px 20px var(--accent-glow);
}

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

/* ─── Waiting Screen ──────────────────────────────────────────────────────── */
.wait-wrap {
  text-align: center;
  width: 100%;
  max-width: 400px;
  position: relative;
}

.pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: var(--accent-glow);
  animation: pulse-expand 2s ease-out infinite;
  z-index: 0;
}

.wait-icon {
  font-size: 40px;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.wait-wrap h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.wait-wrap > p {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}

.camera-preview-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--border);
  background: #000;
  aspect-ratio: 9/16;
  max-height: 45vh;
}

#local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cam-label {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 20px;
}

.session-info {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--bg-card);
  border-radius: 10px;
  padding: 10px 16px;
}

/* ─── Active Screen ───────────────────────────────────────────────────────── */
#screen-active {
  padding: 0;
  justify-content: flex-start;
}

.active-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.rec-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 1px;
}

.rec-dot {
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  animation: blink 1s step-end infinite;
}

.active-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  flex: 1;
  text-align: center;
  margin: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timer {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--green);
}

.btn-switch-cam, .btn-torch {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
}
.btn-switch-cam:active, .btn-torch:active {
  transform: scale(0.9);
  background: rgba(255,255,255,0.4);
}
.btn-torch.active {
  background: rgba(255,215,0,0.4);
  border-color: rgba(255,215,0,0.8);
}

.active-video-wrap {
  flex: 1;
  width: 100%;
  position: relative;
  background: #000;
  overflow: hidden;
  touch-action: none;
}

#active-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.1s ease-out;
  transform-origin: center center;
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
}

.chat-overlay {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 40vh;
  overflow-y: auto;
}

.chat-bubble {
  background: rgba(99, 102, 241, 0.85);
  color: white;
  padding: 10px 14px;
  border-radius: 12px 12px 0 12px;
  font-size: 14px;
  font-weight: 500;
  max-width: 85%;
  align-self: flex-end;
  backdrop-filter: blur(8px);
  animation: slideUp 0.3s ease;
  box-shadow: 0 4px 12px rgba(99,102,241,0.4);
  opacity: 0.8;
}

/* ─── Instruction Banner (Instruksi Besar dari Admin) ────────────────────── */
.instruction-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  width: 90%;
  max-width: 360px;
  background: linear-gradient(135deg, rgba(99,102,241,0.95), rgba(139,92,246,0.95));
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  padding: 24px 20px 20px;
  text-align: center;
  backdrop-filter: blur(16px);
  box-shadow:
    0 0 0 4px rgba(99,102,241,0.3),
    0 20px 40px rgba(0,0,0,0.5),
    0 0 60px rgba(99,102,241,0.4);
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

.instruction-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  animation: instructionAttention 0.5s ease forwards, instructionGlow 2s ease-in-out 0.5s infinite alternate;
}

.instruction-banner.hide {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
}

.instruction-arrow {
  font-size: 28px;
  margin-bottom: 4px;
  animation: bounce 1s ease-in-out infinite;
  display: none; /* hidden, not needed now */
}

.instruction-icon {
  font-size: 32px;
  margin-bottom: 10px;
  animation: iconBounce 0.8s ease-in-out;
}

.instruction-text {
  font-size: 20px;
  font-weight: 700;
  color: white;
  line-height: 1.4;
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
  letter-spacing: 0.3px;
}

.instruction-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 22px;
  border: 3px solid rgba(255,255,255,0.5);
  animation: instructionRipple 1.5s ease-out infinite;
  pointer-events: none;
}

/* ─── Voice Indicator ──────────────────────────────────────────────────── */
.voice-indicator {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16,185,129,0.9);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 50px;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(16,185,129,0.4);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform: translateX(-50%) translateY(-20px);
}

.voice-indicator.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.voice-waves {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 20px;
}

.voice-waves span {
  display: block;
  width: 3px;
  background: white;
  border-radius: 3px;
  animation: voiceWave 0.8s ease-in-out infinite;
}

.voice-waves span:nth-child(1) { animation-delay: 0s; }
.voice-waves span:nth-child(2) { animation-delay: 0.15s; }
.voice-waves span:nth-child(3) { animation-delay: 0.3s; }
.voice-waves span:nth-child(4) { animation-delay: 0.45s; }

.voice-label {
  color: white;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.active-footer {
  width: 100%;
  padding: 12px 16px;
  background: rgba(15,23,42,0.95);
  text-align: center;
}

.active-note {
  font-size: 13px;
  color: var(--green);
  font-weight: 600;
}

.active-note-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── Done Screen ─────────────────────────────────────────────────────────── */
.done-wrap {
  text-align: center;
  max-width: 360px;
  width: 100%;
}

.done-icon {
  font-size: 72px;
  margin-bottom: 24px;
  animation: pop 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.done-wrap h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--green);
}

.done-wrap > p {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
}

.done-sub {
  margin-top: 8px;
  font-size: 13px !important;
}

/* ─── Animations ──────────────────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes pulse-expand {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

@keyframes blink {
  50% { opacity: 0; }
}

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

@keyframes pop {
  0% { transform: scale(0.5); }
  70% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

@keyframes instructionAttention {
  0% { transform: translate(-50%, -50%) scale(1); }
  10% { transform: translate(-50%, -50%) scale(1) rotate(-2deg); }
  20% { transform: translate(-50%, -50%) scale(1) rotate(2deg); }
  30% { transform: translate(-50%, -50%) scale(1) rotate(-1deg); }
  40% { transform: translate(-50%, -50%) scale(1) rotate(1deg); }
  50%, 100% { transform: translate(-50%, -50%) scale(1) rotate(0); }
}

@keyframes instructionGlow {
  from { box-shadow: 0 0 0 4px rgba(99,102,241,0.3), 0 20px 40px rgba(0,0,0,0.5), 0 0 60px rgba(99,102,241,0.4); }
  to { box-shadow: 0 0 0 8px rgba(99,102,241,0.15), 0 20px 40px rgba(0,0,0,0.5), 0 0 80px rgba(139,92,246,0.6); }
}

@keyframes instructionRipple {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.15); }
}

@keyframes iconBounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

@keyframes voiceWave {
  0%, 100% { height: 4px; }
  50% { height: 18px; }
}

/* ─── Zoom Slider ─── */
.zoom-container {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  padding: 8px 16px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 100;
  width: 80%;
  max-width: 300px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  border: 1px solid rgba(255,255,255,0.1);
  animation: slideUp 0.3s ease;
}

.zoom-icon {
  font-size: 1.2rem;
}

.zoom-slider {
  flex: 1;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.2);
  height: 4px;
  border-radius: 2px;
  outline: none;
}

.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #3b82f6;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.zoom-value {
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  min-width: 35px;
  text-align: right;
}
