/* ============================================================
   CAMERA — Face capture UI, Face ID-inspired
============================================================ */

/* --- Photo tabs nav --- */
.photo-tabs {
  display: flex;
  gap: var(--space-2);
  padding: 4px;
  background-color: var(--color-bg);
  border-radius: var(--radius-full);
  width: fit-content;
  margin-inline: auto;
  margin-bottom: var(--space-6);
}

.photo-tab {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.4rem 1rem;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-muted);
  transition:
    background-color var(--duration-base) var(--ease-out),
    color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out);
}

.photo-tab--active,
.photo-tab[aria-selected="true"] {
  background-color: var(--color-surface);
  color: var(--color-ink);
  box-shadow: var(--shadow-xs);
}

.photo-tab:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.photo-tab--done {
  color: var(--color-green);
}

/* --- Camera container --- */
.camera-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
}

/* --- Photo panel --- */
.photo-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
}

.photo-panel[hidden] {
  display: none;
}

/* --- Viewport: the camera window --- */
.camera-viewport {
  position: relative;
  width: 300px;
  height: 300px;
  border-radius: var(--radius-full);
  overflow: hidden;
  background-color: #1a1a1f;
  flex-shrink: 0;
}

/* --- Video feed --- */
.camera-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
  transform: scaleX(-1); /* Mirror for selfie */
  opacity: 0;
  transition: opacity var(--duration-slow) var(--ease-out);
}

.camera-video.is-active {
  opacity: 1;
}

/* --- Captured photo preview --- */
.photo-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-full);
  transform: scaleX(-1);
}

.photo-preview[hidden] {
  display: none;
}

/* --- Guide rings (Face ID style) --- */
.camera-guide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}

.guide-ring {
  position: absolute;
  border-radius: var(--radius-full);
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.guide-ring--outer {
  width: calc(100% - 10px);
  height: calc(100% - 10px);
  border-color: rgba(255, 255, 255, 0.2);
  border-style: dashed;
  border-width: 1.5px;
  animation: rotateRing 12s linear infinite;
}

.guide-ring--inner {
  width: calc(100% - 32px);
  height: calc(100% - 32px);
  border-color: rgba(255, 255, 255, 0.12);
}

/* Face icon guide */
.guide-face {
  position: absolute;
  width: 60px;
  height: 60px;
  color: rgba(255, 255, 255, 0.3);
}

.guide-face svg {
  width: 100%;
  height: 100%;
}

@keyframes rotateRing {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* Active state: rings glow green when camera is on */
.camera-viewport.is-streaming .guide-ring--outer {
  border-color: rgba(39, 174, 96, 0.5);
  border-style: solid;
  animation: rotateRing 8s linear infinite;
  box-shadow: 0 0 0 1px rgba(39, 174, 96, 0.15) inset;
}

/* Captured state: ring goes solid green */
.camera-viewport.is-captured .guide-ring--outer {
  border-color: rgba(39, 174, 96, 0.8);
  border-style: solid;
  animation: none;
}

.camera-viewport.is-captured .guide-ring--inner {
  border-color: rgba(39, 174, 96, 0.3);
}

/* --- Camera instruction text --- */
.camera-instruction {
  font-size: var(--text-sm);
  color: var(--color-muted);
  text-align: center;
  max-width: 32ch;
  line-height: 1.55;
}

/* --- Camera actions --- */
.camera-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  min-height: 60px;
}

/* Start camera button */
.btn-camera-start {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.625rem 1.25rem;
  background-color: var(--color-ink);
  color: #fff;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  transition:
    background-color var(--duration-base) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.btn-camera-start:hover {
  background-color: #2a2a2f;
}

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

/* Capture button: big circle shutter */
.btn-capture {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background-color: var(--color-green);
  box-shadow: var(--shadow-green);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
  position: relative;
}

.btn-capture:hover {
  transform: scale(1.06);
  box-shadow: 0 0 0 6px rgba(39, 174, 96, 0.2), var(--shadow-green);
}

.btn-capture:active {
  transform: scale(0.94);
  box-shadow: var(--shadow-xs);
}

.capture-ring {
  display: block;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-full);
  border: 3px solid rgba(255, 255, 255, 0.6);
}

/* Retake button */
.btn-retake {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.5rem 1rem;
  color: var(--color-muted);
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  transition:
    color var(--duration-base) var(--ease-out),
    border-color var(--duration-base) var(--ease-out);
}

.btn-retake:hover {
  color: var(--color-ink);
  border-color: var(--color-ink-30);
}

.btn-retake[hidden] {
  display: none;
}

/* --- Camera permission denied --- */
.camera-denied {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8);
  text-align: center;
  color: var(--color-muted);
  background-color: var(--color-red-light);
  border: 1px solid rgba(229, 57, 53, 0.2);
  border-radius: var(--radius-xl);
}

