/* ══════════════════════════════════════════════════════════════
   Component Styles
   Extracted from index.html <style> block.
   Hardcoded colours replaced with var(--token) references.
   ══════════════════════════════════════════════════════════════ */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font-body);
  background: var(--background);
  color: var(--foreground);
  line-height: 1.5;
}

/* ── Themed text utility classes ────────────────── */
.text-success { color: var(--success); }
.text-info { color: var(--info); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }
.text-muted { color: var(--muted); }
.text-primary { color: var(--primary); }

/* ── Themed background utility classes ─────────── */
.bg-success-subtle { background: var(--success-subtle); }
.bg-info-subtle { background: var(--info-subtle); }
.bg-warning-subtle { background: var(--warning-subtle); }
.bg-error-subtle { background: var(--error-subtle); }
.bg-muted-subtle { background: var(--muted-subtle); }

/* ── Button disabled states ─────────────────────── */
#btn-load-live:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Summary cards ──────────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 16px 20px;
}
.card .card-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.card .card-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--foreground);
}
.card .card-detail {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.card .delta-positive {
  color: var(--error);
}
.card .delta-negative {
  color: var(--success);
}
.card .delta-neutral {
  color: var(--muted);
}

/* ── Charts row ─────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 20px;
}
.chart-card h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--foreground);
}
.chart-card canvas {
  width: 100% !important;
  height: 300px !important;
}

/* ── Tables ─────────────────────────────────────── */
.table-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 24px;
  overflow-x: auto;
  position: relative;
}
.table-card h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--foreground);
}

