/**
 * admin.css - 后台管理样式
 * 与前台 main.css 配合使用，覆盖后台管理界面样式
 */

/* ========== Login Page ========== */
.admin-login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 20px;
}
.admin-login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  text-align: center;
}
.admin-login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.admin-login-card h2 { font-size: 24px; font-weight: 700; color: #1e293b; margin-bottom: 8px; }
.admin-login-hint { font-size: 14px; color: #64748b; margin-bottom: 24px; }
.admin-login-form { text-align: left; }
.admin-login-error { color: #ef4444; font-size: 13px; min-height: 20px; margin-bottom: 12px; }
.admin-login-tip { font-size: 12px; color: #94a3b8; margin-top: 20px; }
.admin-login-tip code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ========== Admin Layout ========== */
.admin-layout {
  display: flex;
  min-height: 100vh;
  background: #f0f2f5;
}

/* ========== Sidebar ========== */
.admin-sidebar {
  width: 240px;
  background: #1e293b;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  transition: transform 0.3s ease;
}
.admin-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 24px;
  border-bottom: 1px solid #334155;
}
.admin-logo-icon { font-size: 24px; }
.admin-logo-text { font-size: 18px; font-weight: 700; color: #fff; }
.admin-menu { flex: 1; padding: 16px 12px; overflow-y: auto; }
.admin-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 4px;
  transition: all 0.2s ease;
  text-decoration: none;
}
.admin-menu-item:hover { background: #334155; color: #fff; }
.admin-menu-item.active { background: #2563eb; color: #fff; }
.menu-icon { font-size: 18px; width: 20px; text-align: center; }
.admin-sidebar-footer { padding: 16px 12px; border-top: 1px solid #334155; }
.admin-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  color: #64748b;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}
.admin-link:hover { background: #334155; color: #fff; }

/* ========== Main Area ========== */
.admin-main {
  flex: 1;
  margin-left: 240px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.admin-topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.admin-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #1e293b;
}
.admin-topbar-title { font-size: 18px; font-weight: 600; color: #1e293b; }
.admin-content { flex: 1; padding: 24px; overflow-y: auto; }

/* ========== Panel ========== */
.admin-panel {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.panel-header h3 { font-size: 18px; font-weight: 600; color: #1e293b; }

/* ========== Stat Cards ========== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  border-left: 4px solid;
}
.stat-blue { border-left-color: #3b82f6; }
.stat-green { border-left-color: #10b981; }
.stat-orange { border-left-color: #f59e0b; }
.stat-red { border-left-color: #ef4444; }
.stat-icon { font-size: 32px; }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: 700; color: #1e293b; line-height: 1.2; }
.stat-label { font-size: 13px; color: #64748b; }

/* ========== Table ========== */
.table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th {
  text-align: left;
  padding: 12px 16px;
  background: #f8fafc;
  color: #64748b;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}
.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}
.admin-table tbody tr:hover { background: #f8fafc; }
.td-title { min-width: 200px; }
.article-title-text { font-weight: 500; display: block; }
.article-summary-text {
  font-size: 12px;
  color: #94a3b8;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.td-date { font-size: 13px; color: #64748b; white-space: nowrap; }
.td-actions { white-space: nowrap; }

/* ========== Status Badges ========== */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.status-published { background: #d1fae5; color: #059669; }
.status-draft { background: #fef3c7; color: #d97706; }
.cat-tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  color: #fff;
  font-weight: 500;
}
.featured-star { font-size: 16px; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; color: #fff; }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* ========== Icon Buttons ========== */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  transition: all 0.2s ease;
  margin-right: 4px;
}
.btn-edit:hover { background: #2563eb; color: #fff; border-color: #2563eb; }
.btn-delete:hover { background: #ef4444; color: #fff; border-color: #ef4444; }
.btn-save:hover { background: #10b981; color: #fff; border-color: #10b981; }

/* ========== Forms ========== */
.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}
.form-row-inline { align-items: center; }
.form-group { flex: 1; }
.form-group-main { flex: 2; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  margin-bottom: 6px;
}
.admin-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 14px;
  color: #1e293b;
  background: #fff;
  outline: none;
  transition: border-color 0.2s ease;
  font-family: inherit;
}
.admin-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.admin-input-search { max-width: 240px; }
.admin-input-select { max-width: 160px; cursor: pointer; }
.admin-textarea-code { font-family: "SF Mono", "Consolas", "Monaco", monospace; font-size: 13px; line-height: 1.6; }
.admin-color-input { width: 60px; height: 38px; padding: 4px; cursor: pointer; }
.edit-inline { padding: 6px 8px; font-size: 13px; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; }
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #1e293b;
}
.checkbox-label input { width: 18px; height: 18px; cursor: pointer; }

/* ========== Filter Bar ========== */
.admin-filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ========== Inline Form Card ========== */
.inline-form-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}

/* ========== Article Editor ========== */
.article-editor { max-width: 800px; }

/* ========== Quick Actions ========== */
.quick-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.quick-action-btn {
  padding: 12px 24px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #1e293b;
  transition: all 0.2s ease;
}
.quick-action-btn:hover { background: #2563eb; color: #fff; border-color: #2563eb; }

/* ========== Ads Grid ========== */
.admin-hint { font-size: 13px; color: #64748b; margin-bottom: 16px; }
.ads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.ad-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ad-card.inactive { opacity: 0.5; }
.ad-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.ad-card-name { font-size: 15px; font-weight: 600; color: #1e293b; display: block; }
.ad-card-pos { font-size: 12px; color: #64748b; }
.ad-card-preview {
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 16px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.ad-preview-img { max-width: 100%; max-height: 100px; border-radius: 4px; }
.ad-preview-text { font-size: 13px; color: #64748b; text-align: center; }
.ad-preview-code { font-size: 13px; color: #64748b; font-style: italic; }
.ad-card-actions { display: flex; gap: 8px; }

/* ========== Switch Toggle ========== */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #cbd5e1;
  border-radius: 12px;
  transition: 0.3s;
}
.slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.3s;
}
.switch input:checked + .slider { background: #10b981; }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* ========== Data Management ========== */
.data-section {
  padding: 20px 0;
  border-bottom: 1px solid #f1f5f9;
}
.data-section:last-child { border-bottom: none; }
.data-section h4 { font-size: 16px; font-weight: 600; margin-bottom: 12px; color: #1e293b; }
.data-danger h4 { color: #ef4444; }
.admin-file-input {
  margin-bottom: 12px;
  font-size: 14px;
}
.admin-divider {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 24px 0;
}

/* ========== Toast ========== */
.admin-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.admin-toast.show { opacity: 1; transform: translateY(0); }
.admin-toast.success { background: #10b981; color: #fff; }
.admin-toast.error { background: #ef4444; color: #fff; }
.admin-toast.info { background: #2563eb; color: #fff; }

/* ========== Responsive ========== */
@media (max-width: 1024px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .ads-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.mobile-open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .admin-menu-toggle { display: block; }
  .admin-content { padding: 16px; }
  .stat-cards { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 12px; }
  .form-group, .form-group-main { flex: 1; }
  .admin-panel { padding: 16px; }
  .panel-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .admin-filter-bar { flex-direction: column; }
  .admin-input-search, .admin-input-select { max-width: 100%; }
  .admin-table { font-size: 13px; }
  .admin-table th, .admin-table td { padding: 8px 10px; }
  .article-editor { max-width: 100%; }
}

@media (max-width: 480px) {
  .stat-card { padding: 16px; }
  .stat-icon { font-size: 24px; }
  .stat-value { font-size: 22px; }
}
