/* ===== Auth UI — 登录按钮 + 用户头像 ===== */

/* Prevent flash: hide login when session cookie detected, hide avatar otherwise */
.auth-avatar-wrap { display: none; }
html.has-session .auth-login { display: none !important; }
html.has-session .auth-avatar-wrap { display: block !important; }

/* Login button — Apple style */
.auth-login {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: 20px;
  background: transparent;
  color: var(--color-text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.auth-login:hover {
  background: var(--color-text);
  color: var(--color-bg);
  border-color: var(--color-text);
}

.auth-login svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Avatar button + badge (WeChat-style) */
.auth-avatar-wrap {
  position: relative;
}

.auth-avatar-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.auth-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
}

.auth-avatar-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #DD4C4F;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--color-bg);
  box-sizing: content-box;
}

/* Unified dropdown menu */
.auth-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  z-index: 1000;
}

.auth-menu.active {
  display: block;
}

html[data-theme="dark"] .auth-menu {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* User info row */
.auth-menu-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
}

.auth-menu-avatar {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.auth-menu-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Dividers */
.auth-menu-divider {
  height: 1px;
  background: var(--color-border);
  margin: 0;
}

/* Notification section */
.auth-menu-section {
  padding: 0;
}

.auth-menu-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.auth-menu-notif-count {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: #DD4C4F;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.auth-menu-notif-list {
  max-height: 240px;
  overflow-y: auto;
}

.auth-menu-notif-item {
  padding: 8px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  transition: background 0.15s;
}

html[data-theme="dark"] .auth-menu-notif-item {
  border-bottom-color: rgba(255, 255, 255, 0.04);
}

.auth-menu-notif-item:last-child {
  border-bottom: none;
}

.auth-menu-notif-item:hover {
  background: rgba(0, 0, 0, 0.02);
}

html[data-theme="dark"] .auth-menu-notif-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.auth-menu-notif-item.unread {
  background: rgba(221, 76, 79, 0.05);
}

html[data-theme="dark"] .auth-menu-notif-item.unread {
  background: rgba(221, 76, 79, 0.08);
}

.auth-menu-notif-text {
  font-size: 13px;
  line-height: 1.4;
  color: var(--color-text);
}

.auth-menu-notif-time {
  font-size: 11px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

.auth-menu-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 13px;
}

.auth-menu-mark-read {
  display: block;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: #DD4C4F;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}

.auth-menu-mark-read:hover {
  background: rgba(221, 76, 79, 0.05);
}

/* Action items */
.auth-menu-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  color: var(--color-text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.auth-menu-item:hover {
  background: rgba(0, 0, 0, 0.04);
}

html[data-theme="dark"] .auth-menu-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.auth-menu-item-danger {
  color: var(--color-text-secondary);
}

.auth-menu-item-danger:hover {
  color: #DD4C4F;
}

/* ===== Profile Modal — 修改资料弹窗 ===== */

.profile-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.profile-modal {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  width: 320px;
  max-width: calc(100vw - 32px);
}

html[data-theme='dark'] .profile-modal {
  background: #1f2937;
}

.profile-modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 24px;
  color: #111;
}

html[data-theme='dark'] .profile-modal-title {
  color: #f3f4f6;
}

/* Avatar area */
.profile-modal-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 16px;
}

.profile-modal-avatar {
  width: 80px;
  height: 80px;
  border-radius: 8px;
  object-fit: cover;
  background: #f0f0f0;
  cursor: pointer;
  transition: opacity 0.2s;
}

.profile-modal-avatar:hover {
  opacity: 0.8;
}

html[data-theme='dark'] .profile-modal-avatar {
  background: #374151;
}

.profile-modal-hint {
  font-size: 12px;
  color: #6b7280;
  margin-top: 8px;
}

html[data-theme='dark'] .profile-modal-hint {
  color: #9ca3af;
}

/* Nickname field */
.profile-modal-field {
  margin-bottom: 16px;
}

.profile-modal-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 8px;
}

html[data-theme='dark'] .profile-modal-label {
  color: #d1d5db;
}

.profile-modal-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #111;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.profile-modal-input::placeholder {
  color: #9ca3af;
}

.profile-modal-input:focus {
  border-color: #DD4C4F;
  box-shadow: 0 0 0 1px #DD4C4F;
}

html[data-theme='dark'] .profile-modal-input {
  background: #374151;
  border-color: #4b5563;
  color: #f3f4f6;
}

html[data-theme='dark'] .profile-modal-input::placeholder {
  color: #6b7280;
}

html[data-theme='dark'] .profile-modal-input:focus {
  border-color: #DD4C4F;
  box-shadow: 0 0 0 1px #DD4C4F;
}

/* Buttons */
.profile-modal-actions {
  display: flex;
  gap: 12px;
  padding-top: 16px;
}

.profile-modal-btn {
  flex: 1;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.profile-modal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.profile-modal-btn-cancel {
  background: transparent;
  border: 1px solid #d1d5db;
  color: #374151;
}

.profile-modal-btn-cancel:hover:not(:disabled) {
  background: #f9fafb;
}

html[data-theme='dark'] .profile-modal-btn-cancel {
  border-color: #4b5563;
  color: #d1d5db;
}

html[data-theme='dark'] .profile-modal-btn-cancel:hover:not(:disabled) {
  background: #374151;
}

.profile-modal-btn-confirm {
  background: #DD4C4F;
  color: #fff;
}

.profile-modal-btn-confirm:hover:not(:disabled) {
  background: #c43e41;
}

/* Responsive */
@media (max-width: 640px) {
  .auth-login span {
    display: none;
  }
  .auth-login {
    padding: 6px 10px;
  }
  .auth-menu {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 70vh;
    overflow-y: auto;
  }
}
