/* ==========================================================
 * auth-kit widget — 主题变量在 :root 下，可由宿主页面覆盖
 * 所有类名以 .ak- 开头，避免污染宿主样式
 * ========================================================== */
:root {
  --ak-primary: #3b82f6;
  --ak-primary-hover: #2563eb;
  --ak-text: #1f2937;
  --ak-text-muted: #6b7280;
  --ak-border: #e5e7eb;
  --ak-bg: #ffffff;
  --ak-bg-soft: #f9fafb;
  --ak-error-bg: #fef2f2;
  --ak-error-text: #b91c1c;
  --ak-success-bg: #f0fdf4;
  --ak-success-text: #15803d;
  --ak-radius: 10px;
  --ak-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  --ak-z: 2147483000;
}

/* ==========================================================
 * 遮罩与卡片
 * ========================================================== */
.ak-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--ak-z);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  color: var(--ak-text);
  animation: ak-fade-in 0.18s ease-out;
}

@keyframes ak-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ak-card {
  background: var(--ak-bg);
  border-radius: var(--ak-radius);
  box-shadow: var(--ak-shadow);
  width: 400px;
  max-width: calc(100vw - 32px);
  padding: 24px;
  box-sizing: border-box;
  position: relative;
}

.ak-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--ak-text-muted);
  border-radius: 6px;
}
.ak-close:hover {
  background: var(--ak-bg-soft);
  color: var(--ak-text);
}

.ak-title {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 600;
}

/* ==========================================================
 * Tab 切换
 * ========================================================== */
.ak-tabs {
  display: flex;
  border-bottom: 1px solid var(--ak-border);
  margin: 0 0 16px;
  gap: 4px;
}
.ak-tab {
  background: transparent;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--ak-text-muted);
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.ak-tab.ak-active {
  color: var(--ak-primary);
  border-bottom-color: var(--ak-primary);
  font-weight: 500;
}
.ak-tab:hover {
  color: var(--ak-text);
}

/* ==========================================================
 * 表单
 * ========================================================== */
.ak-field {
  margin-bottom: 12px;
}
.ak-label {
  display: block;
  font-size: 12px;
  color: var(--ak-text-muted);
  margin-bottom: 4px;
}
.ak-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--ak-border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--ak-bg);
  color: var(--ak-text);
}
.ak-input:focus {
  border-color: var(--ak-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.ak-input.ak-invalid {
  border-color: var(--ak-error-text);
}

.ak-row {
  display: flex;
  gap: 8px;
}
.ak-row .ak-input {
  flex: 1;
}

.ak-send-btn {
  padding: 0 14px;
  border: 1px solid var(--ak-primary);
  background: var(--ak-bg);
  color: var(--ak-primary);
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.ak-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.ak-send-btn:hover:not(:disabled) {
  background: var(--ak-primary);
  color: #fff;
}

.ak-submit {
  width: 100%;
  padding: 10px;
  background: var(--ak-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s;
}
.ak-submit:hover:not(:disabled) {
  background: var(--ak-primary-hover);
}
.ak-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ak-hint {
  font-size: 12px;
  color: var(--ak-text-muted);
  margin-top: 4px;
}
.ak-error-inline {
  font-size: 12px;
  color: var(--ak-error-text);
  margin-top: 4px;
  min-height: 16px;
}

/* ==========================================================
 * Toast 条
 * ========================================================== */
.ak-toast {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  display: none;
}
.ak-toast.ak-toast-error {
  background: var(--ak-error-bg);
  color: var(--ak-error-text);
  display: block;
}
.ak-toast.ak-toast-success {
  background: var(--ak-success-bg);
  color: var(--ak-success-text);
  display: block;
}

/* ==========================================================
 * 登录状态条（可选：外部调用者可用）
 * ========================================================== */
.ak-user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--ak-bg-soft);
  font-size: 13px;
  color: var(--ak-text);
}

/* ==========================================================
 * 响应式
 * ========================================================== */
@media (max-width: 480px) {
  .ak-card {
    width: calc(100vw - 32px);
    padding: 20px;
  }
}
