/* ============================================
   WeChat AI Chat - Base Styles
   基础样式：CSS变量、重置、通用组件
   ============================================ */

:root {
  --wx-green: #07C160;
  --wx-green-dark: #06AD56;
  --wx-green-bg: #E8F8EF;
  --wx-red: #FA5151;
  --wx-red-bg: #FEECEC;
  --wx-orange: #FA9D3B;
  --wx-blue: #576B95;
  --wx-bg: #EDEDED;
  --wx-bg-light: #F7F7F7;
  --wx-bg-white: #FFFFFF;
  --wx-bg-chat: #EDEDED;
  --wx-bg-hover: #E5E5E5;
  --wx-bg-active: #D9D9D9;
  --wx-text: #191919;
  --wx-text-secondary: #888888;
  --wx-text-tertiary: #B2B2B2;
  --wx-text-link: #576B95;
  --wx-border: #D9D9D9;
  --wx-border-light: #E5E5E5;
  --wx-bubble-other: #FFFFFF;
  --wx-bubble-self: #95EC69;
  --wx-shadow: 0 2px 8px rgba(0,0,0,0.08);
  --wx-shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
  --wx-transition: 0.2s ease;
  --wx-transition-fast: 0.15s ease;
  --wx-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --wx-font-mono: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--wx-font);
  font-size: 15px;
  color: var(--wx-text);
  background: var(--wx-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  height: 100%;
  width: 100%;
}

a {
  color: var(--wx-text-link);
  text-decoration: none;
}

input, textarea, button, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
  border: none;
  background: none;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

.hidden {
  display: none !important;
}

.h-full {
  height: 100%;
}

.w-full {
  width: 100%;
}

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--wx-transition-fast);
  white-space: nowrap;
  min-height: 36px;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--wx-green);
  color: white;
}

.btn-primary:active {
  background: var(--wx-green-dark);
}

.btn-default {
  background: var(--wx-bg-light);
  color: var(--wx-text);
}

.btn-default:active {
  background: var(--wx-bg-hover);
}

.btn-danger {
  background: var(--wx-red);
  color: white;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 16px;
  min-height: 44px;
  border-radius: 8px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  min-height: 28px;
  border-radius: 4px;
}

.btn-block {
  width: 100%;
}

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

/* ---------- 输入框 ---------- */
.input {
  width: 100%;
  padding: 10px 12px;
  background: var(--wx-bg-light);
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 14px;
  transition: all var(--wx-transition-fast);
}

.input:focus {
  background: var(--wx-bg-white);
  border-color: var(--wx-green);
}

.input::placeholder {
  color: var(--wx-text-tertiary);
}

/* ---------- 开关 ---------- */
.switch {
  position: relative;
  width: 50px;
  height: 30px;
  background: var(--wx-border);
  border-radius: 15px;
  cursor: pointer;
  transition: background var(--wx-transition);
  flex-shrink: 0;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform var(--wx-transition);
}

.switch.active {
  background: var(--wx-green);
}

.switch.active::after {
  transform: translateX(20px);
}

/* ---------- Cell 列表项 ---------- */
.cell {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--wx-bg-white);
  cursor: pointer;
  transition: background var(--wx-transition-fast);
  position: relative;
  gap: 12px;
}

.cell:active {
  background: var(--wx-bg-hover);
}

.cell::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 0;
  height: 1px;
  background: var(--wx-border-light);
}

.cell:last-child::after {
  display: none;
}

.cell-group {
  background: var(--wx-bg-white);
  margin-bottom: 8px;
}

.cell-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cell-icon svg {
  width: 20px;
  height: 20px;
}

.cell-title {
  flex: 1;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-value {
  font-size: 14px;
  color: var(--wx-text-secondary);
  flex-shrink: 0;
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-arrow {
  width: 16px;
  height: 16px;
  color: var(--wx-text-tertiary);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell-arrow svg {
  width: 14px;
  height: 14px;
}

/* ---------- 头像 ---------- */
.avatar {
  border-radius: 5px;
  overflow: hidden;
  background: var(--wx-bg-light);
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm { width: 32px; height: 32px; }
.avatar-md { width: 40px; height: 40px; }
.avatar-lg { width: 56px; height: 56px; }
.avatar-xl { width: 72px; height: 72px; }

.avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--wx-green);
  color: white;
  font-weight: 600;
  font-size: 16px;
}

.online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: var(--wx-green);
  border-radius: 50%;
  border: 2px solid var(--wx-bg-white);
}

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--wx-red);
  color: white;
  font-size: 11px;
  font-weight: 500;
  border-radius: 9px;
  line-height: 1;
}

/* ---------- 搜索栏 ---------- */
.search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: var(--wx-bg-white);
  border-radius: 6px;
  cursor: pointer;
}

.search-bar svg {
  width: 16px;
  height: 16px;
  color: var(--wx-text-tertiary);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  font-size: 14px;
  background: transparent;
}

.search-bar input::placeholder {
  color: var(--wx-text-tertiary);
}

/* ---------- 加载动画 ---------- */
.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--wx-border);
  border-top-color: var(--wx-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Toast ---------- */
.toast-container {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  pointer-events: none;
}

.toast {
  background: rgba(0, 0, 0, 0.75);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  max-width: 80vw;
  text-align: center;
  word-break: break-all;
  animation: toastIn 0.2s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- Loading 遮罩 ---------- */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Modal 遮罩 ---------- */
.modal-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: maskIn 0.2s ease;
}

.modal-mask.closing {
  opacity: 0;
  transition: opacity 0.2s;
}

@keyframes maskIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ---------- ActionSheet ---------- */
.action-sheet-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  animation: maskIn 0.2s ease;
}

.action-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--wx-bg-light);
  z-index: 1001;
  padding: 8px;
  padding-bottom: calc(8px + var(--safe-bottom));
  animation: sheetUp 0.25s ease;
  max-height: 70vh;
  overflow-y: auto;
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.action-sheet .action-title {
  padding: 12px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--wx-text-secondary);
  background: var(--wx-bg-white);
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid var(--wx-border-light);
}

.action-sheet .action-item {
  padding: 14px 16px;
  text-align: center;
  font-size: 16px;
  background: var(--wx-bg-white);
  cursor: pointer;
  transition: background var(--wx-transition-fast);
  border-bottom: 1px solid var(--wx-border-light);
}

.action-sheet .action-item:active {
  background: var(--wx-bg-hover);
}

.action-sheet .action-item.danger {
  color: var(--wx-red);
}

.action-sheet .action-cancel {
  margin-top: 8px;
  padding: 14px 16px;
  text-align: center;
  font-size: 16px;
  background: var(--wx-bg-white);
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--wx-transition-fast);
}

.action-sheet .action-cancel:active {
  background: var(--wx-bg-hover);
}

/* ---------- 空状态 ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--wx-text-tertiary);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state-icon svg {
  width: 100%;
  height: 100%;
}

.empty-state-text {
  font-size: 14px;
}

/* ---------- 页面内容容器 ---------- */
.page-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- 滚动条美化 ---------- */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}
