/* ============================================
   文章写作辅导平台 样式
   ============================================ */

:root {
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --transition: all 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
}

.hidden { display: none !important; }
.loading { text-align: center; padding: 40px; color: var(--gray-500); font-size: 14px; }

/* ===== 登录页 ===== */
.login-container {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}
.login-card {
  background: white; border-radius: var(--radius);
  padding: 40px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-header { text-align: center; margin-bottom: 30px; }
.login-logo { font-size: 48px; margin-bottom: 10px; }
.login-header h1 { font-size: 24px; color: var(--gray-900); }
.login-subtitle { color: var(--gray-500); font-size: 14px; margin-top: 4px; }

/* ===== 主布局 ===== */
.main-layout { display: flex; min-height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar {
  width: 240px; background: white; border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0;
  height: 100vh; z-index: 100;
}
.sidebar-header {
  padding: 20px; border-bottom: 1px solid var(--gray-100);
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
}
.logo-icon { font-size: 28px; }
.logo-text { font-size: 18px; font-weight: 700; color: var(--gray-900); }
.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--gray-600); text-decoration: none;
  transition: var(--transition); margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: var(--gray-100); color: var(--gray-800); }
.nav-item.active { background: var(--primary); color: white; }
.nav-icon { font-size: 18px; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: white;
  font-size: 11px; padding: 1px 7px; border-radius: 10px;
  min-width: 20px; text-align: center;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,0.9); color: var(--danger); }
.sidebar-footer {
  padding: 16px; border-top: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.user-info { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.user-avatar { font-size: 24px; }
.user-name { font-size: 13px; color: var(--gray-700); font-weight: 500; }
.btn-logout {
  background: none; border: 1px solid var(--gray-200);
  padding: 6px 12px; border-radius: var(--radius-sm);
  color: var(--gray-500); cursor: pointer; font-size: 12px;
  transition: var(--transition);
}
.btn-logout:hover { border-color: var(--danger); color: var(--danger); }

/* ===== 主内容 ===== */
.main-content {
  margin-left: 240px; flex: 1; padding: 24px 32px; min-height: 100vh;
}
.page-section { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.page-header h2 { font-size: 20px; color: var(--gray-900); }
.page-time { color: var(--gray-400); font-size: 13px; }
.header-actions { display: flex; gap: 8px; }

/* ===== 统计卡片 ===== */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: white; border-radius: var(--radius); padding: 20px;
  box-shadow: var(--shadow); border-left: 4px solid var(--gray-300);
}
.stat-card.stat-pending { border-left-color: var(--warning); }
.stat-card.stat-processing { border-left-color: var(--info); }
.stat-card.stat-completed { border-left-color: var(--success); }
.stat-card.stat-revenue { border-left-color: var(--primary); }
.stat-value { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.stat-pending .stat-value { color: var(--warning); }
.stat-processing .stat-value { color: var(--info); }
.stat-completed .stat-value { color: var(--success); }
.stat-revenue .stat-value { color: var(--primary); }
.stat-label { font-size: 13px; color: var(--gray-500); }

/* ===== 面板 ===== */
.dashboard-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
}
.panel-header h3 { font-size: 15px; }
.panel-header a { font-size: 13px; color: var(--primary); text-decoration: none; }
.panel-body { padding: 16px 20px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: var(--transition);
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: white; color: var(--gray-600); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; padding: 12px; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--gray-700); margin-bottom: 6px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: 14px; color: var(--gray-800);
  transition: var(--transition); outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.form-group textarea { resize: vertical; }
.radio-group { display: flex; gap: 16px; }
.radio-label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

/* ===== 筛选栏 ===== */
.filter-bar {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.filter-bar select, .filter-bar input {
  padding: 8px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: 13px; outline: none;
}
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--primary); }

/* ===== 表格 ===== */
.table-container {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 12px 16px; text-align: left; font-size: 12px;
  font-weight: 600; color: var(--gray-500); text-transform: uppercase;
  background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
}
.data-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
}
.data-table tr:hover { background: var(--gray-50); }
.data-table tr:last-child td { border-bottom: none; }

