/* Azure-DevOps-inspired theme */

:root {
  --azure: #0078d4;
  --azure-dark: #106ebe;
  --ink: #201f1e;
  --ink-soft: #605e5c;
  --line: #edebe9;
  --rail: #f3f2f1;
  --hover: #f3f2f1;
  /* ADO work item type colors */
  --t-epic: #ff7b00;
  --t-feature: #773b93;
  --t-story: #009ccc;
  --t-bug: #cc293d;
  --t-issue: #b4009e;
  --t-task: #f2cb1d;
  /* ADO state colors */
  --s-new: #b2b2b2;
  --s-active: #007acc;
  --s-resolved: #ff9d00;
  --s-closed: #339933;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
}

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

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 48px;
  padding: 0 1rem;
  background: var(--azure);
  color: #fff;
}
.topbar .brand { font-size: 15px; font-weight: 600; color: #fff; white-space: nowrap; }
.topbar .brand:hover { text-decoration: none; }
.topbar-search { flex: 1; max-width: 420px; margin: 0; }
.topbar-search input {
  width: 100%;
  height: 30px;
  border: none;
  border-radius: 2px;
  padding: 0 10px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.9);
}
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.topbar-user form { margin: 0; display: inline; }
.topbar-user button {
  background: transparent; border: 1px solid rgba(255,255,255,0.6); color: #fff;
  border-radius: 2px; padding: 3px 10px; font-size: 12px; cursor: pointer;
}
.topbar-user button:hover { background: rgba(255,255,255,0.15); }

/* ---------- Shell: sidebar + content ---------- */
.shell { display: flex; min-height: calc(100vh - 48px); }
.sidenav {
  width: 200px;
  flex-shrink: 0;
  background: var(--rail);
  border-right: 1px solid var(--line);
  padding-top: 0.5rem;
}
.sidenav a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1rem;
  color: var(--ink);
  font-size: 13px;
  border-left: 3px solid transparent;
}
.sidenav a:hover { background: #e1dfdd; text-decoration: none; }
.sidenav a.active {
  border-left-color: var(--azure);
  background: #fff;
  font-weight: 600;
  color: var(--azure);
}
.sidenav .nav-icon { width: 1.1rem; text-align: center; }
.sidenav hr { border: none; border-top: 1px solid var(--line); margin: 0.5rem 0; }

.content { flex: 1; padding: 1rem 1.5rem 3rem; min-width: 0; }
.content h1 { font-size: 18px; font-weight: 600; margin: 0.3rem 0 1rem; }
.content h2 {
  font-size: 14px; font-weight: 600; margin: 1.4rem 0 0.5rem;
  color: var(--ink);
}

/* ---------- Work item type icon ---------- */
.wi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 2px;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  vertical-align: -2px;
  flex-shrink: 0;
}
.wi-icon.type-epic { background: var(--t-epic); }
.wi-icon.type-feature { background: var(--t-feature); }
.wi-icon.type-story { background: var(--t-story); }
.wi-icon.type-bug { background: var(--t-bug); }
.wi-icon.type-issue { background: var(--t-issue); }
.wi-icon.type-task { background: var(--t-task); color: var(--ink); }

/* ---------- State dot ---------- */
.state-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: -1px;
}
.state-dot.state-new { background: var(--s-new); }
.state-dot.state-active { background: var(--s-active); }
.state-dot.state-resolved { background: var(--s-resolved); }
.state-dot.state-closed { background: var(--s-closed); }

