/* ==========================================================================
   BADGE COMPONENTS
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  letter-spacing: 0.025em;
}

/* Badge Variants */
.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-variables { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: var(--gray-100); color: var(--gray-700); }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-error { background: #fee2e2; color: #991b1b; }
.badge-info { background: #e0f2fe; color: #075985; }
.badge-helper { background: #dbeafe; color: #1e40af; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-neutral { background: var(--gray-100); color: var(--gray-700); }

/* Project-specific badges */
.badge-construction { background-color: #10b981; color: white; }
.badge-renovation { background-color: #f59e0b; color: white; }
.badge-sav { background-color: #ef4444; color: white; }

/* Tenant-type badges (xorizo) */
.badge-platform { background-color: #8b5cf6; color: #fff; }
.badge-broker   { background-color: #7c3aed; color: #fff; }

/* Environment badges (xorizo gov-data Live/Spec) — uppercase pill variant */
.badge-env {
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 10px;
  text-transform: uppercase;
}
.badge-env-live { background: #dcfce7; color: #166534; }
.badge-env-spec { background: #fef3c7; color: #92400e; }

/* Priority badges */
.badge-priority-low { background-color: #6b7280; color: white; }
.badge-priority-medium { background-color: #3b82f6; color: white; }
.badge-priority-high { background-color: #f59e0b; color: white; }
.badge-priority-urgent { background-color: #ef4444; color: white; }

/* Status badges — semantic colour tokens (not domain codes).
   Apps map their own status codes → one of these colours in their status config.
   Pastel palette matches .badge-success / .badge-warning / .badge-error shape
   (light fill, dark text) — chosen to harmonise with the rest of the badge set. */
.badge-status-draft { background: #f3f4f6; color: #374151; }
.badge-status-pending { background: #f3f4f6; color: #374151; }
.badge-status-active { background: #d1fae5; color: #065f46; }
.badge-status-in_progress { background: #dbeafe; color: #1e40af; }
.badge-status-on_hold { background: #fef3c7; color: #92400e; }
.badge-status-completed { background: #a7f3d0; color: #064e3b; }
.badge-status-cancelled { background: #fee2e2; color: #991b1b; }
.badge-status-delayed { background: #fecaca; color: #7f1d1d; }

/* Interactive state — editable status badge opens an inline menu on click.
   Only applied when the PHP helper received transitions and is not readonly. */
.status-badge-editable {
  cursor: pointer;
  user-select: none;
  transition: filter 0.12s ease, box-shadow 0.12s ease;
}
.status-badge-editable:hover { filter: brightness(1.08); }
.status-badge-editable:focus-visible {
  outline: 2px solid var(--primary, #2563eb);
  outline-offset: 2px;
}
.status-badge-editable .status-badge-chevron {
  margin-left: 4px;
  opacity: 0.7;
  vertical-align: -1px;
}
.status-badge-editable.is-loading {
  opacity: 0.6;
  cursor: progress;
}

/* Floating menu — appended to <body> so modals/tables don't clip it */
.status-badge-menu {
  position: absolute;
  z-index: 10001;
  min-width: 180px;
  background: var(--surface, white);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 6px);
  box-shadow: var(--shadow-lg, 0 10px 25px rgba(0,0,0,0.12));
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: status-badge-menu-in 0.08s ease-out;
}
@keyframes status-badge-menu-in {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}
.status-badge-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm, 4px);
  font-size: 0.8125rem;
  color: var(--text, #111827);
  cursor: pointer;
  background: transparent;
  border: 0;
  text-align: left;
  width: 100%;
}
.status-badge-menu-item:hover,
.status-badge-menu-item:focus-visible {
  background: var(--gray-100, #f3f4f6);
  outline: none;
}
.status-badge-menu-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}

/* Variable recalculation level badges (build catalog — variables hierarchy legend) */
.badge-var-level-A { background-color: #6366f1; color: white; }
.badge-var-level-B { background-color: #f59e0b; color: white; }
.badge-var-level-C { background-color: #22c55e; color: white; }
.badge-var-level-Z { background-color: #64748b; color: white; }

/* Count Badge — see navigation.css for the canonical tab-count styling.
 * This rule is kept only as a fallback for the (rare) non-tab usages of
 * `.count-badge`. Inside `.nav-tab` it's overridden by navigation.css to
 * match `.nav-tab-count` exactly (single source of truth for tab counts). */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 0.375rem;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 700;
  background: var(--gray-200, #e5e7eb);
  color: var(--text-muted);
}

/* Type indicators */
.type-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
}

.type-indicator.product {
  background-color: #dbeafe;
  color: #1e40af;
}

.type-indicator.pack {
  background-color: #d1fae5;
  color: #065f46;
}

.item-type-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
}

.item-type-badge.product {
  background-color: #3b82f6;
  color: white;
}

.item-type-badge.pack {
  background-color: #10b981;
  color: white;
}