/* 从 public_site/site.css 复用变量 */
:root {
  --bg: #f4f5f7;
  --card-bg: #fff;
  --border: #e2e3e8;
  --accent: #0d6efd;
  --text: #1f2a37;
  --muted: #6b7280;
  --error: #dc3545;
}

body {
  font-family: "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

/* ========== 登录页布局 ========== */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-container {
  background: var(--card-bg);
  border-radius: 18px;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
  color: var(--text);
}

.login-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}

.form-group input {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 1rem;
  transition: border-color 0.15s ease;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group input.error {
  border-color: var(--error);
}

.field-error {
  font-size: 0.85rem;
  color: var(--error);
}

.error-message {
  background: #fee;
  color: var(--error);
  padding: 0.75rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

/* ========== 通用组件 ========== */

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.admin-header h1 {
  margin: 0 0 0.25rem 0;
  font-size: 1.5rem;
}

.admin-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-secondary,
.btn-link {
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1.2rem;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  display: inline-block;
}

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

.btn-link {
  background: transparent;
  color: var(--accent);
  padding: 0.4rem 0.8rem;
}

.btn-primary:hover,
.btn-secondary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 1.5rem;
  margin: 0 1.5rem 1.5rem;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.card h2 {
  margin: 0 0 1rem 0;
  font-size: 1.2rem;
}

.card label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.card input[type="text"],
.card textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.15s ease;
}

.card input[type="text"]:focus,
.card textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.card textarea {
  resize: vertical;
  min-height: 100px;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ========== 列表页 ========== */

.filters-section {
  margin-bottom: 1.5rem;
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 150px;
}

.filter-group label {
  font-weight: 600;
  font-size: 0.9rem;
}

.filter-group select,
.filter-group input[type="text"] {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  font-size: 0.95rem;
}

.search-group {
  flex: 1;
  min-width: 200px;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

th,
td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.thumbnail {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
}

.thumbnail-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-draft {
  background: #f0f0f0;
  color: #666;
}

.status-published {
  background: #d4edda;
  color: #155724;
}

.status-offline {
  background: #f8d7da;
  color: #721c24;
}

.tag-chip {
  display: inline-block;
  background: #eef4ff;
  color: #3451a3;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  margin-right: 0.25rem;
}

.actions-cell {
  white-space: nowrap;
  min-width: 160px;
}

.btn-link {
  display: inline-block;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.btn-quick-action {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
  vertical-align: middle;
}

.loading-state {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

.pagination-wrapper {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
}

.pagination {
  display: flex;
  gap: 0.5rem;
}

.pagination button {
  min-width: 40px;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.pagination button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

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

/* ========== 编辑页 ========== */

.upload-button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 1rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  margin-bottom: 0.75rem;
  text-align: center;
  min-height: 48px; /* 移动端最小点击区域 */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.upload-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

.upload-button:active {
  transform: translateY(0);
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.asset-card {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  position: relative;
  cursor: grab;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.asset-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.15);
}

.asset-card:active {
  cursor: grabbing;
}

.asset-thumbnail {
  width: 100%;
  height: 150px;
  border-radius: 8px;
  object-fit: cover;
  background: #fafafa;
}

.asset-caption {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  font-size: 0.9rem;
}

.asset-actions {
  display: flex;
  gap: 0.35rem;
}

.btn-sm,
.btn-sm-primary,
.btn-sm-secondary,
.btn-sm-danger {
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  cursor: pointer;
  flex: 1;
}

.btn-sm-primary {
  background: var(--accent);
  color: #fff;
}

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

.btn-sm-danger {
  background: var(--error);
  color: #fff;
}

.drag-handle {
  display: none; /* 整个卡片可拖拽，不需要单独的手柄 */
}

.tag-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tag-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inline-tag-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.75rem;
  background: #f9f9f9;
  border-radius: 8px;
}

.inline-tag-form input[type="text"] {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
}

.inline-tag-form input[type="color"] {
  width: 50px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.tag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-option {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.tag-option:hover {
  background: #f5f5f5;
}

.actions-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* ========== Toast 通知 ========== */

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--accent);
  color: #fff;
  padding: 0.85rem 1.5rem;
  border-radius: 10px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  animation: slideIn 0.3s ease;
}

.toast.error {
  background: var(--error);
}

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

/* ========== 响应式 ========== */

@media (max-width: 768px) {
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

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

  .filter-group,
  .search-group {
    width: 100%;
  }

  .asset-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

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

  .actions-row button {
    width: 100%;
  }

  .pagination {
    gap: 0.35rem;
  }

  .pagination button {
    min-width: 32px;
    padding: 0.4rem 0.6rem;
    font-size: 0.95rem;
  }
}
