/* ═══════════════════════════════════════════════════════════
   Friends Modal — ported from V2
   ═══════════════════════════════════════════════════════════ */

/* Overlay */
.fr-overlay {
  position: fixed; inset: 0;
  z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Modal card */
.fr-modal {
  background: var(--surface, #13161c);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 94vw; max-width: 420px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

/* Header */
.fr-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.fr-header h2 {
  margin: 0; font-size: 18px; font-weight: 600;
  color: var(--text);
}
.fr-close {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 4px; line-height: 0;
}
.fr-close:hover { color: var(--text); }

/* Tab bar */
.fr-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  padding: 0 12px;
}
.fr-tab-btn {
  flex: 1;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 10px 8px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.fr-tab-btn:hover { color: var(--text); }
.fr-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Tab panels */
.fr-tab-panel {
  display: none;
  overflow-y: auto;
  padding: 12px 16px 16px;
  flex: 1;
}
.fr-tab-panel.active { display: block; }

/* Friend / request rows */
.fr-friend-row, .fr-request-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}
.fr-friend-row:last-child, .fr-request-row:last-child { border-bottom: none; }

.fr-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden;
  font-size: 13px; font-weight: 600;
  color: var(--text);
}
.fr-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}

.fr-friend-name {
  flex: 1; font-size: 14px;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Buttons */
.fr-btn {
  border: none; border-radius: 8px; padding: 6px 12px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: opacity .15s;
}
.fr-btn:hover { opacity: .85; }
.fr-btn:disabled { opacity: .5; cursor: default; }

.fr-btn-accept { background: var(--accent); color: var(--bg); }
.fr-btn-decline { background: var(--surface2); color: var(--muted); }
.fr-btn-add { background: var(--accent); color: var(--bg); }
.fr-btn-sent { background: var(--surface2); color: var(--muted); }

.fr-btn-icon {
  background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 4px; line-height: 0; border-radius: 6px;
}
.fr-btn-icon:hover { color: #ef4444; background: rgba(239,68,68,.1); }

.fr-request-actions { display: flex; gap: 6px; flex-shrink: 0; }

.fr-badge {
  font-size: 11px; font-weight: 600; color: var(--accent);
  background: rgba(124,156,255,.1); padding: 4px 10px; border-radius: 6px;
}

/* Search */
.fr-search-wrap {
  position: relative; margin-bottom: 12px;
}
.fr-search-wrap input {
  width: 100%; box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.fr-search-wrap input::placeholder { color: var(--muted); }
.fr-search-wrap input:focus { border-color: var(--accent); }

/* Friend code / link section */
.fr-link-section {
  margin-top: 16px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.fr-link-section h4 {
  margin: 0 0 4px; font-size: 13px; font-weight: 600;
  color: var(--text);
}
.fr-link-section p {
  margin: 0 0 8px; font-size: 12px; color: var(--muted);
}
.fr-code-display {
  font-family: monospace; font-size: 18px; font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px; margin-bottom: 8px;
}
.fr-link-row {
  display: flex; gap: 6px;
}
.fr-link-row input {
  flex: 1; box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 12px; outline: none;
}
.fr-link-row button {
  background: var(--accent); color: var(--bg);
  border: none; border-radius: 8px; padding: 8px 14px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.fr-link-row button:hover { opacity: .85; }

/* Privacy toggle */
.fr-privacy {
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.fr-privacy h4 {
  margin: 0 0 8px; font-size: 13px; font-weight: 600;
  color: var(--text);
}
.fr-radio-group {
  display: flex; flex-direction: column; gap: 6px;
}
.fr-radio-group label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text);
  cursor: pointer;
}
.fr-radio-group input[type="radio"] {
  accent-color: var(--accent);
}

/* Empty / loading states */
.fr-empty, .fr-loading {
  text-align: center; padding: 24px 8px;
  color: var(--muted); font-size: 14px;
}
.fr-empty p { margin: 4px 0; }
.fr-muted { font-size: 12px; color: var(--muted); }

/* ═══════════════════════════════════════════════════════════
   Contacts Import — Find Friends from Contacts card + results
   ═══════════════════════════════════════════════════════════ */

/* Entry card */
.fr-contacts-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(124,156,255,.08), rgba(255,107,157,.06));
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm, 10px);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.fr-contacts-card:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(124,156,255,.12), rgba(255,107,157,.10));
}
.fr-contacts-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--accent-dim, rgba(255,107,157,.15));
  color: var(--accent);
  flex-shrink: 0;
}
.fr-contacts-text {
  flex: 1; min-width: 0;
}
.fr-contacts-text h4 {
  margin: 0; font-size: 14px; font-weight: 600;
  color: var(--text);
}
.fr-contacts-text p {
  margin: 2px 0 0; font-size: 12px;
  color: var(--muted);
}
.fr-contacts-btn {
  background: none; border: none;
  color: var(--muted);
  cursor: pointer; padding: 4px;
  line-height: 0; flex-shrink: 0;
  transition: color .15s;
}
.fr-contacts-card:hover .fr-contacts-btn { color: var(--accent); }

