/* ============================================================
   Ourtennis 论坛 - 用户菜单卡片 + 个人资料编辑弹窗 + 头像裁剪
   z-index 层级（与 CLAUDE.md §9 论坛 SPA 层级表对齐）：
     .f-user-menu              11500  （高于 compose 11000，低于 login 12000、toast 13000、confirm 13500）
     .f-profile-overlay        11000  （与 compose 同层，互斥不并存）
     .f-pm-cropper-overlay     13700  （高于 confirm 13500，低于 lightbox 13800；裁剪期间需挡住所有）
   ============================================================ */

/* ===== 用户菜单卡片（桌面 popover） ===== */
.f-user-menu-catcher {
  position: fixed; inset: 0; z-index: 11499; background: transparent;
}
.f-user-menu {
  position: fixed; z-index: 11500;
  min-width: 240px; max-width: 280px;
  background: var(--f-bg-elevated);
  border: 1px solid var(--f-border);
  border-radius: var(--f-radius-lg);
  box-shadow: var(--f-shadow-pop);
  overflow: hidden;
  animation: f-um-pop .14s ease-out;
  transform-origin: top right;
}
@keyframes f-um-pop {
  from { opacity: 0; transform: scale(.96) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.f-um-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--f-primary-tint) 0%, var(--f-bg-soft) 100%);
  border-bottom: 1px solid var(--f-divider);
}
.f-um-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: linear-gradient(135deg, var(--f-primary), var(--f-primary-soft)) center/cover no-repeat;
  flex: 0 0 auto;
  border: 2px solid #fff;
  box-shadow: var(--f-shadow-blue);
}
.f-um-meta {
  flex: 1 1 auto; min-width: 0;
}
.f-um-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.f-um-name {
  font-size: 14px; font-weight: 700; color: var(--f-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0;
}
.f-um-role-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  max-width: 116px;
  padding: 2px 8px;
  border-radius: var(--f-radius-pill);
  border: 1px solid rgba(31, 58, 104, .14);
  background: rgba(255,255,255,.74);
  color: var(--f-text-soft);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.f-um-role-badge--admin {
  gap: 5px;
  padding-left: 4px;
  color: var(--f-primary);
  box-shadow: 0 3px 10px rgba(15, 30, 61, .08);
}
.f-um-role-badge--admin::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: 0 0 auto;
  background:
    radial-gradient(ellipse 82% 58% at 50% -18%, transparent 58%, rgba(255,255,255,.92) 60% 66%, transparent 68%),
    radial-gradient(ellipse 82% 58% at 50% 118%, transparent 58%, rgba(255,255,255,.86) 60% 66%, transparent 68%),
    radial-gradient(circle at 34% 28%, #f8ff9a 0 14%, var(--f-tennis) 15% 58%, var(--f-tennis-deep) 100%);
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 3px rgba(31, 58, 104, .18),
    inset 0 -1px 1px rgba(15,30,61,.16);
}
.f-um-sub {
  font-size: 11px; color: var(--f-text-muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.f-um-list {
  list-style: none; margin: 0; padding: 6px 0;
}
.f-um-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  font-size: 13px; color: var(--f-text); font-weight: 500;
  cursor: pointer;
  border: 0; background: transparent; width: 100%; text-align: left;
  transition: background .12s;
}
.f-um-item:hover { background: var(--f-bg-soft); }
.f-um-item:active { background: var(--f-primary-tint); }
.f-um-item-icon {
  flex: 0 0 18px; width: 18px; height: 18px;
  color: var(--f-text-muted); display: inline-flex; align-items: center; justify-content: center;
}
.f-um-item-label { flex: 1; }
.f-um-item-hint {
  font-size: 10px; color: var(--f-text-faint);
  padding: 2px 6px; border-radius: var(--f-radius-xs);
  background: var(--f-bg-soft);
}
.f-um-divider {
  height: 1px; background: var(--f-divider); margin: 4px 0;
}
.f-um-item--danger { color: var(--f-danger); }
.f-um-item--danger .f-um-item-icon { color: var(--f-danger); }
.f-um-item--danger:hover { background: rgba(201, 48, 61, .08); }

/* 窄屏：菜单改为 bottom-sheet 形态 */
@media (max-width: 768px) {
  .f-user-menu {
    position: fixed !important;
    left: 0 !important; right: 0 !important; bottom: 0 !important;
    top: auto !important;
    max-width: 100%; min-width: 0; width: 100%;
    border-radius: 14px 14px 0 0;
    animation: f-um-slide-up .18s ease-out;
    transform-origin: bottom center;
    padding-bottom: env(safe-area-inset-bottom);
  }
  @keyframes f-um-slide-up {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .f-um-header { padding: 18px 20px; }
  .f-um-role-badge { max-width: 148px; font-size: 11px; }
  .f-um-item { padding: 14px 20px; font-size: 15px; }
}

/* ===== 个人资料编辑弹窗 ===== */
.f-profile-overlay {
  position: fixed; inset: 0; z-index: 11000;
  background: rgba(15, 30, 61, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: f-pm-fade .15s ease-out;
}
@keyframes f-pm-fade { from { opacity: 0; } to { opacity: 1; } }
.f-profile-modal {
  background: var(--f-bg-elevated);
  border-radius: var(--f-radius-lg);
  width: 100%; max-width: 560px;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  box-shadow: var(--f-shadow-pop);
  animation: f-pm-pop .18s ease-out;
}
@keyframes f-pm-pop {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.f-pm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--f-divider);
}
.f-pm-title {
  font-size: 17px; font-weight: 700; color: var(--f-text); margin: 0;
  letter-spacing: -0.01em;
}
.f-pm-close {
  border: 0; background: transparent; cursor: pointer;
  width: 32px; height: 32px; border-radius: var(--f-radius-xs);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--f-text-muted); font-size: 20px; line-height: 1;
  transition: all .12s;
}
.f-pm-close:hover { background: var(--f-bg-soft); color: var(--f-text); }
.f-pm-body {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1 1 auto;
}

/* 头像区 */
.f-pm-avatar-section {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px;
  background: var(--f-bg-soft);
  border-radius: var(--f-radius);
  margin-bottom: 18px;
}
.f-pm-avatar-preview {
  width: 72px; height: 72px; border-radius: 50%;
  background: linear-gradient(135deg, var(--f-primary), var(--f-primary-soft)) center/cover no-repeat;
  border: 3px solid #fff;
  box-shadow: var(--f-shadow-blue);
  flex: 0 0 auto;
}
.f-pm-avatar-actions {
  flex: 1; display: flex; flex-direction: column; gap: 6px;
}
.f-pm-avatar-tip {
  font-size: 11px; color: var(--f-text-muted);
}
.f-pm-avatar-btn {
  align-self: flex-start;
  padding: 7px 14px; border-radius: var(--f-radius-pill);
  border: 1px solid var(--f-border); background: #fff;
  font-size: 12px; font-weight: 600; color: var(--f-primary);
  cursor: pointer; transition: all .15s;
}
.f-pm-avatar-btn:hover {
  border-color: var(--f-primary); background: var(--f-primary-tint);
}
.f-pm-avatar-btn:disabled { opacity: .55; cursor: not-allowed; }

/* 表单 */
.f-pm-form { display: flex; flex-direction: column; gap: 14px; }
.f-pm-row { display: flex; flex-direction: column; gap: 6px; }
.f-pm-row--inline { flex-direction: row; gap: 12px; }
.f-pm-row--inline > .f-pm-field { flex: 1; }
.f-pm-field { display: flex; flex-direction: column; gap: 6px; }
.f-pm-label {
  font-size: 12px; font-weight: 600; color: var(--f-text-soft);
}
.f-pm-label-req::after {
  content: ' *'; color: var(--f-danger);
}
.f-pm-input, .f-pm-select, .f-pm-textarea {
  width: 100%; box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid var(--f-border);
  border-radius: var(--f-radius);
  background: #fff;
  font-size: 14px; color: var(--f-text);
  font-family: var(--f-font-sans);
  transition: border-color .15s, box-shadow .15s;
}
.f-pm-input:focus, .f-pm-select:focus, .f-pm-textarea:focus {
  outline: none;
  border-color: var(--f-primary);
  box-shadow: 0 0 0 3px var(--f-primary-tint);
}
.f-pm-input:disabled, .f-pm-select:disabled {
  background: var(--f-bg-soft); color: var(--f-text-muted); cursor: not-allowed;
}
.f-pm-textarea { resize: vertical; min-height: 72px; }
.f-pm-helper {
  font-size: 11px; color: var(--f-text-muted);
}

/* 国家 combobox（输入 + 搜索下拉 + 键盘） */
.f-pm-combobox { position: relative; }
.f-pm-combobox-input { padding-right: 32px; cursor: text; }
.f-pm-combobox-caret {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--f-text-muted); font-size: 12px;
  pointer-events: auto; cursor: pointer;
  user-select: none;
}
.f-pm-combobox-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  z-index: 11100;                /* 高于 modal 11000，低于 cropper 13700 */
  max-height: 280px; overflow-y: auto;
  background: #fff;
  border: 1px solid var(--f-border);
  border-radius: var(--f-radius);
  box-shadow: 0 6px 18px rgba(0,0,0,.12);
}
.f-pm-combobox-item {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 14px;
}
.f-pm-combobox-item:hover,
.f-pm-combobox-item.is-active {
  background: var(--f-primary-tint);
}
.f-pm-combobox-item-zh { color: var(--f-text); flex: 1; min-width: 0; }
.f-pm-combobox-item-en { color: var(--f-text-muted); font-size: 12px; }
.f-pm-combobox-empty {
  padding: 14px; text-align: center; color: var(--f-text-muted); font-size: 13px;
}

