/* ==========================================================================
   Capacity Planner Tab — capacity.css
   ========================================================================== */

/* ==========================================================================
   Capacity Planner Tab  –  v2 (date-picker, ticket-pts based)
   ========================================================================== */

#tab-capacity {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0 4px;
}

#capacity-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0;
}

/* ── Toolbar ────────────────────────────────────────────────────────────── */

.cap-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 2px 16px;
  flex-shrink: 0;
  flex-wrap: wrap;
  border-bottom: 1px solid #E2E8F0;
  margin-bottom: 16px;
}

.cap-toolbar-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.cap-date-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.cap-date-lbl {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  white-space: nowrap;
}

.cap-date-inp {
  padding: 5px 10px;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  font-size: 13px;
  color: #1F2937;
  cursor: pointer;
}
.cap-date-inp:focus {
  outline: 2px solid #3B82F6;
  outline-offset: 1px;
}

.cap-presets {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.cap-preset {
  padding: 4px 10px;
  border: 1px solid #D1D5DB;
  border-radius: 16px;
  background: #fff;
  color: #374151;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.cap-preset:hover  { background: #F3F4F6; border-color: #9CA3AF; }
.cap-preset.active { background: #2563EB; border-color: #2563EB; color: #fff; }

.cap-excl-mgr {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.cap-excl-mgr input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: #2563EB;
}

/* ── Global Bug Fix % row ────────────────────────────────────────────────── */

.cap-bugfix-global {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.cap-bugfix-global-lbl {
  font-size: 13px;
  font-weight: 500;
  color: #374151;
}
.cap-bugfix-global-inp {
  width: 52px;
  padding: 4px 7px;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  font-size: 13px;
  color: #1F2937;
  text-align: right;
}
.cap-bugfix-global-inp:focus {
  outline: 2px solid #3B82F6;
  outline-offset: 1px;
}
.cap-bugfix-global-unit {
  font-size: 13px;
  color: #6B7280;
}
.cap-bugfix-apply-btn {
  padding: 4px 10px;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.cap-bugfix-apply-btn:hover {
  background: #F3F4F6;
  border-color: #9CA3AF;
}

/* ── Subtask View toggle switch ──────────────────────────────────────────── */

.cap-subtask-view-lbl {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.cap-subtask-view-lbl input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.cap-toggle-switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  background: #CBD5E1;
  border-radius: 9px;
  transition: background 0.18s;
  flex-shrink: 0;
}
.cap-toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.18s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
}
.cap-subtask-view-lbl input[type="checkbox"]:checked + .cap-toggle-switch {
  background: #2563EB;
}
.cap-subtask-view-lbl input[type="checkbox"]:checked + .cap-toggle-switch::after {
  transform: translateX(14px);
}
.cap-subtask-view-text {
  line-height: 1;
}

/* ── Per-team Bug Fix % inline label ─────────────────────────────────────── */

.cap-bugfix-lbl {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #6B7280;
  white-space: nowrap;
}
.cap-bugfix-prefix {
  font-weight: 500;
  color: #64748B;
  font-size: 12px;
}
.cap-bugfix-inp {
  width: 44px;
  padding: 3px 6px;
  border: 1px solid #D1D5DB;
  border-radius: 5px;
  font-size: 12px;
  color: #1F2937;
  text-align: right;
  background: #fff;
}
.cap-bugfix-inp:focus {
  outline: 2px solid #3B82F6;
  outline-offset: 1px;
}
.cap-bugfix-deduct {
  color: #F59E0B;
  font-size: 11px;
  font-weight: 500;
}

/* ── Per-team Bug-in-Buffer checkbox ─────────────────────────────────────── */

.cap-bug-in-buf-lbl {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: #64748B;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.cap-bug-in-buf-lbl input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #3B82F6;
  cursor: pointer;
}

/* ── Detail section hide-done filter bar ────────────────────────────────── */

.cap-det-filter-bar {
  display: flex;
  align-items: center;
  padding: 4px 8px 6px;
  border-bottom: 1px solid #F1F5F9;
}
.cap-det-hide-lbl {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #64748B;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.cap-det-hide-lbl input[type="checkbox"] {
  width: 13px;
  height: 13px;
  accent-color: #3B82F6;
  cursor: pointer;
}

/* ── Summary chips ──────────────────────────────────────────────────────── */

.cap-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.cap-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 8px 14px;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  font-size: 13px;
  min-width: 100px;
}
.cap-chip strong { font-size: 16px; font-weight: 700; color: #1F2937; }
.chip-lbl  { font-size: 10px; font-weight: 600; text-transform: uppercase; color: #94A3B8; letter-spacing: 0.04em; }
.chip-sub  { font-size: 11px; color: #94A3B8; }
.chip-ok   { border-color: #BBF7D0; background: #F0FDF4; }
.chip-ok strong { color: #15803D; }
.chip-over { border-color: #FECACA; background: #FEF2F2; }
.chip-over strong { color: #DC2626; }

/* ── Info bar ────────────────────────────────────────────────────────────── */

.cap-info-bar {
  font-size: 12px;
  color: #64748B;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  padding: 8px 14px;
  margin-bottom: 16px;
  flex-shrink: 0;
}
.cap-info-bar code {
  background: #E2E8F0;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
}

/* ── Card list ────────────────────────────────────────────────────────────── */

.cap-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 24px;
}

.cap-card {
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  overflow: hidden;
}

/* ── Card header ─────────────────────────────────────────────────────────── */

.cap-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #F8FAFC;
  border-bottom: 1px solid #E2E8F0;
  flex-wrap: wrap;
}

.cap-tdot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cap-card-name {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
}

.cap-card-meta {
  font-size: 12px;
  color: #94A3B8;
}

/* ── Utilisation bar ─────────────────────────────────────────────────────── */

.cap-bar-outer {
  flex-shrink: 0;
  margin-left: auto;
  width: 140px;
  height: 8px;
  background: #E2E8F0;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}

.cap-bar-fill {
  height: 100%;
  border-radius: 4px 0 0 4px;
  transition: width 0.3s;
}
.cap-bar-fill.cap-ok   { background: #22C55E; }
.cap-bar-fill.cap-warn { background: #F59E0B; }
.cap-bar-fill.cap-over { background: #EF4444; }

.cap-bar-ovf {
  height: 100%;
  background: #dc2626;
  opacity: 0.4;
  min-width: 3px;
}

/* ── Badge ────────────────────────────────────────────────────────────────── */

.cap-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.cap-badge.cap-ok   { background: #DCFCE7; color: #15803D; }
.cap-badge.cap-warn { background: #FEF3C7; color: #92400E; }
.cap-badge.cap-over { background: #FEE2E2; color: #991B1B; }

/* ── Toggle button ────────────────────────────────────────────────────────── */

.cap-toggle {
  margin-left: 0;
  padding: 4px 10px;
  border: 1px solid #D1D5DB;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.cap-toggle:hover { background: #F3F4F6; }

/* ── Stats row ───────────────────────────────────────────────────────────── */

.cap-card-stats {
  display: flex;
  gap: 0;
  border-bottom: 1px solid #E2E8F0;
}

.cap-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 16px;
  border-right: 1px solid #F1F5F9;
  min-width: 0;
}
.cap-stat:last-child { border-right: none; }

.cap-stat-lbl {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94A3B8;
}
.cap-stat-val {
  font-size: 20px;
  font-weight: 700;
  color: #1F2937;
  font-variant-numeric: tabular-nums;
}
.cap-stat-sub {
  font-size: 11px;
  color: #94A3B8;
}

.stat-ok  .cap-stat-val { color: #15803D; }
.stat-over .cap-stat-val { color: #DC2626; }
.stat-ok  .cap-stat-lbl { color: #16a34a; }
.stat-over .cap-stat-lbl { color: #dc2626; }

.cap-rem-val  { color: #D97706 !important; }
.cap-over-txt { color: #DC2626; font-weight: 600; }
.cap-ok-txt   { color: #15803D; }

/* ── Detail section ─────────────────────────────────────────────────────── */

.cap-detail {
  background: #FAFAFA;
}

.cap-det-section {
  padding: 14px 20px;
  border-top: 1px solid #F1F5F9;
}
.cap-det-section:first-child { border-top: none; }

.cap-det-h {
  font-size: 12px;
  font-weight: 600;
  color: #64748B;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}

.cap-det-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
  font-size: 12px;
}
.cap-det-table th {
  text-align: left;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid #E2E8F0;
  background: #F8FAFC;
  white-space: nowrap;
}
.cap-det-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #F8FAFC;
  vertical-align: middle;
  color: #374151;
}
.cap-det-table tbody tr:last-child td { border-bottom: none; }
.cap-det-table tbody tr:hover td { background: #F8FAFC; }

.cap-etd-key {
  width: 8%;
  white-space: nowrap;
  font-family: monospace;
  font-size: 11px;
}
.cap-etd-key a { color: #2563EB; text-decoration: none; }
.cap-etd-key a:hover { text-decoration: underline; }

.cap-etd-sum {
  width: 42%;
  color: #374151;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cap-etd-num {
  width: 10%;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cap-etd-stat {
  width: 110px;
  white-space: nowrap;
}

.cap-etd-due {
  width: 10%;
  white-space: nowrap;
}

.cap-due-chip {
  display: inline-block;
  padding: 1px 6px;
  background: #EFF6FF;
  color: #1D4ED8;
  border-radius: 4px;
  font-size: 11px;
  font-family: monospace;
}
.cap-win-chip {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px;
  background: #FEF3C7;
  color: #92400E;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.cap-com-dev {
  color: #1E40AF;
  font-size: 11px;
  font-weight: 600;
}
.cap-com-bug {
  color: #B91C1C;
  font-size: 11px;
  font-weight: 600;
}

.cap-mtd-name { white-space: nowrap; }
.cap-cn { font-size: 11px; color: #94A3B8; margin-left: 4px; }

.cap-empty {
  padding: 16px;
  font-size: 13px;
  color: #94A3B8;
  font-style: italic;
}

/* ── Category badges ──────────────────────────────────────────────────────── */

.cap-det-h {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #64748B;
  text-transform: none;
  letter-spacing: 0;
  margin: 0 0 10px;
}

.cap-cat-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.cat-committed { background: #DCFCE7; color: #15803D; }
.cat-risk      { background: #FEF3C7; color: #92400E; }
.cat-backlog   { background: #EFF6FF; color: #1D4ED8; }
.cat-discuss   { background: #F1F5F9; color: #64748B; }
.cat-future    { background: #F5F3FF; color: #6D28D9; }
.cat-orphan    { background: #FFF1F2; color: #BE123C; }

/* ── Collapsible section header ──────────────────────────────────────────── */

.cap-det-h--toggle {
  cursor: pointer;
  user-select: none;
  padding: 6px 4px;
  border-radius: 4px;
  margin-bottom: 0;
  transition: background 0.1s;
}
.cap-det-h--toggle:hover { background: #F1F5F9; }
.cap-sec-chevron {
  font-size: 9px;
  color: #94A3B8;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.cap-sec-body {
  padding-top: 4px;
  padding-bottom: 4px;
}
.cap-det-subsection {
  margin-left: 16px;
  border-left: 2px solid #E2E8F0;
  padding-left: 10px;
}

/* ── Orphan type tag ─────────────────────────────────────────────────────── */

.cap-type-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #1D4ED8;
  background: #EFF6FF;
  border-radius: 3px;
  padding: 0 4px;
  vertical-align: middle;
}

.cap-cat-meta {
  font-size: 11px;
  font-weight: 400;
  color: #94A3B8;
}

/* ── Estimate tag ─────────────────────────────────────────────────────────── */

.cap-est-tag {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #92400E;
  background: #FEF3C7;
  border-radius: 3px;
  padding: 0 4px;
  margin-right: 3px;
  vertical-align: middle;
}

/* ── At-risk pill in card header ─────────────────────────────────────────── */

.cap-risk-pill {
  display: inline-block;
  padding: 2px 8px;
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: default;
}

/* ── Backlog stat value ───────────────────────────────────────────────────── */

.cap-backlog-val { color: #64748B; }

.muted { color: #CBD5E1; }

/* ── Clickable BUG Committed stat ───────────────────────────────────────── */

.cap-stat--clickable {
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 8px;
}
.cap-stat--clickable:hover {
  background: #FFF7ED;
}
.cap-stat--clickable:hover .cap-stat-lbl {
  color: #B45309;
}

.cap-view-hint {
  color: #B45309;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Bug Tickets Modal ────────────────────────────────────────────────────── */

.modal--wide {
  max-width: 1300px;
  width: 96vw;
}

.modal-body--scroll {
  overflow-x: auto;
  max-height: 82vh;
  overflow-y: auto;
}

.bug-modal-table {
  min-width: 620px;
}

/* Bug modal toolbar (filter + count) */
.bug-modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 2px 12px;
  border-bottom: 1px solid #E2E8F0;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.bug-modal-counts {
  font-size: 13px;
  color: #374151;
}
.bug-modal-counts strong {
  font-weight: 700;
  color: #1F2937;
}

.bug-modal-filter-lbl {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  user-select: none;
}
.bug-modal-filter-lbl input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: #2563EB;
}
.bug-filter-hint {
  color: #94A3B8;
  font-weight: 400;
}

.cap-etd-assignee {
  width: 120px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Due date colour coding in bug ticket modal */
.cap-due-chip.bug-due--overdue {
  background: #FEE2E2;
  color: #DC2626;
  border-color: #FCA5A5;
}
.cap-due-chip.bug-due--soon {
  background: #FFF7ED;
  color: #EA580C;
  border-color: #FED7AA;
}
