/* IO智联管理后台 - 全局样式 */
:root {
  --primary: #1890ff;
  --primary-hover: #40a9ff;
  --primary-active: #096dd9;
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --info: #1890ff;
  --text: #333;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #e8e8e8;
  --bg: #f0f2f5;
  --bg-white: #fff;
  --sidebar-bg: #001529;
  --sidebar-text: #ffffffb3;
  --sidebar-active: #1890ff;
  --header-height: 56px;
  --sidebar-width: 200px;
  --radius: 4px;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ========== 布局 ========== */
.layout { display: flex; flex-direction: column; height: 100vh; }
.header {
  height: var(--header-height); background: var(--bg-white); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 20px; font-weight: 700; color: var(--primary); }
.title { font-size: 16px; color: var(--text); }
.header-right { display: flex; align-items: center; gap: 16px; }
.admin-name { color: var(--text-secondary); }

.main { display: flex; flex: 1; overflow: hidden; }
.sidebar {
  width: var(--sidebar-width); background: var(--sidebar-bg); overflow-y: auto; flex-shrink: 0;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; padding: 12px 24px; color: var(--sidebar-text);
  text-decoration: none; transition: all 0.2s; font-size: 14px;
}
.menu-item:hover { color: #fff; background: #ffffff1a; }
.menu-item.active { background: var(--sidebar-active); color: #fff; }
.menu-icon { font-size: 16px; width: 20px; text-align: center; }

.content { flex: 1; overflow-y: auto; padding: 24px; background: var(--bg); }
.footer {
  height: 40px; background: var(--bg-white); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 12px;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; padding: 6px 16px;
  border-radius: var(--radius); font-size: 14px; cursor: pointer; border: 1px solid transparent;
  transition: all 0.2s; line-height: 1.5; white-space: nowrap;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-default { background: #fff; color: var(--text); border-color: var(--border); }
.btn-default:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #ff7875; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { background: #ffc53d; }
.btn-link { background: none; border: none; color: var(--primary); padding: 0; cursor: pointer; font-size: 14px; }
.btn-link:hover { color: var(--primary-hover); }
.btn-block { width: 100%; padding: 10px 16px; font-size: 16px; }

/* ========== 表单 ========== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; color: var(--text); font-weight: 500; }
.form-input, .form-select {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; color: var(--text); background: #fff; transition: border-color 0.2s;
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(24,144,255,0.2); }
textarea.form-input { resize: vertical; }
.form-input.input-error, .form-select.input-error { border-color: var(--danger); }
.required { color: var(--danger); margin-left: 2px; }
.radio-group { display: flex; gap: 20px; }
.radio-label, .checkbox-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 400; }
.form-actions { padding-top: 8px; }
.form-hint { display: block; margin-top: 4px; color: var(--text-muted); font-size: 12px; }
.import-guide { background: #f5f5f5; padding: 16px; border-radius: var(--radius); margin-bottom: 16px; }
.import-guide h4 { margin: 0 0 8px 0; font-size: 14px; }
.import-guide ol { margin: 0; padding-left: 20px; color: var(--text-secondary); }

/* ========== 表格 ========== */
.data-table {
  width: 100%; border-collapse: collapse; background: var(--bg-white);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.data-table th, .data-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: #fafafa; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.data-table tbody tr:nth-child(even) { background: #fafafa; }
.data-table tbody tr:hover { background: #e6f7ff; }
.data-table small { color: var(--text-muted); }

/* ========== 分页 ========== */
.pagination {
  display: flex; align-items: center; gap: 8px; padding: 16px 0; justify-content: center;
}
.pagination-info { margin-right: 16px; color: var(--text-secondary); }
.page-item {
  display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px;
  padding: 0 8px; border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; cursor: pointer; transition: all 0.2s; font-size: 14px;
}
.page-item:hover { color: var(--primary); border-color: var(--primary); }
.page-item.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-item.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.ellipsis { padding: 0 4px; color: var(--text-muted); }
.page-size-select { padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; margin-left: 8px; }

/* ========== 标签 ========== */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; line-height: 1.6;
}
.tag-success { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.tag-danger { background: #fff2f0; color: #ff4d4f; border: 1px solid #ffccc7; }
.tag-primary { background: #e6f7ff; color: #1890ff; border: 1px solid #91d5ff; }
.tag-warning { background: #fffbe6; color: #faad14; border: 1px solid #ffe58f; }
.tag-default { background: #fafafa; color: #999; border: 1px solid #d9d9d9; }

/* ========== 在线状态 ========== */
.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.online-dot.online { background: var(--success); }
.online-dot.offline { background: #d9d9d9; }

/* ========== 搜索栏 ========== */
.search-bar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
  background: var(--bg-white); padding: 16px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.search-bar .form-input { width: 220px; }
.search-bar .sms-available-input { width: 110px; }
.search-bar .form-select { width: 140px; }

/* ========== 页面头部 ========== */
.page-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
}
.page-header h2 { font-size: 20px; font-weight: 600; }
.page-actions { display: flex; gap: 8px; }

/* ========== 链接按钮 ========== */
.link-btn { color: var(--primary); cursor: pointer; margin-right: 12px; }
.link-btn:hover { color: var(--primary-hover); text-decoration: underline; }
.link-btn.disabled { color: var(--text-muted); cursor: not-allowed; pointer-events: none; }
.link-btn.disabled:hover { color: var(--text-muted); text-decoration: none; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-muted); }

/* ========== 空状态 ========== */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--text-muted); background: var(--bg-white);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ========== 加载状态 ========== */
.loading {
  text-align: center; padding: 48px; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.loading-spinner {
  display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== 消息提示 ========== */
#message-container {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 10000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.message {
  padding: 10px 24px; border-radius: var(--radius); color: #fff; font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); pointer-events: auto; animation: slideIn 0.3s;
  min-width: 200px; text-align: center;
}
.message-success { background: var(--success); }
.message-error { background: var(--danger); }
.message-warning { background: var(--warning); }
.message-info { background: var(--primary); }
.message.fade-out { animation: fadeOut 0.3s forwards; }
@keyframes slideIn { from { transform: translateY(-20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateY(-10px); } }

/* ========== 模态框 ========== */
#modal-container {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 9000;
  pointer-events: none;
}
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s; pointer-events: auto;
}
.modal-overlay.fade-out { animation: fadeOut 0.2s forwards; }
.modal {
  background: var(--bg-white); border-radius: 8px; box-shadow: 0 6px 30px rgba(0,0,0,0.2);
  max-height: 85vh; display: flex; flex-direction: column; animation: modalIn 0.2s;
}
.modal-sm { width: 420px; }
.modal-md { width: 560px; }
.modal-lg { width: 720px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 24px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 600; margin: 0; }
.modal-close {
  background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 4px;
}
.modal-close:hover { background: #f0f0f0; color: var(--text); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 12px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ========== 详情 ========== */
.detail-section { margin-bottom: 20px; }
.detail-section:last-child { margin-bottom: 0; }
.section-title { font-size: 15px; font-weight: 600; color: var(--text); padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.detail-row { display: flex; padding: 8px 0; border-bottom: 1px dashed #f0f0f0; }
.detail-label { width: 120px; flex-shrink: 0; color: var(--text-secondary); }
.detail-value { flex: 1; color: var(--text); word-break: break-all; }
.detail-actions { padding-top: 16px; border-top: 1px solid var(--border); display: flex; gap: 12px; }

/* ========== 登录页 ========== */
.login-page {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
  width: 400px; background: var(--bg-white); border-radius: 12px; padding: 48px 40px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.login-title { text-align: center; font-size: 24px; color: var(--text); margin-bottom: 32px; }
.login-card .form-input { height: 44px; font-size: 15px; }
.login-card .btn-block { height: 44px; font-size: 16px; margin-top: 8px; }

/* ========== 仪表盘 ========== */
.dashboard-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-white); border-radius: var(--radius); padding: 20px 24px;
  display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow);
}
.stat-icon { font-size: 32px; }
.stat-info { flex: 1; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-title { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.dashboard-charts { margin-bottom: 24px; }
.chart-card {
  background: var(--bg-white); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.chart-card h3 { font-size: 15px; margin-bottom: 16px; }
.chart-card canvas { width: 100% !important; height: auto !important; }

.dashboard-lists { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.list-card {
  background: var(--bg-white); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.list-card h3 { font-size: 15px; margin-bottom: 12px; }
.simple-list .list-item {
  display: flex; align-items: center; padding: 8px 0; border-bottom: 1px solid #f5f5f5; gap: 12px;
}
.simple-list .list-item:last-child { border-bottom: none; }
.item-title { font-weight: 500; min-width: 100px; }
.item-desc { color: var(--text-secondary); flex: 1; }
.item-time { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* ========== Tab ========== */
.tabs { display: flex; gap: 0; margin-bottom: 20px; background: var(--bg-white); border-radius: var(--radius) var(--radius) 0 0; border-bottom: 2px solid var(--border); box-shadow: var(--shadow); }
.tab-btn {
  padding: 12px 24px; border: none; background: none; cursor: pointer; font-size: 14px;
  color: var(--text-secondary); position: relative; transition: color 0.2s;
}
.tab-btn.active { color: var(--primary); font-weight: 600; }
.tab-btn.active::after {
  content: ''; position: absolute; bottom: -2px; left: 0; right: 0; height: 2px; background: var(--primary);
}
.tab-content { display: none; background: var(--bg-white); padding: 24px; border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); }
.tab-content.active { display: block; }
.tab-content h3 { font-size: 15px; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ========== 缩略图 ========== */
.thumb { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; }

/* ========== 协议内容 ========== */
.agreement-content { max-height: 60vh; overflow-y: auto; padding: 16px; background: #fafafa; border-radius: var(--radius); line-height: 1.8; }
.agreement-content h2 { font-size: 18px; margin: 16px 0 8px; }
.agreement-content h3 { font-size: 16px; margin: 14px 0 6px; }
.agreement-content h4 { font-size: 15px; margin: 12px 0 4px; }

/* ========== Markdown 预览 ========== */
.markdown-preview {
  line-height: 1.8;
  color: var(--text);
  word-break: break-word;
}
.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4 {
  margin: 18px 0 10px;
  font-weight: 600;
  line-height: 1.4;
}
.markdown-preview h1 { font-size: 22px; }
.markdown-preview h2 { font-size: 19px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.markdown-preview h3 { font-size: 17px; }
.markdown-preview h4 { font-size: 15px; }
.markdown-preview p { margin: 8px 0; }
.markdown-preview ul { margin: 8px 0 8px 22px; }
.markdown-preview li { margin: 4px 0; }
.markdown-preview pre {
  margin: 12px 0;
  padding: 12px;
  overflow-x: auto;
  background: #f5f5f5;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.markdown-preview code {
  font-family: Consolas, Monaco, 'Courier New', monospace;
  background: #f5f5f5;
  border-radius: 3px;
  padding: 2px 4px;
  font-size: 13px;
}
.markdown-preview pre code {
  display: block;
  padding: 0;
  background: transparent;
}

/* ========== 响应式 ========== */
@media (max-width: 1200px) {
  .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
  .dashboard-lists { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .dashboard-stats { grid-template-columns: 1fr; }
  .search-bar { flex-direction: column; align-items: stretch; }
  .search-bar .form-input, .search-bar .form-select { width: 100%; }
  .modal { margin: 16px; max-width: calc(100vw - 32px); }
  .modal-sm, .modal-md, .modal-lg { width: auto; }
}

/* ========== 记录查询页面 ========== */
.search-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.search-bar .date-separator {
  color: var(--text-secondary);
  padding: 0 4px;
}

/* Tab 样式补充 */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab-btn {
  padding: 12px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  position: relative;
  transition: color 0.2s;
}

.tab-btn:hover {
  color: var(--primary);
}

.tab-btn.active {
  color: var(--primary);
  font-weight: 500;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
}

/* ========== 文件上传拖拽区 ========== */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafafa;
  margin-bottom: 16px;
}
.upload-zone:hover {
  border-color: var(--primary);
  background: #f0f7ff;
}
.upload-zone.dragover {
  border-color: var(--primary);
  background: #e6f7ff;
  box-shadow: 0 0 0 3px rgba(24,144,255,0.15);
}
.upload-zone-icon {
  font-size: 36px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.upload-zone-text {
  color: var(--text-secondary);
  font-size: 14px;
}
.upload-zone-hint {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}
.cert-drop-zone { margin-bottom: 12px; }
.cert-textarea { min-height: 180px; font-family: Consolas, Monaco, 'Courier New', monospace; }
.upload-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: #f5f5f5;
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.upload-preview img {
  max-width: 120px;
  max-height: 80px;
  object-fit: contain;
  border-radius: 4px;
}
.upload-preview-info {
  flex: 1;
  min-width: 0;
}
.upload-preview-name {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upload-preview-size {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.upload-preview-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}
.upload-preview-remove:hover {
  color: var(--danger);
}
.upload-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}
.upload-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ========== 短信管理 ========== */
.sms-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  background: var(--bg-white);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.sms-stats div {
  color: var(--text-secondary);
}
.sms-stats strong {
  color: var(--text);
  font-size: 20px;
}
.sms-price-editor {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.sms-price-editor label {
  color: var(--text-secondary);
}
.sms-price-editor .form-input {
  width: 120px;
}
.sms-price-panel {
  margin-bottom: 16px;
}
.sms-price-logs {
  margin-bottom: 16px;
}
.sms-user-picker { position: relative; }
.sms-user-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: 66px;
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}
.sms-user-option {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.sms-user-option:last-child { border-bottom: 0; }
.sms-user-option:hover { background: #f5f8ff; }
.sms-user-option strong { display: block; color: var(--text); font-size: 14px; line-height: 1.4; }
.sms-user-option span, .sms-user-empty, .sms-user-hint { color: var(--text-muted); font-size: 12px; line-height: 1.5; }
.sms-user-empty { padding: 10px 12px; }
.sms-user-hint { margin-top: 6px; }
.sms-trend {
  margin-top: 16px;
}
.trend-bars {
  height: 110px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding: 12px 4px;
}
.trend-bar {
  flex: 1;
  min-width: 4px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
  opacity: 0.75;
}
.trend-bar:hover {
  opacity: 1;
}

.log-detail-line {
  max-width: 420px;
  white-space: normal;
  word-break: break-word;
  line-height: 1.5;
}