/* Consent screen */
.fr-contacts-consent {
  text-align: center;
  padding: 16px 8px;
  margin-bottom: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 10px);
}
.fr-contacts-consent-icon {
  width: 36px; height: 36px;
  margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(74,222,128,.1);
  color: var(--success, #4ade80);
}
.fr-contacts-consent p {
  margin: 0 0 14px;
  font-size: 12px; line-height: 1.5;
  color: var(--muted);
}
.fr-btn-accent {
  background: var(--accent); color: var(--bg);
  border: none; border-radius: 20px;
  padding: 10px 24px;
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.fr-btn-accent:hover { opacity: .85; }

/* Results sections */
.fr-contacts-results {
  /* Container for matched + unmatched lists */
}
.fr-contacts-section {
  margin-bottom: 12px;
}
.fr-contacts-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 0 0 6px;
  padding: 0 4px;
}

/* Muted avatar for non-matched contacts */
.fr-avatar-muted {
  background: var(--surface3, #222d42);
  color: var(--muted);
}
.fr-name-muted {
  color: var(--text-dim, #c8cdd8);
}

/* Invite button */
.fr-btn-invite {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.fr-btn-invite:hover {
  background: var(--accent);
  color: var(--bg);
}

/* Share button (native share fallback) */
.fr-btn-share {
  display: block;
  width: 100%;
  margin-top: 10px;
  background: var(--accent);
  color: var(--bg);
  border-radius: 10px;
  padding: 10px;
  font-size: 13px; font-weight: 600;
}

/* Desktop fallback card */
.fr-contacts-fallback {
  padding: 14px 16px;
  margin-bottom: 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 10px);
}
.fr-contacts-fallback-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 6px;
  color: var(--accent);
}
.fr-contacts-fallback-header h4 {
  margin: 0; font-size: 14px; font-weight: 600;
  color: var(--text);
}

/* ═══════════════════════════════════════════════════════════
   QR Scanner — camera overlay + celebration canvas
   ═══════════════════════════════════════════════════════════ */

/* Scanner entry card (in Find Friends tab) */
.fr-qr-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, rgba(196,113,237,.1), rgba(255,179,71,.06));
  border: 1px solid rgba(196,113,237,.2);
  border-radius: var(--radius-sm, 10px);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.fr-qr-card:hover {
  border-color: rgba(196,113,237,.4);
  background: linear-gradient(135deg, rgba(196,113,237,.15), rgba(255,179,71,.10));
}
.fr-qr-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(196,113,237,.15);
  color: #c471ed;
  flex-shrink: 0;
}
.fr-qr-text {
  flex: 1; min-width: 0;
}
.fr-qr-text h4 {
  margin: 0; font-size: 14px; font-weight: 600;
  color: var(--text);
}
.fr-qr-text p {
  margin: 2px 0 0; font-size: 12px;
  color: var(--muted);
}
.fr-qr-arrow {
  background: none; border: none;
  color: var(--muted);
  cursor: pointer; padding: 4px;
  line-height: 0; flex-shrink: 0;
  transition: color .15s;
}
.fr-qr-card:hover .fr-qr-arrow { color: #c471ed; }

/* QR code display (your code) */
.fr-qr-display {
  text-align: center;
  padding: 16px;
  margin: 12px 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.fr-qr-display-code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #ffb347, #ff6b9d, #c471ed);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}
.fr-qr-display-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}

/* ─── Scanner overlay (fullscreen) ──────────────────────── */
.qr-overlay {
  position: fixed; inset: 0;
  z-index: 9500;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: qrFadeIn .25s ease;
}
@keyframes qrFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.qr-scanner-wrap {
  background: var(--surface, #13161c);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 92vw; max-width: 380px;
  padding: 20px;
  box-shadow: 0 12px 48px rgba(0,0,0,.5), 0 0 80px rgba(196,113,237,.08);
  animation: qrSlideUp .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes qrSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.qr-scanner-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.qr-scanner-header h3 {
  margin: 0; font-size: 17px; font-weight: 700;
  color: var(--text);
}
.qr-close-btn {
  background: none; border: none;
  color: var(--muted); cursor: pointer;
  padding: 4px; line-height: 0;
  border-radius: 8px;
  transition: color .15s, background .15s;
}
.qr-close-btn:hover {
  color: var(--text);
  background: var(--surface2);
}

/* Viewfinder */
.qr-viewfinder {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  background: #000;
}
.qr-viewfinder video {
  width: 100%; height: 100%;
  object-fit: cover;
}

/* Corner brackets */
.qr-corners {
  position: absolute; inset: 0;
  pointer-events: none;
}
.qr-corner {
  position: absolute;
  width: 28px; height: 28px;
  border: 3px solid rgba(196,113,237,.7);
}
.qr-tl { top: 16px; left: 16px; border-right: none; border-bottom: none; border-radius: 4px 0 0 0; }
.qr-tr { top: 16px; right: 16px; border-left: none; border-bottom: none; border-radius: 0 4px 0 0; }
.qr-bl { bottom: 16px; left: 16px; border-right: none; border-top: none; border-radius: 0 0 0 4px; }
.qr-br { bottom: 16px; right: 16px; border-left: none; border-top: none; border-radius: 0 0 4px 0; }

/* Scan line animation */
.qr-scan-line {
  position: absolute;
  left: 20px; right: 20px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #c471ed, #ff6b9d, #c471ed, transparent);
  box-shadow: 0 0 12px rgba(196,113,237,.4), 0 0 24px rgba(196,113,237,.15);
  animation: qrScanLine 2.5s ease-in-out infinite;
  border-radius: 2px;
}
@keyframes qrScanLine {
  0%   { top: 20px; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: calc(100% - 20px); opacity: 0; }
}

/* Status text */
.qr-status {
  position: absolute;
  bottom: 12px; left: 0; right: 0;
  text-align: center;
  font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,.6);
  text-shadow: 0 1px 4px rgba(0,0,0,.5);
}
.qr-status.scanning { color: rgba(196,113,237,.9); }
.qr-status.error { color: rgba(248,113,113,.8); }

/* Hint text */
.qr-hint {
  text-align: center;
  font-size: 13px; color: var(--muted);
  margin: 14px 0 8px;
}

/* Manual code entry */
.qr-manual-section {
  margin-top: 4px;
}
.qr-or {
  text-align: center;
  font-size: 11px; color: var(--muted);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.qr-code-input-row {
  display: flex; gap: 8px;
}
.qr-code-input-row input {
  flex: 1; box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  letter-spacing: 1px;
  outline: none;
  transition: border-color .15s;
}
.qr-code-input-row input::placeholder { color: var(--muted); font-family: var(--font); letter-spacing: 0; }
.qr-code-input-row input:focus { border-color: #c471ed; }
.qr-submit-btn {
  background: linear-gradient(135deg, #c471ed, #ff6b9d);
  color: #fff; border: none;
  border-radius: 10px; padding: 10px 20px;
  font-size: 14px; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  transition: opacity .15s, transform .1s;
}
.qr-submit-btn:hover { opacity: .9; }
.qr-submit-btn:active { transform: scale(.97); }

/* ─── Celebration canvas ──────────────────────────────── */
.qr-celebration-canvas {
  position: fixed; inset: 0;
  z-index: 9800;
  pointer-events: none;
}

/* ─── Friend added card (celebration result) ─────────── */
.qr-friend-card-wrap {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  z-index: 9850;
  opacity: 0;
  transition: all .5s cubic-bezier(.34, 1.56, .64, 1);
  pointer-events: none;
}
.qr-friend-card-wrap.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.qr-friend-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 32px;
  text-align: center;
  min-width: 260px;
  box-shadow: 0 8px 40px rgba(0,0,0,.4), 0 0 60px rgba(196,113,237,.12);
}
.qr-friend-avatars {
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.qr-friend-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  border: 3px solid var(--bg);
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  color: var(--text);
  overflow: hidden;
}
.qr-friend-avatar:nth-child(2) { margin-left: -14px; }
.qr-friend-avatar img { width: 100%; height: 100%; object-fit: cover; }
.qr-friend-check {
  position: absolute; bottom: -3px; right: -3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: linear-gradient(135deg, #ffb347, #ff6b9d);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}
.qr-friend-card h3 {
  font-size: 17px; font-weight: 700; margin: 0 0 4px;
  color: var(--text);
}
.qr-friend-card h3 span {
  background: linear-gradient(135deg, #ffb347, #ff6b9d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.qr-friend-card p {
  font-size: 13px; color: var(--muted); margin: 0 0 16px;
}
.qr-friend-dismiss {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 20px;
  font-size: 13px; font-weight: 600;
  color: var(--text); cursor: pointer;
  transition: background .15s;
}
.qr-friend-dismiss:hover { background: var(--border); }
