/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #0f1117;
  --bg-sidebar: #16181f;
  --bg-card:    #1e2130;
  --bg-hover:   #252840;
  --border:     #2e3250;
  --accent:     #6c8aff;
  --accent-dim: #3a4a99;
  --green:      #4caf88;
  --orange:     #f0a060;
  --red:        #e05555;
  --text:       #d4d8f0;
  --text-muted: #7880a8;
  --text-dim:   #454a6a;
  --radius:     8px;
  --shadow:     0 2px 12px rgba(0,0,0,.4);
}

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

/* ── Layout ───────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
}

#sidebar {
  width: 240px;
  min-width: 200px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#main {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar-header {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
}
.logo { font-size: 20px; }
.logo-text { color: var(--text); }

#project-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.project-item {
  display: flex;
  flex-direction: column;
  padding: 10px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.1s, border-color 0.1s;
  user-select: none;
}
.project-item:hover { background: var(--bg-hover); }
.project-item.active {
  background: var(--bg-hover);
  border-left-color: var(--accent);
}

.project-name {
  font-weight: 500;
  color: var(--text);
}
.project-badges {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
}
.badge-approved { background: #1a3a28; color: var(--green); }
.badge-backlog  { background: #2a2010; color: var(--orange); }
.badge-queue    { background: #1a1e3a; color: var(--accent); }
.badge-done     { background: #1a1a2a; color: var(--text-muted); }
.badge-blocked  { background: #2a1010; color: var(--red); }
.badge-worker   { background: #1a2a10; color: #8be06e; animation: pulse-badge 2s infinite; }
@keyframes pulse-badge { 0%,100% { opacity: 1; } 50% { opacity: 0.55; } }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-sm {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 2px solid rgba(139, 224, 110, 0.25);
  border-top-color: #8be06e;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin-left: 7px;
  vertical-align: middle;
  flex-shrink: 0;
}
.worker-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(139, 224, 110, 0.25);
  border-top-color: #8be06e;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

/* ── Welcome ──────────────────────────────────────────────────────────────── */
.welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}
.welcome-inner { text-align: center; color: var(--text-muted); }
.welcome-inner h1 { font-size: 28px; color: var(--text); margin-bottom: 8px; }

/* ── Project view ─────────────────────────────────────────────────────────── */
.project-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.project-header h2 {
  font-size: 22px;
  font-weight: 600;
}
.header-actions { display: flex; gap: 8px; }

/* ── Worker banner ────────────────────────────────────────────────────────── */
.worker-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1a2a10;
  border: 1px solid #3a6a28;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 13px;
  color: #8be06e;
  margin-bottom: 20px;
}

/* ── Task sections ────────────────────────────────────────────────────────── */
#task-sections {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.task-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.section-header .section-count {
  font-weight: 500;
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}

.task-list { list-style: none; }

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.task-item:last-child { border-bottom: none; }
.task-item:hover { background: var(--bg-hover); }
.task-item.done { opacity: 0.45; }

.task-check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}
.task-check[disabled] { cursor: default; }

.task-text {
  flex: 1;
  word-break: break-word;
}
.task-item.done .task-text { text-decoration: line-through; color: var(--text-muted); }

.task-inprogress { background: #151e10; }
.task-inprogress:hover { background: #1c2a15 !important; }
.inprogress-badge {
  display: inline-block;
  background: #1a3a10;
  color: #8be06e;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 600;
  flex-shrink: 0;
  animation: pulse-badge 2s infinite;
}

.blocked-tag {
  display: inline-block;
  background: #2a1010;
  color: var(--red);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 4px;
  font-weight: 600;
}

.task-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.1s;
}
.task-item:hover .task-actions { opacity: 1; }

.btn-tiny {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}
.btn-tiny:hover { background: var(--bg-hover); color: var(--text); }
.btn-tiny.approve { border-color: var(--accent-dim); color: var(--accent); }
.btn-tiny.approve:hover { background: var(--accent-dim); color: #fff; }
.btn-tiny.edit { border-color: #3a3050; color: var(--text-muted); }
.btn-tiny.edit:hover { background: #2a2040; color: var(--text); }

/* ── Completed section ────────────────────────────────────────────────────── */
.section-header.collapsible { cursor: pointer; user-select: none; }
.section-header.collapsible:hover { background: var(--bg-hover); }

.completed-date-header {
  padding: 6px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #8099ff; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.btn-run {
  background: #1a3a28;
  border: 1px solid var(--green);
  color: var(--green);
}
.btn-run:hover:not(:disabled) { background: #224d35; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 480px;
  max-width: 95vw;
  box-shadow: var(--shadow);
}
.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: 15px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-body { padding: 16px 20px; }
.modal-hint { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }
.modal-body textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
}
.modal-body textarea:focus { border-color: var(--accent); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slide-in 0.2s ease;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } }

/* ── Loading / error ──────────────────────────────────────────────────────── */
.loading, .error {
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
}
.error { color: var(--red); }

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

@media (max-width: 600px) {
  #sidebar { width: 180px; min-width: 160px; }
  #main { padding: 16px 12px; }
}
