/* ========== 管理后台样式（复用基础变量 + 扩展）========== */
@import url('./style.css');

/* ========== 管理页整体 ========== */
.admin-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 24px;
}

.admin-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
}

.admin-header .back-link {
  font-size: 0.85rem;
  color: var(--accent);
}

/* ========== 登录面板 ========== */
.login-panel {
  max-width: 360px;
  margin: 80px auto;
  padding: 32px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.login-panel h2 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.login-panel p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.login-panel input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  margin-bottom: 12px;
  transition: border-color var(--transition);
}

.login-panel input:focus {
  border-color: var(--accent);
}

.login-panel .btn {
  width: 100%;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: #3d5ce0;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-danger {
  background: transparent;
  color: #e74c3c;
  border: 1px solid #fde2e2;
}

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

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
}

/* ========== 工具栏 ========== */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

/* ========== 分类卡片 ========== */
.cat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.cat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--hover-bg);
  border-bottom: 1px solid var(--border);
}

.cat-card-header .cat-name {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-card-header .cat-name .drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1rem;
}

.cat-card-header .cat-actions {
  display: flex;
  gap: 6px;
}

.cat-card-body {
  padding: 12px 16px;
}

/* ========== 链接列表 ========== */
.link-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.link-item:last-child {
  border-bottom: none;
}

.link-item .link-name {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 500;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-item .link-url {
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-item .link-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ========== 模态框 ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 440px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  transform: translateY(10px);
  transition: transform 0.2s;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal h3 {
  font-size: 1.05rem;
  margin-bottom: 16px;
}

.modal .form-group {
  margin-bottom: 14px;
}

.modal label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.modal input,
.modal select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--transition);
}

.modal input:focus,
.modal select:focus {
  border-color: var(--accent);
}

.modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ========== Toast ========== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  background: var(--text-primary);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  z-index: 2000;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #e74c3c;
}

/* ========== 空状态 ========== */
.admin-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ========== 响应式 ========== */
@media (max-width: 640px) {
  .admin-container {
    padding: 16px 12px 48px;
  }

  .cat-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .link-item {
    flex-wrap: wrap;
  }

  .link-item .link-url {
    max-width: 140px;
  }

  .modal {
    width: 95%;
    padding: 20px;
  }

  .toolbar {
    flex-direction: column;
  }

  .toolbar .btn {
    width: 100%;
  }
}
