/* ============================================================
   Task Manager — Styles
   ============================================================ */

:root {
  --bg: #f0f2f5;
  --card: #ffffff;
  --primary: #4f6ef7;
  --primary-hover: #3b5de7;
  --primary-light: #eef1ff;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --text: #1e293b;
  --text-dim: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Top Bar
   ============================================================ */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 52px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  border: none;
  background: none;
  padding: 4px 0;
}

.topbar-logo svg { width: 24px; height: 24px; }

.topbar-center {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Search */
.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  gap: 8px;
}

.search-box input {
  border: none;
  background: none;
  outline: none;
  font-size: 0.85rem;
  color: var(--text);
  width: 100%;
}

.search-box input::placeholder { color: var(--text-muted); }
.search-box svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }

/* ============================================================
   Tabs
   ============================================================ */

.tabs {
  display: flex;
  gap: 0;
  padding: 0 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 52px;
  z-index: 99;
}

.tab {
  padding: 12px 20px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-count {
  display: inline-block;
  margin-left: 6px;
  background: var(--bg);
  color: var(--text-dim);
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}

/* ============================================================
   Content Area
   ============================================================ */

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px;
}

/* ============================================================
   Home — filters bar
   ============================================================ */

.filters-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 5px 14px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ============================================================
   Card List
   ============================================================ */

.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  position: relative;
}

.card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.card-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.card-main {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  word-break: break-word;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-status {
  &.todo, &.open { background: #e2e8f0; color: #475569; }
  &.in_progress { background: #dbeafe; color: #2563eb; }
  &.done { background: var(--success-light); color: #059669; }
  &.resolved { background: var(--success-light); color: #059669; }
  &.wont_fix { background: #f1f5f9; color: #64748b; }
}

.badge-priority {
  &.low { background: #f1f5f9; color: #64748b; }
  &.medium { background: #fef9c3; color: #a16207; }
  &.high { background: #fed7aa; color: #c2410c; }
  &.urgent { background: #fecaca; color: #b91c1c; }
}

.badge-severity {
  &.low { background: #f1f5f9; color: #64748b; }
  &.medium { background: #fef9c3; color: #a16207; }
  &.high { background: #fed7aa; color: #c2410c; }
  &.critical { background: #fecaca; color: #b91c1c; }
}

.tag {
  display: inline-block;
  padding: 1px 7px;
  font-size: 0.7rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
}

.due-date {
  font-size: 0.72rem;
  color: var(--text-muted);

  &.overdue { color: var(--danger); font-weight: 600; }
}

.link-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 3px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; }

/* ============================================================
   Detail Page
   ============================================================ */

.detail {
  max-width: 780px;
  margin: 0 auto;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.detail-header-left {
  flex: 1;
  min-width: 0;
}

.detail-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 6px;
  word-break: break-word;
}

.detail-id {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
  margin-bottom: 12px;
}

.detail-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Sections */
.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 24px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-body { }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.info-item { }
.info-label { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 2px; }
.info-value { font-size: 0.88rem; font-weight: 500; }

/* Description */
.desc-text {
  font-size: 0.88rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

.desc-empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.85rem;
}

/* Linked items */
.linked-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.linked-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}

.linked-item:hover { background: var(--primary-light); }

.linked-item-title {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
}

.linked-item-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 1.1rem;
  border-radius: 4px;
  line-height: 1;
}

.linked-item-remove:hover {
  background: var(--danger-light);
  color: var(--danger);
}

/* Comments */
.comment {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.comment:last-child { border-bottom: none; }

.comment-content {
  font-size: 0.87rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.comment-form {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.comment-form textarea {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
  min-height: 36px;
  max-height: 120px;
}

.comment-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  font-size: 0.84rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-outline {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-danger-outline {
  background: var(--card);
  color: var(--danger);
  border: 1px solid var(--border);
}
.btn-danger-outline:hover { background: var(--danger-light); border-color: var(--danger); }

.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-icon {
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text-dim);
  cursor: pointer;
  margin-bottom: 16px;
}
.btn-back:hover { color: var(--primary); border-color: var(--primary); }

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s;
}

.modal {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  animation: slideUp 0.2s;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1rem; font-weight: 700; }

.modal-body { padding: 16px 20px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.form-group {
  margin-bottom: 14px;
}

.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 38px;
  align-items: center;
  cursor: text;
}

.tag-input-wrap:focus-within { border-color: var(--primary); }

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  border-radius: 4px;
  font-weight: 500;
}

.tag-pill-remove {
  cursor: pointer;
  font-weight: 700;
  opacity: 0.6;
}

.tag-pill-remove:hover { opacity: 1; }

.tag-input {
  border: none;
  outline: none;
  font-size: 0.82rem;
  flex: 1;
  min-width: 80px;
  padding: 2px 0;
  background: none;
  color: var(--text);
  font-family: inherit;
}

/* ============================================================
   Link Modal — search list
   ============================================================ */

.link-search-list {
  max-height: 300px;
  overflow-y: auto;
  margin-top: 8px;
}

.link-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.link-search-item:hover { background: var(--bg); }

.link-search-item.selected {
  background: var(--primary-light);
}

/* ============================================================
   Animations
   ============================================================ */

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 300;
  animation: slideUp 0.2s;
  box-shadow: var(--shadow-md);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 640px) {
  .content { padding: 12px 12px; }
  .topbar { padding: 0 12px; }
  .tabs { padding: 0 12px; }
  .card { padding: 12px 14px; }
  .detail-header { flex-direction: column; }
  .detail-actions { width: 100%; justify-content: flex-end; }
  .info-grid { grid-template-columns: 1fr; }
}
