/* Mobile Face Training — FR-E2 */

.mft-overlay {
  position: fixed;
  inset: 0;
  /* Reserve room for tab-bar (z 11000 sits above this z 10300).
     See mobile-tab-bar.css → "UNIVERSAL MOBILE-MODAL BOTTOM RESERVATION". */
  padding-bottom: var(--mobile-control-panel-height, 56px);
  /* Primary mobile modal tier (per Z_INDEX_HIERARCHY.md). Was 120000 — that
     wildly violated the hierarchy and trapped UMI (10400) underneath when
     opening media from Confirmed Faces. UMI now correctly overlays this. */
  z-index: 10300;
  background: #0d1f1f;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.mft-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  background: #111d1d;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mft-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.mft-title {
  flex: 1;
  font-family: 'Inter', sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mft-badge {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  background: #2a7575;
  color: #fff;
  border-radius: 10px;
  padding: 3px 9px;
}

/* Body */
.mft-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}

/* Mode selector screen */
.mft-mode-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  gap: 20px;
}

.mft-avatar-large {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(42, 117, 117, 0.5);
}

.mft-avatar-initials-large {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #2a7575;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 32px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(42, 117, 117, 0.5);
}

.mft-person-name {
  font-family: 'Playfair Display', serif;
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  text-align: center;
  margin: 0;
}

.mft-instructions {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  margin: 0;
  line-height: 1.5;
  max-width: 280px;
}

.mft-mode-btns {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.mft-mode-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  color: #fff;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.mft-mode-btn:active {
  background: rgba(42, 117, 117, 0.25);
  border-color: #2a7575;
}

.mft-mode-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #2a7575;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.mft-mode-label {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 2px;
}

.mft-mode-desc {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  margin: 0;
}

/* Camera screen */
.mft-camera-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #000;
}

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

.mft-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror for selfie */
}

.mft-face-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 220px;
  height: 280px;
  border: 3px solid rgba(42, 117, 117, 0.8);
  border-radius: 50%;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.4);
}

.mft-camera-hint {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
  pointer-events: none;
}

.mft-camera-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 32px calc(env(safe-area-inset-bottom, 0px) + 24px);
  background: #000;
  gap: 40px;
}

.mft-capture-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.15);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s;
}

.mft-capture-btn:active {
  transform: scale(0.92);
}

.mft-camera-cancel {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  color: #fff;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Preview screen */
.mft-preview-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px;
  gap: 20px;
}

.mft-preview-img {
  width: 220px;
  height: 280px;
  object-fit: cover;
  border-radius: 16px;
  border: 2px solid rgba(42, 117, 117, 0.4);
}

.mft-preview-hint {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  margin: 0;
}

.mft-preview-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

.mft-submit-btn {
  width: 100%;
  padding: 16px;
  background: #2a7575;
  border: none;
  border-radius: 12px;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}

.mft-submit-btn:active {
  background: #1a5555;
}

.mft-submit-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.mft-retake-btn {
  width: 100%;
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* Result screen */
.mft-result-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  gap: 16px;
}

.mft-result-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.mft-result-icon.success { background: rgba(16, 185, 129, 0.15); }
.mft-result-icon.error { background: rgba(239, 68, 68, 0.15); }

.mft-result-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-align: center;
  margin: 0;
}

.mft-result-detail {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  margin: 0;
  line-height: 1.5;
}

.mft-quality-bar {
  width: 100%;
  max-width: 280px;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
}

.mft-quality-fill {
  height: 100%;
  border-radius: 4px;
  background: #10b981;
  transition: width 0.6s ease;
}

.mft-quality-label {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
}

.mft-result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 280px;
}

/* Loading state */
.mft-loading {
  position: absolute;
  inset: 0;
  background: rgba(13, 31, 31, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 10;
}

.mft-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #2a7575;
  border-radius: 50%;
  animation: mft-spin 0.8s linear infinite;
}

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

.mft-loading-text {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

/* Hidden file input */
.mft-file-input {
  position: absolute;
  left: -9999px;
  opacity: 0;
}

/* ── Tabs (training mode: Add Photo / Tagged Faces) ──────────────────── */
.mft-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 16px 0;
  background: #1a1d2b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mft-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 8px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.mft-tab.active {
  color: #fff;
  border-bottom-color: #6c9ef8;
}

.mft-tab:focus-visible {
  outline: 2px solid #6c9ef8;
  outline-offset: -4px;
}

/* ── Tagged Faces screen (scrolls inside .mft-body) ──────────────────── */
.mft-tagged-screen {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.mft-tagged-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 12px 16px 6px;
  font-family: 'Inter', sans-serif;
}

.mft-tagged-count {
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.mft-tagged-hint {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
}

.mft-tagged-grid {
  padding: 8px 12px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  align-content: start;
}

.mft-tagged-loading,
.mft-tagged-empty {
  grid-column: 1 / -1;
  padding: 28px 16px;
  text-align: center;
  color: rgba(255, 255, 255, 0.65);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.mft-face-tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border: none;
  padding: 0;
  background: #23273a;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.mft-face-tile:active {
  transform: scale(0.96);
}

.mft-face-tile:focus-visible {
  outline: 2px solid #6c9ef8;
  outline-offset: 2px;
}

.mft-face-tile-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.mft-face-tile-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 4px 6px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.75), transparent);
  text-align: center;
  pointer-events: none;
}

.mft-tagged-footer {
  padding: 0 12px 16px;
}

.mft-load-more {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.mft-load-more:active {
  background: rgba(255, 255, 255, 0.12);
}
