/**
 * 深圳市禾力报关有限公司 · 企微AI助手系统
 * 样式文件
 */

/* ============ 基础样式 ============ */
:root {
  --primary: #C41E1E;
  --primary-dark: #a31818;
  --secondary: #D4A843;
  --bg: #F5F5F5;
  --white: #ffffff;
  --text: #333333;
  --text-light: #666666;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;
}

* {
  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;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============ 登录页 ============ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
}

.login-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: url('/images/background.jpg');
  background-size: cover;
  background-position: center;
  opacity: 0.15;
  filter: blur(2px);
}

.login-container {
  position: relative;
  z-index: 1;
  width: 420px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hover);
  padding: 40px;
  animation: fadeInUp 0.6s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.login-logo img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: 50%;
  box-shadow: var(--shadow);
}

.login-title {
  text-align: center;
  margin-bottom: 8px;
}

.login-title h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-title p {
  font-size: 13px;
  color: var(--text-light);
}

.login-slogan {
  text-align: center;
  margin-bottom: 24px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.login-slogan span {
  font-size: 14px;
  color: var(--secondary);
  font-weight: 500;
  letter-spacing: 2px;
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.login-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(196, 30, 30, 0.3);
}

.login-btn i {
  font-size: 20px;
}

.login-info {
  margin-top: 24px;
  padding: 16px;
  background: #fafafa;
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.8;
}

.login-info h4 {
  color: var(--primary);
  margin-bottom: 8px;
  font-size: 13px;
}

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

/* 侧边栏 */
.sidebar {
  width: 240px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
}

.sidebar-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  line-height: 1.3;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  margin: 2px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.nav-item:hover {
  background: #fff1f0;
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary);
  color: var(--white);
}

.nav-item i {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-light);
  text-align: center;
}

/* 主内容区 */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 24px 32px;
  min-height: 100vh;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.page-header p {
  font-size: 14px;
  color: var(--text-light);
}

/* ============ 卡片组件 ============ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

/* ============ 表单组件 ============ */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: all 0.2s;
  font-family: inherit;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(196, 30, 30, 0.1);
}

.form-textarea {
  min-height: 120px;
  resize: vertical;
}

/* ============ 按钮组件 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #f0f0f0;
  color: var(--text);
}

.btn-secondary:hover {
  background: #e0e0e0;
}

/* ============ 客户群列表 ============ */
.chatroom-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}

.chatroom-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.chatroom-item:hover {
  background: #fff1f0;
}

.chatroom-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.chatroom-info {
  flex: 1;
}

.chatroom-name {
  font-size: 14px;
  font-weight: 500;
}

.chatroom-meta {
  font-size: 12px;
  color: var(--text-light);
}

.chatroom-count {
  background: #e8f5e9;
  color: #2e7d32;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}

/* ============ 模板列表 ============ */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.template-card {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.template-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}

.template-card h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.template-card .category {
  font-size: 12px;
  color: var(--secondary);
  margin-bottom: 8px;
}

.template-card .preview {
  font-size: 13px;
  color: var(--text-light);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============ 发送记录表格 ============ */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.data-table th {
  font-weight: 600;
  color: var(--text-light);
  background: #fafafa;
}

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
}

.status-success { background: #e8f5e9; color: #2e7d32; }
.status-pending { background: #fff3e0; color: #ef6c00; }
.status-failed { background: #ffebee; color: #c62828; }

/* ============ 统计卡片 ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  text-align: center;
}

.stat-card .number {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.stat-card .label {
  font-size: 14px;
  color: var(--text-light);
}

/* ============ 响应式 ============ */
@media (max-width: 768px) {
  .sidebar {
    width: 200px;
  }
  .main-content {
    margin-left: 200px;
    padding: 16px;
  }
  .template-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .sidebar {
    display: none;
  }
  .main-content {
    margin-left: 0;
  }
  .login-container {
    width: 90%;
    padding: 24px;
  }
}

/* ============ 动画 ============ */
.fade-in {
  animation: fadeIn 0.3s ease;
}

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

/* ============ 消息提示 ============ */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius);
  color: var(--white);
  font-size: 14px;
  z-index: 1000;
  animation: slideIn 0.3s ease;
}

.toast-success { background: #4caf50; }
.toast-error { background: #f44336; }
.toast-info { background: #2196f3; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============ 加载动画 ============ */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============ 隐藏/显示 ============ */
.hidden { display: none !important; }