/* ---------- Avatar chip ---------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--azure);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
  text-transform: uppercase;
}
.avatar-name { margin-left: 6px; vertical-align: middle; }

/* ---------- Query grid (item list) ---------- */
.filter-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 0 0.75rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0;
}
.filter-bar select, .filter-bar input[type="search"] {
  height: 30px;
  border: 1px solid #8a8886;
  border-radius: 2px;
  padding: 0 8px;
  font-size: 13px;
  background: #fff;
}
.filter-bar input[type="search"] { min-width: 220px; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
thead th {
  text-align: left;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: 5px 10px; border-bottom: 1px solid var(--line); }
tbody tr:hover { background: var(--hover); }
td .wi-title { font-weight: 400; color: var(--ink); }
td .wi-title:hover { color: var(--azure); }

/* Inline-editable controls: invisible until hover, like ADO fields */
select.inline-edit, input.inline-edit {
  width: auto;
  max-width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 2px;
  cursor: pointer;
}
select.inline-edit:hover, input.inline-edit:hover,
select.inline-edit:focus, input.inline-edit:focus {
  border-color: #8a8886;
  background: #fff;
}
input.inline-edit { cursor: text; min-width: 3.5rem; }

.wi-title-input {
  display: block;
  width: 100%;
  max-width: none;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  margin: 0.2rem 0 0.5rem;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
}
.wi-title-input:hover { border-color: #8a8886; }
.wi-title-input:focus { outline: 2px solid var(--azure); outline-offset: -1px; background: #fff; }

/* ---------- Buttons & forms ---------- */
button, .btn {
  font-family: inherit;
  font-size: 13px;
  border-radius: 2px;
  padding: 5px 14px;
  cursor: pointer;
  border: 1px solid var(--azure);
  background: var(--azure);
  color: #fff;
}
button:hover, .btn:hover { background: var(--azure-dark); text-decoration: none; }
button.secondary, .btn.secondary {
  background: #fff; color: var(--ink); border: 1px solid #8a8886;
}
button.secondary:hover, .btn.secondary:hover { background: var(--hover); }
button.danger, .btn.danger { background: #cc293d; border-color: #cc293d; }
button.danger:hover { background: #a4263a; }

form p { margin: 0 0 0.8rem; }
form label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 3px; color: var(--ink-soft); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
select, textarea {
  font-family: inherit;
  font-size: 13px;
  width: 100%;
  max-width: 640px;
  border: 1px solid #8a8886;
  border-radius: 2px;
  padding: 6px 8px;
  background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azure); outline-offset: -1px; }
.errorlist { color: #cc293d; font-size: 12px; margin: 0 0 0.5rem; padding-left: 1rem; }

/* ---------- Work item detail (two-column form) ---------- */
.wi-header {
  border: 1px solid var(--line);
  border-left: 4px solid var(--azure);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.wi-header.type-epic { border-left-color: var(--t-epic); }
.wi-header.type-feature { border-left-color: var(--t-feature); }
.wi-header.type-story { border-left-color: var(--t-story); }
.wi-header.type-bug { border-left-color: var(--t-bug); }
.wi-header.type-issue { border-left-color: var(--t-issue); }
.wi-header.type-task { border-left-color: var(--t-task); }
.wi-header h1 { margin: 0.2rem 0 0.5rem; font-size: 17px; }
.wi-header .wi-id { color: var(--ink-soft); font-weight: 400; }
.wi-meta { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; font-size: 13px; }
.wi-meta .label { color: var(--ink-soft); font-size: 12px; margin-right: 4px; }
.wi-actions { margin-left: auto; display: flex; gap: 0.4rem; }

.wi-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.5rem; }
@media (max-width: 900px) { .wi-layout { grid-template-columns: 1fr; } }

.wi-panel {
  border: 1px solid var(--line);
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.9rem;
}
.wi-panel h2 { margin: 0 0 0.5rem; font-size: 13px; }
.wi-panel dl { margin: 0; }
.wi-panel dt { font-size: 11px; color: var(--ink-soft); margin-top: 0.5rem; }
.wi-panel dd { margin: 1px 0 0; font-size: 13px; }
.wi-panel ul { margin: 0.2rem 0; padding-left: 1.1rem; }
.wi-panel li { margin: 0.2rem 0; }

.markdown { font-size: 13px; line-height: 1.55; }
.markdown img { max-width: 100%; }
.markdown pre { background: var(--rail); padding: 0.6rem; overflow-x: auto; }
.markdown table td, .markdown table th { border: 1px solid var(--line); padding: 4px 8px; }
.markdown blockquote { border-left: 3px solid var(--line); margin-left: 0; padding-left: 0.8rem; color: var(--ink-soft); }

/* ---------- Discussion ---------- */
.comment { display: flex; gap: 0.6rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.comment .avatar { flex-shrink: 0; margin-top: 2px; }
.comment header { margin-bottom: 0.1rem; }
.comment header small { color: var(--ink-soft); margin-left: 0.5rem; }
.comment .markdown p:first-child { margin-top: 0.2rem; }
.comment .markdown p:last-child { margin-bottom: 0; }

/* ---------- Watch / small buttons ---------- */
.watch-btn { padding: 3px 10px; font-size: 12px; }
.link-btn {
  background: none; border: none; color: #cc293d;
  cursor: pointer; padding: 0 4px; font-size: 12px; width: auto; display: inline;
}
.link-btn:hover { background: none; text-decoration: underline; }

/* ---------- Tree / backlog ---------- */
.backlog-header { display: flex; align-items: baseline; gap: 1.25rem; flex-wrap: wrap; }
.visit-history { display: flex; align-items: center; gap: 4px; }
.visit-history .avatar { width: 20px; height: 20px; font-size: 10px; }
.visit-history small { margin-left: 6px; color: var(--ink-soft); }

.tree-node { margin: 0; }
.tree-node summary {
  list-style: none;
  cursor: pointer;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  overflow: hidden;
}
.tree-node summary::before { content: "⌄"; color: var(--ink-soft); width: 0.9rem; flex-shrink: 0; }
.tree-node[open] > summary::before { content: "⌄"; }
.tree-node:not([open]) > summary::before { content: "›"; }
.tree-node.leaf > summary::before { content: " "; }
.tree-node summary:hover { background: var(--hover); }
.tree-node summary small { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; }
.tree-children { margin-left: 1.4rem; }
.add-child { font-size: 11px; margin-left: auto; padding-left: 1rem; visibility: hidden; }
.tree-node summary:hover .add-child { visibility: visible; }

/* ---------- Messages ---------- */
.message {
  padding: 0.5rem 0.9rem;
  margin-bottom: 0.8rem;
  font-size: 13px;
  border: 1px solid var(--line);
  border-left-width: 4px;
}
.message.success { border-left-color: var(--s-closed); background: #f4faf4; }
.message.error { border-left-color: #cc293d; background: #fdf3f4; }

/* ---------- Login ---------- */
.login-card {
  max-width: 26rem;
  margin: 5rem auto;
  border: 1px solid var(--line);
  border-top: 4px solid var(--azure);
  padding: 1.5rem 2rem 2rem;
}
.login-card h1 { font-size: 18px; }

fieldset[role="group"] { border: none; padding: 0; margin: 0.4rem 0; display: flex; gap: 0.5rem; }
