/* ===== 用户系统与顶栏区域 ===== */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-auth-wrap {
  position: relative;
}

.auth-open-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-main);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.auth-open-btn:hover {
  background: var(--card-bg-soft);
  border-color: #cbd5e1;
}

.user-avatar-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-main);
  padding: 4px 10px 4px 6px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

.user-avatar-btn:hover {
  background: var(--card-bg-soft);
}

.user-avatar-badge {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.user-name-text {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.uname-short {
  display: none;
}

.uname-full {
  display: inline;
}

.user-dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 200px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
  padding: 6px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-dropdown-panel.hidden {
  display: none !important;
}

.user-dropdown-info {
  padding: 8px 10px 6px;
}

.user-dropdown-uname {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main);
}

.user-dropdown-email {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-divider {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 4px 0;
}

.user-menu-item {
  appearance: none;
  border: none;
  background: transparent;
  padding: 8px 10px;
  text-align: left;
  font-size: 13px;
  color: var(--text-main);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  transition: background 0.15s;
}

a.user-menu-item {
  text-decoration: none;
}

.user-menu-item.hidden {
  display: none;
}

.user-menu-item:hover {
  background: var(--card-bg-soft);
}

.user-menu-item.text-danger {
  color: #ef4444;
}

.user-menu-item.text-danger:hover {
  background: rgba(239, 68, 68, 0.08);
}

/* ===== 模态弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-card {
  width: 90%;
  max-width: 400px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card-lg {
  max-width: 680px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

@keyframes modalPop {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.modal-tabs {
  display: flex;
  gap: 6px;
  background: var(--page-bg);
  padding: 4px;
  border-radius: 10px;
}

.tab-btn {
  appearance: none;
  border: none;
  background: transparent;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn.active {
  background: var(--card-bg);
  color: var(--text-main);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}

.auth-links-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: -4px;
  margin-bottom: 14px;
  font-size: 12px;
}

.auth-link {
  color: #2563eb;
  text-decoration: none;
  transition: opacity 0.15s;
  cursor: pointer;
  font-weight: 500;
}

.auth-link:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.modal-close-btn {
  appearance: none;
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 18px;
}

.history-body {
  overflow-y: auto;
  flex: 1;
  padding: 14px 18px;
}

.auth-alert {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: #b91c1c;
}

.auth-alert.hidden {
  display: none;
}

.form-group {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.form-group input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--card-bg-soft);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus {
  border-color: #3b82f6;
  background: var(--card-bg);
}

.form-group input:disabled,
.form-group input[readonly].input-locked {
  background-color: var(--card-bg-soft) !important;
  opacity: 0.65;
  cursor: not-allowed;
  color: var(--text-muted);
  border-color: var(--border) !important;
  outline: none !important;
  box-shadow: none !important;
}

.password-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-input-wrap input {
  width: 100%;
  padding-right: 40px;
  box-sizing: border-box;
}

.pwd-toggle-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: 6px;
  transition: color 0.15s, background-color 0.15s;
}

.pwd-toggle-btn:hover {
  color: var(--text-main);
  background-color: rgba(125, 125, 125, 0.12);
}

.auth-submit-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: opacity 0.15s;
}

.auth-submit-btn:hover {
  opacity: 0.9;
}

.auth-form.hidden {
  display: none;
}

/* ===== 历史记录模态列表 ===== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--card-bg-soft);
  transition: border-color 0.15s;
}

.history-card:hover {
  border-color: #cbd5e1;
}

.history-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.history-query {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-main);
  margin-bottom: 6px;
}

.history-response {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  max-height: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
}

.history-empty {
  text-align: center;
  padding: 30px;
  color: var(--text-muted);
  font-size: 13px;
}