/* chip 组（性别/惯用手） */
.f-pm-chips {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.f-pm-chip {
  padding: 7px 14px; border-radius: var(--f-radius-pill);
  border: 1px solid var(--f-border); background: #fff;
  font-size: 13px; font-weight: 500; color: var(--f-text-soft);
  cursor: pointer; transition: all .15s;
}
.f-pm-chip:hover { border-color: var(--f-primary-soft); }
.f-pm-chip.active {
  border-color: var(--f-primary); background: var(--f-primary);
  color: #fff; font-weight: 600;
}

/* footer */
.f-pm-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 22px;
  border-top: 1px solid var(--f-divider);
  background: var(--f-bg-soft);
  border-radius: 0 0 var(--f-radius-lg) var(--f-radius-lg);
}
.f-pm-btn {
  padding: 9px 20px; border-radius: var(--f-radius-pill);
  border: 1px solid transparent;
  font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.f-pm-btn-cancel {
  background: #fff; color: var(--f-text-soft); border-color: var(--f-border);
}
.f-pm-btn-cancel:hover { border-color: var(--f-border-strong); }
.f-pm-btn-primary {
  background: var(--f-primary); color: #fff;
  box-shadow: var(--f-shadow-blue);
}
.f-pm-btn-primary:hover { background: var(--f-primary-soft); transform: translateY(-1px); }
.f-pm-btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* 窄屏：弹窗全屏化（参照 compose） */
@media (max-width: 768px) {
  .f-profile-overlay { padding: 0; align-items: stretch; }
  .f-profile-modal {
    max-width: 100%; max-height: 100vh; height: 100vh;
    border-radius: 0;
  }
  .f-pm-footer { border-radius: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .f-pm-row--inline { flex-direction: column; gap: 14px; }
}

/* ===== 头像裁剪 overlay（Cropper.js） ===== */
.f-pm-cropper-overlay {
  position: fixed; inset: 0; z-index: 13700;
  background: rgba(15, 30, 61, .82);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.f-pm-cropper-card {
  background: var(--f-bg-elevated);
  border-radius: var(--f-radius-lg);
  width: 100%; max-width: 480px;
  display: flex; flex-direction: column;
  box-shadow: var(--f-shadow-pop);
  overflow: hidden;
}
.f-pm-cropper-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--f-divider);
  font-size: 15px; font-weight: 700; color: var(--f-text);
}
.f-pm-cropper-stage {
  position: relative;
  width: 100%; height: 360px;
  background: #000;
  overflow: hidden;
}
.f-pm-cropper-stage img {
  max-width: 100%;
  display: block;
}
.f-pm-cropper-zoom {
  display: flex; justify-content: center; gap: 8px;
  padding: 10px;
  background: var(--f-bg-soft);
}
.f-pm-cropper-zoom button {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--f-border); background: #fff;
  font-size: 18px; font-weight: 700; color: var(--f-primary);
  cursor: pointer;
}
.f-pm-cropper-zoom button:hover { background: var(--f-primary-tint); }
.f-pm-cropper-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--f-divider);
}
@media (max-width: 768px) {
  .f-pm-cropper-overlay { padding: 0; }
  .f-pm-cropper-card { max-width: 100%; height: 100vh; border-radius: 0; }
  .f-pm-cropper-stage { flex: 1; height: auto; }
  .f-pm-cropper-footer { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