/* ── Expand / compress toggle ─────────────────────────────────────── */
.card-expand-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 4px;
  background: var(--card, #fff);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted, #888);
  font-size: 16px;
  padding: 0;
  z-index: 1;
  transition: background 0.15s, color 0.15s;
}
.card-expand-btn:hover {
  background: var(--hover, #f5f5f5);
  color: var(--foreground, #333);
}
.table-card.card-expanded {
  flex: 1 0 100% !important;
  max-width: 100% !important;
}
.table-card .table-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 12px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
/* Capacity heatmap row hover — dotted outline around the whole person row group */
tbody.person-row:hover {
  outline: 1.5px dotted var(--foreground);
  outline-offset: -1px;
}
th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:hover td {
  background: var(--background);
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-added {
  background: var(--success-badge);
  color: var(--success);
}
.badge-removed {
  background: var(--error-badge);
  color: var(--error);
}
.badge-state {
  background: var(--primary-badge);
  color: var(--primary);
}
.badge-estimate {
  background: var(--warning-badge);
  color: var(--warning);
}
.badge-story {
  background: var(--primary-badge);
  color: var(--primary);
}
.badge-task {
  background: var(--warning-badge);
  color: var(--warning);
}
.badge-bug {
  background: var(--error-badge);
  color: var(--error);
}
.wi-link {
  color: var(--primary);
  text-decoration: none;
}
.wi-link:hover {
  text-decoration: underline;
}

/* ── Empty / loading / error states ─────────────── */
.state-msg {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 14px;
}
.state-msg.error {
  color: var(--error);
}
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Filter row in changes table ────────────────── */
.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.filter-btn {
  font-family: inherit;
  font-size: 12px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
}
.filter-btn.active {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

/* ── Effort flow ───────────────────────────────── */
.effort-flow {
  display: flex;
  flex-direction: column;
  margin-top: 8px;
}
.effort-flow-row {
  display: grid;
  grid-template-columns: 1fr 90px 1fr;
  align-items: center;
  padding: 4px 12px;
  border-left: 4px solid var(--border);
  margin-bottom: 2px;
  flex: 1;
  min-height: 0;
}
.effort-flow-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--foreground);
}
.effort-flow-value {
  font-size: 18px;
  font-weight: 700;
  text-align: right;
  padding-right: 12px;
}
.effort-flow-detail {
  font-size: 11px;
  color: var(--muted);
}
.effort-flow-start {
  border-left-color: var(--primary);
  background: var(--primary-tint);
}
.effort-flow-start .effort-flow-value {
  color: var(--primary);
}
.effort-flow-add {
  border-left-color: var(--warning);
  background: var(--warning-tint);
}
.effort-flow-add .effort-flow-value {
  color: var(--warning);
}
.effort-flow-done {
  border-left-color: var(--success);
  background: var(--success-tint);
}
.effort-flow-done .effort-flow-value {
  color: var(--success);
}
.effort-flow-remove {
  border-left-color: var(--muted);
  background: var(--muted-tint);
}
.effort-flow-remove .effort-flow-value {
  color: var(--muted);
}
.effort-flow-end {
  border-left-color: var(--primary);
  background: var(--primary-tint);
  border-top: 2px solid var(--border);
  margin-top: 4px;
}
.effort-flow-end .effort-flow-value {
  color: var(--primary);
}
.effort-flow-end .effort-flow-label {
  font-size: 15px;
}
.effort-flow-end .effort-flow-value {
  font-size: 26px;
}

.table-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

/* ── Secondary outline button (settings, profile, org actions) ── */
.btn-reset {
  font-family: inherit;
  font-size: 13px;
  height: 36px;
  padding: 0 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-button);
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s ease;
}
.btn-reset:hover {
  border-color: var(--foreground);
  color: var(--foreground);
}

/* ── Empty state (no report loaded) ────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
  color: var(--muted);
}
.empty-state h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 600;
  color: var(--foreground);
  margin: 0 0 8px;
}
.empty-state p {
  font-size: 14px;
  max-width: 400px;
  line-height: 1.5;
  margin: 0;
}

/* ── Release notes ─────────────────────────────── */
.release-version { margin-bottom: 24px; }
.release-version h3 { font-family: var(--font-heading); font-size: 15px; font-weight: 600; color: var(--foreground); margin: 0 0 8px; }
.release-version ul { margin: 0; padding-left: 20px; color: var(--foreground); font-size: 13px; line-height: 1.6; }

/* ── Privacy page ─────────────────────────────── */
.privacy-section {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.privacy-section-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  font-size: 20px;
}
.privacy-section-icon .material-symbols-sharp { font-size: 22px; }
.privacy-section-body h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  margin: 0 0 6px;
}
.privacy-section-body p {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 10px;
  line-height: 1.5;
}
.privacy-section-body ul {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--foreground);
  line-height: 1.7;
}
.privacy-summary {
  margin-top: 8px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--foreground);
}
.privacy-full-policy {
  margin-top: 16px;
  text-align: center;
}
.privacy-full-policy a {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.privacy-full-policy a:hover { text-decoration: underline; }

/* ── Help page ────────────────────────────────── */
.help-section {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.help-section-number {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-heading);
}
.help-section-body h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  margin: 0 0 6px;
}
.help-section-body p {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.5;
}
.help-section-body p.help-hint {
  margin-top: 12px;
  margin-bottom: 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.help-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.help-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: var(--foreground);
  line-height: 1.5;
}
.help-step-icon {
  flex-shrink: 0;
  font-size: 18px;
  color: var(--primary);
  margin-top: 1px;
}
.help-status-explainer {
  margin-top: 8px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.help-status-explainer h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  margin: 0 0 6px;
}
.help-status-explainer p {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 12px;
  line-height: 1.5;
}
.help-status-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.help-status-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--foreground);
  line-height: 1.4;
}
.help-status-item .material-symbols-sharp {
  font-size: 20px;
  flex-shrink: 0;
}

/* ── Responsive ─────────────────────────────────── */

/* Medium: sidebar as collapsed rail, toolbar wraps */
@media (max-width: 900px) {
  .sidebar:not(.collapsed) {
    width: 48px;
  }
  .sidebar:not(.collapsed) .nav-label { display: none; }
  .sidebar:not(.collapsed) .sidebar-logo { display: none; }
  .sidebar:not(.collapsed) .sidebar-nav-item {
    justify-content: center;
    padding: 0;
    width: 32px;
    height: 32px;
    margin: 0 auto;
  }
  .sidebar:not(.collapsed) .sidebar-sub-items { display: none !important; }
  .sidebar:not(.collapsed) .sidebar-nav-label { display: none; }
  .charts-row { grid-template-columns: 1fr; }
}

