/* OpenClaw Web UI — Dark Mode */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #222533;
  --border: #2e3245;
  --text: #e2e4ef;
  --text-muted: #7b7e99;
  --accent: #5b6ef5;
  --accent-hover: #7183ff;
  --danger: #f05050;
  --success: #4caf82;
  --warning: #f0a830;
  --urgent: #f05050;
  --high: #f08030;
  --medium: #5b6ef5;
  --low: #7b7e99;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── Header ── */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 0.5rem; }
.brand-icon { font-size: 1.3rem; }
.brand-name { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.3px; color: var(--text); }
.nav { display: flex; gap: 0.25rem; }
.nav-link {
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--surface2); text-decoration: none; }
.nav-link.active { color: var(--text); background: var(--surface2); }

/* ── Main ── */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 1.4rem; font-weight: 700; }
.back-link { display: block; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.25rem; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); color: var(--text); text-decoration: none; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card h3 { font-size: 0.875rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.75rem; }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.75rem; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); }
input[type="text"], input[type="date"], input[type="number"],
select, textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.45rem 0.65rem;
  font-size: 0.875rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; font-family: inherit; }
.form-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* ── Modal ── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
}
.modal.hidden { display: none; }
.modal-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 540px;
}
.modal-inner h2 { margin-bottom: 1.25rem; }

/* ── Board ── */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  align-items: start;
}
.board-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.col-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.col-title { font-weight: 600; font-size: 0.875rem; }
.col-count {
  background: var(--surface2);
  color: var(--text-muted);
  border-radius: 12px;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
}
.col-cards { padding: 0.5rem; display: flex; flex-direction: column; gap: 0.4rem; }
.col-empty { padding: 1rem; text-align: center; color: var(--text-muted); font-size: 0.8rem; }
.task-card {
  display: block;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.65rem 0.75rem;
  transition: border-color 0.15s, background 0.15s;
  text-decoration: none;
  color: var(--text);
}
.task-card:hover { border-color: var(--accent); background: #252837; text-decoration: none; color: var(--text); }
.task-title { font-size: 0.875rem; font-weight: 500; margin-bottom: 0.35rem; }
.task-meta { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.task-contexts { margin-top: 0.35rem; font-size: 0.75rem; color: var(--text-muted); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-priority-urgent { background: rgba(240,80,80,0.2); color: var(--urgent); }
.badge-priority-high { background: rgba(240,128,48,0.2); color: var(--high); }
.badge-priority-medium { background: rgba(91,110,245,0.2); color: var(--medium); }
.badge-priority-low { background: rgba(123,126,153,0.2); color: var(--low); }
.badge-date { background: rgba(91,110,245,0.15); color: var(--accent); }
.badge-area { background: rgba(255,255,255,0.07); color: var(--text-muted); }
.badge-status { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.badge-run-success { background: rgba(76,175,130,0.2); color: var(--success); }
.badge-run-failure { background: rgba(240,80,80,0.2); color: var(--danger); }
.badge-run-running { background: rgba(240,168,48,0.2); color: var(--warning); }
.badge-run-unknown { background: var(--surface2); color: var(--text-muted); }
.badge-owner-peter { background: rgba(91,110,245,0.15); color: var(--accent); }
.badge-owner-nicole { background: rgba(76,175,130,0.15); color: var(--success); }

/* ── Owner Filter ── */
.owner-filter {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.filter-btn {
  padding: 0.3rem 0.85rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  text-decoration: none;
  cursor: pointer;
}
.filter-btn:hover { background: var(--border); color: var(--text); text-decoration: none; }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Filters ── */
.filters {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filter-count { color: var(--text-muted); font-size: 0.875rem; margin-left: auto; }
.filters select { width: auto; }

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: var(--surface);
  padding: 0.65rem 0.85rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface2); }
.data-table tr.row-error td { background: rgba(240,80,80,0.05); }
.data-table tr.row-running td { background: rgba(240,168,48,0.05); }
.id-col { font-family: monospace; color: var(--text-muted); white-space: nowrap; }
.title-col { max-width: 400px; }
.mono { font-family: monospace; }
.small { font-size: 0.8rem; }
.muted { color: var(--text-muted); }
.empty-row { text-align: center; color: var(--text-muted); padding: 2rem; }
.error-text { color: var(--danger); font-family: monospace; }

/* ── Task Detail ── */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 768px) {
  .detail-layout { grid-template-columns: 1fr; }
}
.quick-status {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.4rem 0.6rem;
  font-size: 0.875rem;
  cursor: pointer;
}
.info-list { display: grid; grid-template-columns: auto 1fr; gap: 0.35rem 1rem; }
.info-list dt { color: var(--text-muted); font-size: 0.8rem; font-weight: 500; white-space: nowrap; }
.info-list dd { font-size: 0.875rem; }
.history-list { display: flex; flex-direction: column; gap: 0.5rem; }
.history-item { font-size: 0.8rem; }
.history-arrow { display: flex; align-items: center; gap: 0.35rem; }
.history-old { color: var(--text-muted); }
.arrow { color: var(--accent); }
.history-new { font-weight: 600; }
.history-meta { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.1rem; }

/* ── Hidden ── */
.hidden { display: none !important; }
