/* ==========================================================================
   Face Verification Standalone UI - Minimalist Light Theme (Black & White)
   ========================================================================== */

:root {
  --bg-primary: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-elevated: #ffffff;

  --border-color: #e2e8f0;
  --border-strong: #0f172a;
  --border-focus: #000000;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --color-black: #0f172a;
  --color-white: #ffffff;

  --success-color: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;

  --danger-color: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --transition-fast: 150ms ease;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  padding: 24px 16px 48px;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

.app-container {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

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

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--color-black);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-white);
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand .subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.api-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
}

.api-pill:hover {
  background: #e2e8f0;
  color: var(--text-primary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #eab308;
  display: inline-block;
}

.status-dot.connected {
  background: var(--success-color);
}

.status-dot.disconnected {
  background: var(--danger-color);
}

.btn-icon {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-icon:hover {
  color: var(--text-primary);
  background: #e2e8f0;
}

/* Settings Drawer */
.settings-drawer {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-item label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.setting-item input[type="text"],
.setting-item select {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.setting-item input[type="text"]:focus,
.setting-item select:focus {
  border-color: var(--border-strong);
}

.threshold-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.threshold-slider-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--color-black);
}

.threshold-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 32px;
}

/* Toast */
.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}

.toast.error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-color);
}

.toast.success {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  color: var(--success-color);
}

/* ==========================================================================
   Main Cards Grid (Document on Left, Camera on Right)
   ========================================================================== */

.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 820px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
}

.card-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-badge {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--color-black);
  color: var(--color-white);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-header h2 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
}

.status-tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.status-tag.active {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: #cbd5e1;
}

.status-tag.analyzing {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

/* ==========================================================================
   Panel 1: Document Dropzone
   ========================================================================== */

.dropzone {
  min-height: 340px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fbfcfd;
  cursor: pointer;
  transition: var(--transition-fast);
  overflow: hidden;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.dropzone.dragover {
  background: #f1f5f9;
  border: 2px dashed var(--color-black);
}

.dropzone-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 20px;
}

.upload-icon-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.dropzone:hover .upload-icon-circle {
  color: var(--color-black);
  border-color: #94a3b8;
}

.dropzone-primary-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.dropzone-secondary-text {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 260px;
  margin-bottom: 16px;
}

/* Document Preview State */
.preview-container {
  width: 100%;
  height: 100%;
  min-height: 340px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
}

.doc-preview-img {
  max-width: 100%;
  max-height: 340px;
  object-fit: contain;
}

.doc-overlay-details {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.detected-face-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  pointer-events: auto;
}

.doc-face-thumbnail {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-color);
}

.badge-text {
  display: flex;
  flex-direction: column;
}

.badge-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.badge-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.btn-change-doc {
  pointer-events: auto;
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-change-doc:hover {
  color: var(--danger-color);
  border-color: var(--danger-color);
}

/* Loader Overlay */
.loader-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 10;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--color-black);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loader-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ==========================================================================
   Panel 2: Camera Viewport
   ========================================================================== */

.camera-viewport {
  min-height: 340px;
  position: relative;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.camera-media {
  width: 100%;
  height: 340px;
  object-fit: cover;
  transform: scaleX(-1);
}

/* Face Target Guide Oval */
.face-target-guide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.guide-oval {
  width: 170px;
  height: 220px;
  border: 1px dashed rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
}

.guide-label {
  margin-top: 12px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.65);
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

/* Camera Placeholder (Off state) */
.camera-placeholder {
  position: absolute;
  inset: 0;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 5;
}

.camera-off-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

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

/* Floating Camera Controls */
.camera-controls-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 8;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition-fast);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-primary {
  background: var(--color-black);
  color: var(--color-white);
  border-color: var(--color-black);
}

.btn-primary:hover:not(:disabled) {
  background: #334155;
  border-color: #334155;
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-secondary {
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  border-color: #cbd5e1;
}

.btn-glass {
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-glass:hover {
  background: var(--bg-subtle);
}

/* Hero Compare Action */
.action-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 0;
}

.btn-hero {
  padding: 14px 44px;
  font-size: 16px;
  font-family: var(--font-display);
  letter-spacing: -0.01em;
  border-radius: var(--radius-full);
}

.btn-icon-sparkle {
  font-size: 16px;
}

.action-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   Hero Result Display Section
   ========================================================================== */

.result-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  position: relative;
}

.result-inner {
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: relative;
}

.btn-close-result {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: var(--transition-fast);
}

.btn-close-result:hover {
  color: var(--color-black);
  border-color: #94a3b8;
}

/* Decision Banner */
.decision-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
}

.decision-banner.match {
  background: var(--success-bg);
  border-color: var(--success-border);
}

.decision-banner.not-match {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.decision-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.decision-banner.match .decision-icon-wrap {
  background: var(--success-color);
  color: #ffffff;
}

.decision-banner.not-match .decision-icon-wrap {
  background: var(--danger-color);
  color: #ffffff;
}

.decision-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 2px;
}

.decision-banner.match .decision-title {
  color: var(--success-color);
}

.decision-banner.not-match .decision-title {
  color: var(--danger-color);
}

.decision-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Score Display Panel */
.score-display-panel {
  background: #fbfcfd;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.score-metrics-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 16px;
}

.metric-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.metric-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.metric-hero-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}

.value-number {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--color-black);
}

.value-threshold {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--text-secondary);
}

.value-raw {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.metric-divider {
  width: 1px;
  height: 40px;
  background: var(--border-color);
}

@media (max-width: 640px) {
  .metric-divider {
    display: none;
  }
}

.confidence-pill {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  align-self: center;
}

.confidence-pill.high {
  background: var(--success-bg);
  color: var(--success-color);
  border-color: var(--success-border);
}

.confidence-pill.valid {
  background: #f8fafc;
  color: var(--text-primary);
  border-color: #cbd5e1;
}

.confidence-pill.reject {
  background: var(--danger-bg);
  color: var(--danger-color);
  border-color: var(--danger-border);
}

/* Similarity Meter Bar */
.similarity-meter-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.threshold-marker-label {
  color: var(--text-primary);
  font-weight: 600;
}

.meter-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: var(--radius-full);
  position: relative;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  background: var(--color-black);
  transition: width 500ms ease;
}

.meter-fill.fail {
  background: var(--danger-color);
}

.meter-threshold-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #000000;
  z-index: 2;
  transform: translateX(-50%);
}

/* Comparison Face Crops */
.comparison-faces-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}

.face-crop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.crop-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.crop-avatar-box {
  width: 100px;
  height: 100px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #f8fafc;
  overflow: hidden;
}

.crop-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.crop-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.vs-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-actions {
  display: flex;
  justify-content: center;
  padding-top: 4px;
}