/* =============================================================================
   profile.css — Phase 9: Profile & Settings
   Zap Design System
   Profile page: avatar, stats, edit name, quick links.
   ============================================================================= */


/* ─── PAGE LAYOUT ────────────────────────────────────────────────────────────── */

.profile-page {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) var(--space-2xl);
}


/* ─── AVATAR SECTION ──────────────────────────────────────────────────────────── */

.profile-avatar-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xl) 0 var(--space-lg);
}

.profile-avatar-wrap {
  position: relative;
  width: 88px;
  height: 88px;
  flex-shrink: 0;
}

.profile-avatar {
  width: 88px;
  height: 88px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--border-soft);
  display: block;
  background: var(--bg-elevated);
}

.profile-avatar-placeholder {
  width: 88px;
  height: 88px;
  border-radius: var(--radius-full);
  background: var(--bg-elevated);
  border: 2px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-avatar-placeholder img {
  width: 40px;
  height: 40px;
  display: block;
  filter: brightness(0) invert(0.35);
}

.profile-avatar-upload-btn {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.profile-avatar-upload-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-active);
}

.profile-avatar-upload-btn img {
  width: 14px;
  height: 14px;
  display: block;
  filter: brightness(0) invert(0.7);
  pointer-events: none;
}

/* Upload loading overlay */
.profile-avatar-wrap.uploading .profile-avatar,
.profile-avatar-wrap.uploading .profile-avatar-placeholder {
  opacity: 0.45;
}

.profile-avatar-upload-spinner {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}

.profile-avatar-wrap.uploading .profile-avatar-upload-spinner {
  display: flex;
}

.profile-avatar-upload-spinner img {
  width: 24px;
  height: 24px;
  display: block;
  filter: brightness(0) invert(0.9);
  animation: profile-spin 0.9s linear infinite;
}

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

/* Hidden file input */
.profile-avatar-input {
  display: none;
}

/* Name + tag */
.profile-identity {
  text-align: center;
}

.profile-name {
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  letter-spacing: -0.3px;
  margin-bottom: 4px;
}

.profile-email {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.profile-badges {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.profile-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border: 1px solid;
}

.profile-badge img {
  width: 11px;
  height: 11px;
  display: block;
}

.profile-badge.premium {
  color: #D97706;
  border-color: rgba(217, 119, 6, 0.3);
  background: rgba(217, 119, 6, 0.06);
}

.profile-badge.premium img {
  filter: brightness(0) saturate(1) invert(0.5) sepia(1) saturate(4) hue-rotate(5deg);
}

.profile-badge.verified {
  color: var(--success);
  border-color: rgba(22, 163, 74, 0.3);
  background: rgba(22, 163, 74, 0.06);
}

.profile-badge.verified img {
  filter: brightness(0) saturate(1) invert(0.4) sepia(1) saturate(3) hue-rotate(90deg);
}

.profile-badge.agent {
  color: #2563EB;
  border-color: rgba(37, 99, 235, 0.3);
  background: rgba(37, 99, 235, 0.06);
}

.profile-badge.agent img {
  filter: brightness(0) saturate(1) invert(0.4) sepia(1) saturate(5) hue-rotate(200deg);
}


/* ─── STATS ROW ──────────────────────────────────────────────────────────────── */

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-lg);
}

.profile-stat {
  background: var(--bg-card);
  padding: 16px 12px;
  text-align: center;
}

.profile-stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.profile-stat-value.green {
  color: var(--success);
}

.profile-stat-label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-muted);
}


/* ─── INFO CARD ──────────────────────────────────────────────────────────────── */

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-md);
}

.profile-card-title {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--font-semi);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

/* ── Row ── */
.profile-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.profile-row:last-child {
  border-bottom: none;
}

.profile-row-left {
  flex: 1;
  min-width: 0;
}

.profile-row-label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 3px;
}

.profile-row-value {
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-row-value.mono {
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}

.profile-row-value.muted {
  color: var(--text-muted);
}

/* Action button inside row */
.profile-row-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: none;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.profile-row-action:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-active);
}

.profile-row-action img {
  width: 13px;
  height: 13px;
  display: block;
  filter: brightness(0) invert(0.5);
  pointer-events: none;
  transition: filter 0.15s;
}

.profile-row-action:hover img {
  filter: brightness(0) invert(0.85);
}

/* Inline edit for display name */
.profile-name-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border-active);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
  min-width: 0;
}

.profile-name-input:focus {
  border-color: var(--text-muted);
}

.profile-name-save-btn {
  padding: 7px 14px;
  background: var(--text-primary);
  color: var(--bg-base);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--font-semi);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.profile-name-save-btn:hover {
  opacity: 0.82;
}

.profile-name-save-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}


/* ─── REFERRAL CARD ──────────────────────────────────────────────────────────── */

.referral-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: var(--space-md);
}

.referral-label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: var(--font-semi);
}

.referral-code-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.referral-code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  letter-spacing: 1.5px;
  min-width: 0;
}

.referral-copy-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.referral-copy-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-active);
}

.referral-copy-btn img {
  width: 13px;
  height: 13px;
  display: block;
  filter: brightness(0) invert(0.5);
  pointer-events: none;
}

.referral-copy-btn.copied {
  color: var(--success);
  border-color: rgba(22, 163, 74, 0.3);
}

.referral-copy-btn.copied img {
  filter: brightness(0) saturate(1) invert(0.4) sepia(1) saturate(3) hue-rotate(90deg);
}

.referral-hint {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 10px;
  line-height: 1.5;
}


/* ─── LOGOUT BUTTON ──────────────────────────────────────────────────────────── */

.profile-logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px;
  background: none;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--danger);
  cursor: pointer;
  margin-top: var(--space-lg);
  transition: background 0.15s, border-color 0.15s;
}

.profile-logout-btn:hover {
  background: rgba(220, 38, 38, 0.05);
  border-color: rgba(220, 38, 38, 0.25);
}

.profile-logout-btn img {
  width: 16px;
  height: 16px;
  display: block;
  filter: brightness(0) saturate(1) invert(0.4) sepia(1) saturate(5) hue-rotate(310deg);
  pointer-events: none;
}


/* ─── RESPONSIVE ─────────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  .profile-stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .profile-stat-value {
    font-size: var(--text-base);
  }
}
