/* =====================================================
   智能任务管理系统 · 界面样式
   ===================================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #1f2937;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --danger: #dc2626;
  --high: #ef4444;
  --medium: #f59e0b;
  --low: #10b981;
  --radius: 14px;
}

html,
body {
  height: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB",
    "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.page {
  min-height: 100%;
  padding: 48px 16px;
}

.container {
  max-width: 680px;
  margin: 0 auto;
}

/* ---------- 页头 ---------- */
.app-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.logo {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.28);
}

.logo span {
  width: 14px;
  height: 7px;
  border-left: 3px solid #fff;
  border-bottom: 3px solid #fff;
  transform: rotate(-45deg) translateY(-2px);
  border-radius: 1px;
}

.app-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.subtitle {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
}

/* ---------- 添加任务表单 ---------- */
.add-form {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
}

.task-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.task-input::placeholder {
  color: var(--text-3);
}

.task-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.priority-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.priority-wrap label {
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
}

#prioritySelect {
  height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  outline: none;
}

.btn {
  height: 42px;
  padding: 0 18px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, filter 0.15s, transform 0.05s;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary:hover {
  background: var(--accent-2);
}

/* ---------- 工具栏：筛选 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 12px;
}

.filter-bar {
  display: flex;
  gap: 4px;
  background: var(--card);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.filter-btn {
  height: 32px;
  padding: 0 16px;
  border: none;
  border-radius: 9px;
  background: transparent;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  color: var(--text);
}

.filter-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.task-count {
  font-size: 13px;
  color: var(--text-2);
}

/* ---------- 任务列表 ---------- */
.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 完成状态圆圈 */
.toggle-btn {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border: 2px solid #cbd5e1;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
}

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

.toggle-btn.done {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-btn.done::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* 任务主体 */
.task-body {
  flex: 1;
  min-width: 0;
}

.task-title {
  display: block;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-all;
  transition: color 0.15s;
}

/* 已完成任务：删除线 */
.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--text-2);
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.badge {
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 600;
}

.badge.high {
  color: #b91c1c;
  background: #fee2e2;
}

.badge.medium {
  color: #b45309;
  background: #fef3c7;
}

.badge.low {
  color: #047857;
  background: #d1fae5;
}

.status {
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
}

.status.todo {
  color: #475569;
  background: #e2e8f0;
}

.status.done {
  color: #1d4ed8;
  background: #dbeafe;
}

.task-time {
  font-size: 12px;
  color: var(--text-3);
}

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

.btn-toggle {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  background: #eff6ff;
  color: var(--accent);
  border: 1px solid #bfdbfe;
}

.btn-toggle:hover {
  background: #dbeafe;
}

.btn-delete {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.btn-delete:hover {
  background: #fee2e2;
}

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 44px 0 36px;
  color: var(--text-2);
  font-size: 14px;
}

.empty-icon {
  display: block;
  margin: 0 auto 14px;
}

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(8px);
  background: #1f2937;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 10;
  max-width: 80vw;
}

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

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

/* ---------- 响应式 ---------- */
@media (max-width: 560px) {
  .page {
    padding: 24px 12px;
  }

  .add-form {
    flex-wrap: wrap;
  }

  .task-input {
    flex: 1 1 100%;
  }

  .priority-wrap {
    flex: 1;
  }

  .add-form .btn-primary {
    flex: none;
  }

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