/* ===== 状态标签 ===== */
.status-badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.status-pending { background: #fef3c7; color: #92400e; }
.status-processing { background: #dbeafe; color: #1e40af; }
.status-completed { background: #d1fae5; color: #065f46; }
.status-cancelled { background: #fee2e2; color: #991b1b; }

/* ===== 分页 ===== */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; margin-top: 16px; padding: 16px;
}
.pagination button {
  padding: 6px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); background: white; cursor: pointer;
  font-size: 13px; transition: var(--transition);
}
.pagination button:hover { background: var(--gray-50); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 弹窗 ===== */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-content {
  position: relative; background: white; border-radius: var(--radius);
  width: 90%; max-width: 500px; max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: modalIn 0.2s ease;
}
.modal-lg { max-width: 700px; }
@keyframes modalIn { 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: 16px 20px; border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 { font-size: 16px; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--gray-400); }
.modal-body { padding: 20px; }

/* ===== 套餐卡片 ===== */
.packages-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
}
.package-card {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; text-align: center; position: relative;
  border: 2px solid transparent; transition: var(--transition);
}
.package-card:hover { border-color: var(--primary-light); transform: translateY(-2px); }
.package-card.featured { border-color: var(--primary); }
.package-card.featured::before {
  content: '推荐'; position: absolute; top: -10px; right: 16px;
  background: var(--primary); color: white; padding: 2px 12px;
  border-radius: 10px; font-size: 11px; font-weight: 600;
}
.package-name { font-size: 18px; font-weight: 700; color: var(--gray-900); margin-bottom: 8px; }
.package-price { font-size: 32px; font-weight: 800; color: var(--primary); margin: 12px 0; }
.package-price small { font-size: 14px; font-weight: 400; color: var(--gray-500); }
.package-desc { color: var(--gray-500); font-size: 13px; margin-bottom: 16px; }
.package-features { list-style: none; text-align: left; }
.package-features li { padding: 6px 0; font-size: 13px; color: var(--gray-600); }
.package-features li::before { content: '✓ '; color: var(--success); font-weight: 700; }

/* ===== 写手卡片 ===== */
.writers-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
.writer-card {
  background: white; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; display: flex; gap: 16px; align-items: flex-start;
}
.writer-avatar { font-size: 40px; flex-shrink: 0; }
.writer-info { flex: 1; }
.writer-name { font-size: 15px; font-weight: 600; }
.writer-major { font-size: 12px; color: var(--gray-500); margin: 2px 0 6px; }
.writer-skills { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.skill-tag {
  background: var(--gray-100); padding: 2px 8px; border-radius: 4px;
  font-size: 11px; color: var(--gray-600);
}
.writer-stats { display: flex; gap: 12px; font-size: 12px; color: var(--gray-500); }
.writer-stats span { display: flex; align-items: center; gap: 4px; }

/* ===== 沟通中心 ===== */
.chat-layout { display: flex; height: calc(100vh - 120px); background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.chat-sidebar { width: 280px; border-right: 1px solid var(--gray-200); display: flex; flex-direction: column; }
.chat-search { padding: 12px; }
.chat-search input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); outline: none; font-size: 13px;
}
.chat-order-list { flex: 1; overflow-y: auto; }
.chat-order-item {
  padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--gray-100);
  transition: var(--transition);
}
.chat-order-item:hover { background: var(--gray-50); }
.chat-order-item.active { background: var(--primary); color: white; }
.chat-order-item .coi-client { font-weight: 600; font-size: 14px; }
.chat-order-item .coi-package { font-size: 12px; opacity: 0.8; }
.chat-order-item .coi-last-msg { font-size: 12px; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-placeholder {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; color: var(--gray-400);
}
.placeholder-icon { font-size: 48px; margin-bottom: 12px; }

.chat-header { padding: 14px 20px; border-bottom: 1px solid var(--gray-100); }
.chat-header h3 { font-size: 15px; }
.chat-header .chat-order-info { font-size: 12px; color: var(--gray-500); }

.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.message {
  max-width: 70%; padding: 10px 14px; border-radius: 12px;
  font-size: 13px; line-height: 1.5;
}
.message-system { align-self: center; background: var(--gray-100); color: var(--gray-500); font-size: 12px; border-radius: 20px; padding: 6px 16px; }
.message-client { align-self: flex-start; background: var(--gray-100); }
.message-writer { align-self: flex-end; background: var(--primary); color: white; }
.message-admin { align-self: flex-end; background: #7c3aed; color: white; }
.message-sender { font-size: 11px; margin-bottom: 4px; font-weight: 600; }
.message-writer .message-sender { color: rgba(255,255,255,0.8); }
.message-admin .message-sender { color: rgba(255,255,255,0.8); }
.message-images { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.message-images img { max-width: 200px; max-height: 200px; border-radius: 8px; cursor: pointer; transition: var(--transition); }
.message-images img:hover { transform: scale(1.05); }
.message-audio { margin-top: 6px; }
.message-audio audio { height: 36px; max-width: 220px; }
.message-time { font-size: 10px; margin-top: 4px; opacity: 0.6; text-align: right; }

.chat-input-area {
  padding: 12px 16px; border-top: 1px solid var(--gray-200);
  display: flex; gap: 8px; align-items: flex-end;
}
.chat-input-area textarea {
  flex: 1; padding: 8px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); resize: none; min-height: 40px; max-height: 120px;
  font-size: 16px; outline: none; line-height: 1.4;
  -webkit-appearance: none;
}
/* 移动端使用 16px font-size 防止 iOS 自动缩放 */
.chat-input-area textarea:focus { border-color: var(--primary); }
.chat-actions { display: flex; gap: 4px; }
.chat-btn {
  width: 40px; height: 40px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); background: white; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: var(--transition);
}
.chat-btn:hover { background: var(--gray-50); border-color: var(--primary); }

/* ===== 图片预览放大 ===== */
.image-preview-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 2000;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.image-preview-overlay img {
  max-width: 90%; max-height: 90%; border-radius: 8px;
}

/* ===== 通知消息 ===== */
.notice-list { display: flex; flex-direction: column; gap: 12px; }
.notice-item { padding: 8px 0; border-bottom: 1px solid var(--gray-100); }
.notice-item:last-child { border-bottom: none; }
.notice-title { font-weight: 600; font-size: 13px; color: var(--gray-800); }
.notice-desc { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ===== 错误消息 ===== */
.error-message {
  color: var(--danger); font-size: 13px; text-align: center;
  padding: 8px; margin-top: 12px; background: #fef2f2;
  border-radius: var(--radius-sm);
}

/* ===== 下架/停用置灰 ===== */
.package-offline { opacity: 0.55; }

/* ===== 客户订单卡片 ===== */
.client-orders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.client-order-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  border: 2px solid transparent;
}
.client-order-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.client-order-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.client-order-no {
  font-weight: 600;
  font-size: 15px;
  color: var(--gray-900);
}
.client-order-body {
  margin-bottom: 12px;
}
.client-order-package {
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
  margin-bottom: 4px;
}
.client-order-topic {
  font-size: 13px;
  color: var(--gray-600);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.client-order-writer {
  font-size: 12px;
  color: var(--gray-500);
}
.client-order-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--gray-100);
}
.client-order-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}
.client-order-time {
  font-size: 12px;
  color: var(--gray-400);
}