/* Mobile: sidebar becomes a horizontal top bar */
@media (max-width: 600px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100% !important;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
    height: auto;
    overflow-x: auto;
  }
  .sidebar-header {
    height: auto;
    padding: 8px 12px;
  }
  .sidebar-nav {
    flex-direction: row;
    padding: 4px 8px;
    overflow-x: auto;
  }
  .sidebar-nav-label { display: none; }
  .sidebar-nav-item {
    white-space: nowrap;
    height: 32px;
    padding: 0 8px;
    font-size: 12px;
  }
  .sidebar-bottom {
    flex-direction: row;
    border-top: none;
    border-left: 1px solid var(--sidebar-border);
    padding: 4px 8px;
  }
  .sidebar-sub-items { display: none !important; }
  .sidebar.collapsed { width: 100% !important; }
  .sidebar.collapsed .nav-label { display: inline; }
  .sidebar.collapsed .sidebar-logo { display: inline; }
  .sidebar-toggle { display: none; }
}

/* ── Query picker (per-role saved query selector) ─────────────────── */
.query-picker {
  background: var(--card, #fff);
  border: 1px solid var(--border, #e0e0e0);
  border-radius: var(--radius-card, 6px);
  box-shadow: var(--shadow, 0 1px 2px rgba(0,0,0,0.04));
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--foreground, #1a1a1a);
  position: relative;
  overflow: visible;
}
.query-picker-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: transparent;
  border: none;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
}
.query-picker-header:hover {
  background: var(--hover, #f5f5f5);
  border-radius: var(--radius-card, 6px);
}
.query-picker-caret {
  font-size: 12px;
  color: var(--muted, #605e5c);
  flex: 0 0 auto;
  width: 12px;
  text-align: center;
}
.query-picker-icon {
  font-size: 15px;
  color: var(--muted, #605e5c);
  flex: 0 0 auto;
}
.query-picker-title {
  font-weight: 600;
  color: var(--foreground, #1a1a1a);
}
.query-picker-summary {
  color: var(--muted, #605e5c);
  font-size: 12px;
  margin-left: auto;
}
.query-picker-body {
  padding: 0 14px 12px;
  border-top: 1px solid var(--border, #eee);
}
.query-picker.is-collapsed .query-picker-header:hover {
  border-radius: var(--radius-card, 6px);
}
.query-picker-table {
  display: grid;
  grid-template-columns: auto auto auto;
  justify-content: start;
  column-gap: 14px;
  row-gap: 6px;
  align-items: center;
  padding-top: 10px;
}
.query-picker-cell {
  min-width: 0;
  padding: 2px 0;
}
.query-picker-role-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: nowrap;
}
.query-picker-role {
  font-weight: 600;
  color: var(--foreground, #323130);
  white-space: nowrap;
}
.query-picker-desc {
  color: var(--muted, #605e5c);
  font-size: 12px;
  white-space: nowrap;
}
.query-picker-desc.is-empty {
  color: var(--muted, #888);
  opacity: 0.5;
}
.query-picker-buttons {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.query-picker-name {
  color: var(--foreground, #323130);
  background: var(--muted-bg, #f3f4f6);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 4px;
  padding: 4px 8px;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.query-picker-name .query-picker-link {
  color: var(--primary, #0078d4);
  text-decoration: none;
}
.query-picker-name .query-picker-link:hover {
  text-decoration: underline;
}
.query-picker-empty {
  color: var(--muted, #888);
  font-style: italic;
}
.query-picker-edit,
.query-picker-clear {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border, #d2d0ce);
  background: var(--card, #fff);
  border-radius: 3px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: var(--muted, #605e5c);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.query-picker-edit:hover:not(:disabled),
.query-picker-clear:hover {
  background: var(--hover, #f3f2f1);
}
.query-picker-edit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
