/* 个人资料 sheet - 美化版：保存在下、修改密码在右下角，符合常见互联网操作习惯 */

/* ---- 遮罩 ---- */
.profile-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

/* ---- 主 sheet 容器 ---- */
.profile-sheet {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.97);
  width: min(92vw, 380px);
  background: var(--color-bg-white);
  border-radius: 16px;
  border: 1px solid var(--color-border-light);
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 1001;
}

body.stats-profile-modal-open .profile-sheet-overlay {
  opacity: 1;
  pointer-events: auto;
}

body.stats-profile-modal-open .profile-sheet {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

/* ---- 头部 ---- */
.profile-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-bg-white);
}

.profile-sheet-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
}

.profile-sheet-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--color-border-light);
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.profile-sheet-close:hover {
  background: var(--color-bg-white);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.profile-sheet-close:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-primary);
}

/* ---- 内容区 ---- */
.profile-sheet-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* 未登录 */
.profile-sheet-guest {
  text-align: center;
  padding: 32px 24px;
}

.profile-sheet-guest-tip {
  font-size: 14px;
  color: var(--color-text-tertiary);
  margin: 0 0 20px;
  line-height: 1.5;
}

.profile-sheet-guest .btn {
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
}

/* 已登录：信息块 + 页脚 ---- */
.profile-sheet-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.profile-sheet-block {
  padding: 20px 20px 16px;
  flex: 1;
}

.profile-sheet-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 14px;
}

.profile-sheet-row:last-of-type {
  border-bottom: none;
}

.profile-sheet-label {
  width: 64px;
  flex-shrink: 0;
  font-size: 14px;
  color: var(--color-text-tertiary);
}

.profile-sheet-value {
  flex: 1;
  min-width: 0;
  color: var(--color-text-primary);
  text-align: right;
  word-break: break-all;
  font-size: 14px;
}

.profile-sheet-row--nickname .profile-sheet-value,
.profile-sheet-row--nickname .profile-sheet-input {
  flex: 1;
  min-width: 0;
}

.profile-sheet-nickname-display[hidden],
.profile-sheet-nickname-input[hidden] {
  display: none;
}

.profile-sheet-input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--color-border-light);
  border-radius: 10px;
  background: var(--color-bg-white);
  color: var(--color-text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.profile-sheet-input::placeholder {
  color: var(--color-text-light);
}

.profile-sheet-input:hover {
  border-color: var(--color-border);
}

.profile-sheet-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.profile-sheet-msg {
  font-size: 12px;
  margin: 8px 0 0;
  min-height: 1.25em;
  color: var(--color-text-tertiary);
}

.profile-sheet-msg.success { color: #059669; }
.profile-sheet-msg.error { color: #dc2626; }

/* 保存按钮：在昵称下方，主操作 */
.profile-sheet-save-btn {
  width: 100%;
  margin-top: 16px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
}

/* 密码行：紧接昵称下方，与邮箱/昵称同列 */
.profile-sheet-row--action {
  border-bottom: 1px solid var(--color-border-light);
}

.profile-sheet-link {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  text-align: right;
  text-decoration: none;
  transition: color 0.15s ease;
}

.profile-sheet-link:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
}

.profile-sheet-link:focus {
  outline: none;
  text-decoration: underline;
}

/* ---- 修改密码二次弹窗（保持统一风格） ---- */
.profile-pwd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1010;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.profile-pwd-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.97);
  width: min(92vw, 360px);
  background: var(--color-bg-white);
  border-radius: 16px;
  border: 1px solid var(--color-border-light);
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 1011;
}

body.profile-pwd-open .profile-pwd-overlay {
  opacity: 1;
  pointer-events: auto;
}

body.profile-pwd-open .profile-pwd-modal {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.profile-pwd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-bg-white);
}

.profile-pwd-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.profile-pwd-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.profile-pwd-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-pwd-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.profile-pwd-input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--color-border-light);
  border-radius: 10px;
  background: var(--color-bg-white);
  color: var(--color-text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.profile-pwd-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.profile-pwd-msg {
  font-size: 12px;
  margin: 0;
  min-height: 1.25em;
}

.profile-pwd-msg.success { color: #059669; }
.profile-pwd-msg.error { color: #dc2626; }

.profile-pwd-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
}

.profile-pwd-actions .btn {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
}

@media (max-width: 480px) {
  .profile-sheet,
  .profile-pwd-modal {
    width: 94vw;
  }
  .profile-sheet-block {
    padding-left: 16px;
    padding-right: 16px;
  }
  .profile-sheet-header {
    padding: 16px;
  }
}