/* ===== 通讯录（私聊）===== */
.chat-contact-list { flex: 1; overflow-y: auto; }
.chat-contact-item { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; transition: var(--transition); border-bottom: 1px solid #f8f9fb; }
.chat-contact-item:hover { background: var(--gray-50); }
.chat-contact-item.active { background: #eef2ff; }
.cc-avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 700; flex-shrink: 0; }
.cc-info { flex: 1; min-width: 0; }
.cc-name { font-size: 14px; font-weight: 600; color: var(--gray-800); display: flex; align-items: center; gap: 6px; }
.cc-last { font-size: 12px; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-time { font-size: 11px; color: var(--gray-400); flex-shrink: 0; }
.unread-dot { background: var(--danger); color: #fff; font-size: 10px; min-width: 18px; height: 18px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; }

/* ===== 内部论坛 ===== */
.forum-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.forum-post-list { display: flex; flex-direction: column; gap: 12px; }
.forum-post-item { background: #fff; border-radius: var(--radius); padding: 18px 22px; box-shadow: var(--shadow); cursor: pointer; transition: var(--transition); }
.forum-post-item:hover { border-left: 4px solid var(--primary); }
.fp-title { font-size: 16px; font-weight: 700; color: var(--gray-900); margin-bottom: 6px; }
.fp-meta { font-size: 12px; color: var(--gray-400); display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.fp-meta .author { color: var(--primary); font-weight: 600; }
.fp-meta .admin-tag { background: #7c3aed; color: #fff; padding: 1px 8px; border-radius: 10px; font-size: 10px; }
.forum-post-detail { background: #fff; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 16px; }
.fp-detail-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.fp-detail-content { font-size: 14px; color: var(--gray-700); white-space: pre-wrap; margin: 12px 0; }
.reply-item { display: flex; gap: 10px; padding: 14px 0; border-bottom: 1px solid #f3f4f6; }
.reply-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gray-200); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--gray-600); flex-shrink: 0; }
.reply-body { flex: 1; }
.reply-meta { font-size: 12px; color: var(--gray-400); margin-bottom: 4px; }
.reply-meta .author { color: var(--primary); font-weight: 600; }
.reply-content { font-size: 13.5px; color: var(--gray-700); }
.write-post-card { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); position: sticky; top: 20px; }
@media (max-width: 900px) {
  .forum-layout { grid-template-columns: 1fr; }
  .write-post-card { position: static; }
}

/* ===== 响应式 ===== */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .packages-grid { grid-template-columns: repeat(2, 1fr); }
  .writers-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-panels { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar .logo-text, .sidebar .nav-item span:not(.nav-icon), .sidebar .user-name, .sidebar .nav-badge { display: none; }
  .sidebar-footer { flex-direction: column; gap: 8px; }
  .main-content { margin-left: 60px; padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .packages-grid { grid-template-columns: 1fr; }
  .writers-grid { grid-template-columns: 1fr; }
  .chat-layout { flex-direction: column; }
  .chat-sidebar { width: 100%; max-height: 200px; }
  .message { max-width: 85%; }
}