.camera-denied:not([hidden]) {
  display: flex;
}

.camera-denied svg {
  color: var(--color-red);
}

.camera-denied p {
  font-size: var(--text-sm);
  max-width: 36ch;
  line-height: 1.6;
  color: var(--color-red);
}

/* Capture flash animation */
@keyframes captureFlash {
  0%   { opacity: 0; }
  10%  { opacity: 0.6; }
  100% { opacity: 0; }
}

.camera-viewport.flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: white;
  border-radius: var(--radius-full);
  animation: captureFlash 0.4s var(--ease-out) forwards;
  pointer-events: none;
  z-index: 10;
}

/* ============================================================
   INSURANCE CAMERA — document capture UI
============================================================ */

.ins-mode-tabs {
  display: flex;
  gap: var(--space-2);
  padding: 4px;
  background-color: var(--color-bg);
  border-radius: var(--radius-full);
  width: fit-content;
  margin-bottom: var(--space-3);
  border: 1.5px solid var(--color-border);
}

.ins-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.4rem 1rem;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-muted);
  transition:
    background-color var(--duration-base) var(--ease-out),
    color var(--duration-base) var(--ease-out),
    box-shadow var(--duration-base) var(--ease-out);
}

.ins-tab--active {
  background-color: var(--color-surface);
  color: var(--color-ink);
  box-shadow: var(--shadow-xs);
}

.ins-panel[hidden] {
  display: none;
}

/* Camera box: rectangular for documents */
.ins-camera-box {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background-color: #1a1a1f;
  border-radius: var(--radius-xl);
  overflow: hidden;
}

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

/* Document frame guide */
.ins-doc-frame {
  position: absolute;
  inset: 12px;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  pointer-events: none;
}

.ins-doc-frame::before,
.ins-doc-frame::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: #27AE60;
  border-style: solid;
}
.ins-doc-frame::before {
  top: -2px; left: -2px;
  border-width: 3px 0 0 3px;
  border-radius: 4px 0 0 0;
}
.ins-doc-frame::after {
  bottom: -2px; right: -2px;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 4px 0;
}

/* Captured photo preview */
.ins-photo-preview-box {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 2px solid var(--color-green);
}

.ins-photo-preview-box[hidden] {
  display: none;
}

.ins-photo-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ins-camera-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  min-height: 56px;
  margin-top: var(--space-4);
}

.ins-camera-hint {
  font-size: var(--text-xs);
  color: var(--color-muted);
  text-align: center;
  margin-top: var(--space-2);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .guide-ring--outer {
    animation: none;
  }
  .camera-viewport.is-streaming .guide-ring--outer {
    animation: none;
  }
}

/* Responsive */
@media (max-width: 480px) {
  .camera-viewport {
    width: 260px;
    height: 260px;
  }

  .photo-tabs {
    width: 100%;
    justify-content: center;
  }

  .photo-tab {
    flex: 1;
    justify-content: center;
    font-size: var(--text-xs);
    padding: 0.4rem 0.5rem;
  }
}
