/* 通用样式重置 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: #1E293B;
  background: #F8FAFC;
}

a {
  color: #2563EB;
  text-decoration: none;
}

/* 登录页 */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
}

.login-box {
  width: 420px;
  padding: 40px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-box h1 {
  font-size: 24px;
  margin-bottom: 8px;
  color: #1E293B;
}

.login-box .subtitle {
  color: #64748B;
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #334155;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: #2563EB;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: #2563EB;
  color: #fff;
}

.btn-primary:hover {
  background: #1D4ED8;
}

.btn-success {
  background: #10B981;
  color: #fff;
}

.btn-success:hover {
  background: #059669;
}

.btn-warning {
  background: #F59E0B;
  color: #fff;
}

.btn-warning:hover {
  background: #D97706;
}

.btn-danger {
  background: #EF4444;
  color: #fff;
}

.btn-danger:hover {
  background: #DC2626;
}

.btn-secondary {
  background: #E2E8F0;
  color: #475569;
}

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

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.error-tip {
  color: #EF4444;
  font-size: 13px;
  margin-top: 8px;
  display: none;
}

/* 后台布局 */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: #1E293B;
  color: #fff;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid #334155;
}

.sidebar-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.sidebar-header p {
  font-size: 12px;
  color: #94A3B8;
  margin-top: 4px;
}

.sidebar-menu {
  flex: 1;
  padding: 12px 0;
}

.menu-item {
  display: block;
  padding: 14px 20px;
  color: #CBD5E1;
  transition: all 0.2s;
}

.menu-item:hover,
.menu-item.active {
  background: #334155;
  color: #fff;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #334155;
  font-size: 12px;
  color: #94A3B8;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.topbar h3 {
  font-size: 18px;
  font-weight: 600;
}

.content-body {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* 卡片 */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* 工具栏 */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  gap: 8px;
}

.search-box input {
  width: 240px;
}

.filter-box {
  display: flex;
  gap: 8px;
}

.filter-box select {
  padding: 8px 12px;
  border: 1px solid #CBD5E1;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}

/* 表格 */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid #E2E8F0;
}

.data-table th {
  font-weight: 600;
  color: #64748B;
  background: #F8FAFC;
  font-size: 13px;
}

.data-table tr:hover td {
  background: #F8FAFC;
}

.data-table .cover-cell img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
}

/* 标签 */
.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.tag-published {
  background: #DBEAFE;
  color: #1D4ED8;
}

.tag-draft {
  background: #F1F5F9;
  color: #64748B;
}

.tag-top {
  background: #FEF3C7;
  color: #B45309;
  margin-left: 6px;
}

/* 操作按钮 */
.actions {
  display: flex;
  gap: 8px;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #94A3B8;
}

.empty-state p {
  margin-top: 12px;
  font-size: 14px;
}

/* 分页 */
.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.pagination button {
  padding: 6px 14px;
  border: 1px solid #CBD5E1;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination .page-info {
  color: #64748B;
}

/* 表单布局 */
.form-row {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
}

.form-col {
  flex: 1;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #334155;
}

.form-label .required {
  color: #EF4444;
  margin-left: 4px;
}

.form-textarea {
  min-height: 240px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.6;
}

.form-hint {
  font-size: 12px;
  color: #94A3B8;
  margin-top: 6px;
}

/* 封面图上传 */
.cover-uploader {
  width: 200px;
  height: 120px;
  border: 2px dashed #CBD5E1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #64748B;
  background: #F8FAFC;
  transition: all 0.2s;
  overflow: hidden;
  position: relative;
}

.cover-uploader:hover {
  border-color: #2563EB;
  color: #2563EB;
}

.cover-uploader img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-uploader .upload-text {
  text-align: center;
  font-size: 13px;
}

.cover-uploader .upload-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
}

.switch-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch {
  position: relative;
  width: 48px;
  height: 26px;
}

.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: 26px;
  transition: 0.2s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: #2563EB;
}

.switch input:checked + .slider:before {
  transform: translateX(22px);
}

/* 加载遮罩 */
.loading-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255,255,255,0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-mask.active {
  display: flex;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #E2E8F0;
  border-top-color: #2563EB;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #1E293B;
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 10000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 模态框 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  width: 420px;
  background: #fff;
  border-radius: 12px;
  padding: 24px;
}

.modal-box h4 {
  margin-bottom: 12px;
}

.modal-box p {
  color: #64748B;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* 响应式 */
@media (max-width: 768px) {
  .sidebar {
    width: 180px;
  }

  .form-row {
    flex-direction: column;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box input {
    width: 100%;
  }
}
