/* ============================================================
   云邮箱 - 样式表
   ============================================================ */

/* ─── CSS 变量 ─────────────────────────────────────────────── */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f0f1f3;
  --bg-hover: #e8eaf0;
  --bg-active: #e0e3ed;
  --text-primary: #1a1a2e;
  --text-secondary: #5a5d72;
  --text-muted: #9295a8;
  --text-inverse: #ffffff;
  --border-color: #e2e4ea;
  --border-light: #f0f1f5;
  --accent: #6366f1;
  --accent-hover: #5558e6;
  --accent-light: #eef0ff;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --warning: #f59e0b;
  --success: #10b981;
  --star-color: #f59e0b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --transition: 0.2s ease;
}

/* ─── 重置 ─────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", sans-serif;
  color: var(--text-primary);
  background: var(--bg-secondary);
  line-height: 1.6;
  height: 100vh;
  overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── 通用组件 ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon {
  padding: 6px;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  justify-content: center;
}
.btn-full { width: 100%; justify-content: center; }
.btn-danger:hover { color: var(--danger); background: #fef2f2; }
.btn .btn-loading { display: none; }
.btn.loading .btn-text { display: none; }
.btn.loading .btn-loading { display: inline; }

/* ─── 登录页面 ─────────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef0ff 0%, #f8f9fa 50%, #e8f5e9 100%);
}
.auth-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}
.auth-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}
.auth-header {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo { margin-bottom: 12px; }
.auth-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}
.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all var(--transition);
}
.auth-tab.active {
  background: var(--bg-primary);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.auth-form { display: none; }
.auth-form.active { display: block; }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  transition: border var(--transition);
  outline: none;
}
.form-group input:focus, .form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
  display: none;
}
.form-error.show { display: block; }
.input-suffix {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.input-suffix input {
  border: none;
  border-radius: 0;
  flex: 1;
}
.input-suffix input:focus { box-shadow: none; }
.input-suffix:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.input-suffix .suffix {
  padding: 10px 12px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

/* ─── 顶部栏 ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  position: relative;
  z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}
.topbar-center { flex: 1; max-width: 480px; margin: 0 auto; }
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 6px 14px;
  border: 1px solid transparent;
  transition: all var(--transition);
}
.search-box:focus-within {
  background: var(--bg-primary);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.search-box input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 14px;
  color: var(--text-primary);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.user-email {
  font-size: 13px;
  color: var(--text-secondary);
}
.sidebar-toggle { display: none; }

/* ─── 布局 ─────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: calc(100vh - var(--topbar-height));
}

/* ─── 侧边栏 ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 12px;
  flex-shrink: 0;
  transition: margin var(--transition);
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }
.btn-compose {
  margin-bottom: 8px;
  padding: 12px;
  justify-content: center;
  font-size: 15px;
  border-radius: var(--radius-md);
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  cursor: pointer;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); text-decoration: none; }
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.sidebar-section { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border-light); }
.sidebar-section-title { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.domain-info { padding: 0 4px; }
.domain-info-item { display: flex; justify-content: space-between; font-size: 13px; }
.domain-label { color: var(--text-muted); }
.domain-value { color: var(--text-primary); font-weight: 500; word-break: break-all; }

/* ─── 主内容区 ─────────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  background: var(--bg-primary);
}

/* ─── 邮件列表 ─────────────────────────────────────────────── */
.email-list {
  width: 400px;
  min-width: 300px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.email-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-light);
}
.email-list-header h2 { font-size: 18px; font-weight: 700; }
.email-list-actions { display: flex; gap: 4px; }
.email-list-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* 邮件列表项 */
.email-item {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
  position: relative;
}
.email-item:hover { background: var(--bg-secondary); }
.email-item.active { background: var(--accent-light); }
.email-item.unread { background: #fafbff; }
.email-item.unread .email-sender { font-weight: 600; }
.email-item.unread::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}
.email-item-star {
  flex-shrink: 0;
  padding-top: 2px;
}
.email-item-star svg { fill: transparent; stroke: var(--border-color); transition: all var(--transition); }
.email-item-star.starred svg { fill: var(--star-color); stroke: var(--star-color); }
.email-item-content { flex: 1; min-width: 0; }
.email-item-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.email-sender {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.email-date {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-left: 8px;
}
.email-subject {
  font-size: 13px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.email-preview {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

/* ─── 邮件详情 ─────────────────────────────────────────────── */
.email-detail {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.email-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  gap: 8px;
}
.email-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
}
.email-detail .email-header-info {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-light);
}
.email-detail .email-subject-line {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 12px;
}
.email-detail .email-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.email-detail .email-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.email-detail .email-meta-label { color: var(--text-muted); min-width: 40px; }
.email-detail .email-meta-value { color: var(--text-primary); font-weight: 500; }
.email-detail .email-meta-value.sender { color: var(--accent); }
.email-detail .email-content {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.email-detail .email-content.html-content {
  white-space: normal;
}
.email-detail .email-attachments {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
}
.email-detail .attachment-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin: 0 6px 6px 0;
}

/* ─── 写邮件对话框 ─────────────────────────────────────────── */
.compose-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.compose-dialog {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 560px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.compose-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}
.compose-header h3 { font-size: 16px; font-weight: 600; }
.compose-form { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.compose-form .compose-field { display: flex; flex-direction: column; gap: 4px; }
.compose-form .compose-field label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.compose-form .compose-field input { padding: 10px 12px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-size: 14px; outline: none; }
.compose-form .compose-field input:focus { border-color: var(--accent); }
.compose-field-body { flex: 1; }
.compose-form .compose-field textarea {
  min-height: 180px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  resize: vertical;
  font-family: inherit;
  line-height: 1.6;
}
.compose-form .compose-field textarea:focus { border-color: var(--accent); }
.compose-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

/* ─── 加载中和空状态 ───────────────────────────────────────── */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-muted);
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 4px; }
.empty-state p { font-size: 13px; }

/* ─── 响应式 ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: var(--topbar-height); bottom: 0; z-index: 50; box-shadow: var(--shadow-lg); }
  .sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-width)); }
  .sidebar-toggle { display: flex; }
  .email-list { width: 100%; min-width: 0; }
  .email-detail { position: fixed; inset: var(--topbar-height) 0 0 0; z-index: 40; background: var(--bg-primary); }
  .topbar-center { max-width: none; }
  .compose-dialog { width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
}

/* ─── 滚动条美化 ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
