/* ============================================================
   Aurora UCP — Components
   ============================================================ */

/* ========== INCIDENT BANNER ========== */
@keyframes incidentPulse {
  0%,  100% { box-shadow: 0 2px 16px rgba(0,0,0,0.4); }
  50%       { box-shadow: 0 2px 24px rgba(239,68,68,0.25); }
}

#incident-banner {
  flex-shrink: 0;
}

/* Incident Mode — body-level state class */
body.incident-critical  { --bg-base: #0c0808; }
body.incident-containment { --bg-base: #090610; }

/* ========== PANEL / CARD ========== */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--panel-padding);
}

.panel-sm { padding: var(--sp-4); }
.panel-flat { border-radius: var(--radius-md); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
  gap: var(--sp-3);
}

.panel-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.panel-title-lg {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0;
  text-transform: none;
}

.panel-action {
  font-size: var(--text-xs);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
}
.panel-action:hover { color: var(--text-accent); }

/* ========== STAT CARD ========== */
.stat-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.stat-card:hover {
  border-color: var(--border-default);
}

.stat-card-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
}

.stat-card-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  font-family: var(--font-mono);
}

.stat-card-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.stat-card-icon {
  position: absolute;
  top: var(--sp-5);
  right: var(--sp-5);
  opacity: 0.15;
}

.stat-card.healthy  { border-left: 3px solid var(--status-healthy); }
.stat-card.warning  { border-left: 3px solid var(--status-warning); }
.stat-card.critical { border-left: 3px solid var(--status-critical); }
.stat-card.info     { border-left: 3px solid var(--accent); }

/* ========== BADGE ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-healthy {
  background: var(--status-healthy-bg);
  color: var(--status-healthy);
  border-color: var(--status-healthy-border);
}
.badge-healthy .badge-dot { background: var(--status-healthy); }

.badge-warning {
  background: var(--status-warning-bg);
  color: var(--status-warning);
  border-color: var(--status-warning-border);
}
.badge-warning .badge-dot { background: var(--status-warning); }

.badge-critical {
  background: var(--status-critical-bg);
  color: var(--status-critical);
  border-color: var(--status-critical-border);
}
.badge-critical .badge-dot { background: var(--status-critical); }

.badge-offline {
  background: var(--status-offline-bg);
  color: var(--status-unknown);
  border-color: var(--status-offline-border);
}
.badge-offline .badge-dot { background: var(--status-unknown); }

.badge-info {
  background: var(--status-info-bg);
  color: var(--status-info);
  border-color: var(--status-info-border);
}

.badge-accent {
  background: var(--accent-glow);
  color: var(--text-accent);
  border-color: var(--border-accent);
}

.badge-neutral {
  background: var(--bg-hover);
  color: var(--text-secondary);
  border-color: var(--border-default);
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-panel-alt);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-emphasis); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--status-critical-bg);
  color: var(--status-critical);
  border-color: var(--status-critical-border);
}
.btn-danger:hover { background: var(--status-critical-dim); color: #fff; }

.btn-warning {
  background: var(--status-warning-bg);
  color: var(--status-warning);
  border-color: var(--status-warning-border);
}
.btn-warning:hover { background: var(--status-warning-dim); color: #fff; }

.btn-sm {
  padding: 3px 10px;
  font-size: var(--text-xs);
  gap: var(--sp-1);
}

.btn-icon {
  padding: 5px;
  aspect-ratio: 1;
  justify-content: center;
}

.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ========== TABLE ========== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table thead th {
  text-align: left;
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody td {
  padding: var(--sp-3) var(--sp-4);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tbody td.secondary {
  color: var(--text-secondary);
}

.data-table tbody td.mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.data-table .actions-cell {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ========== FORM CONTROLS ========== */
.input {
  background: var(--bg-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: 6px 12px;
  transition: border-color var(--transition-fast);
  outline: none;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-muted); }

.input-search {
  padding-left: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%233d5270' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
}

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%233d5270' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

/* ========== TOOLBAR ========== */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}

.toolbar-left  { display: flex; align-items: center; gap: var(--sp-3); flex: 1; }
.toolbar-right { display: flex; align-items: center; gap: var(--sp-3); }

/* ========== PROGRESS BAR ========== */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--border-subtle);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}
.progress-bar-fill.healthy  { background: var(--status-healthy); }
.progress-bar-fill.warning  { background: var(--status-warning); }
.progress-bar-fill.critical { background: var(--status-critical); }
.progress-bar-fill.info     { background: var(--accent); }

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--sp-6);
  animation: fadeOverlay 150ms ease forwards;
}

@keyframes fadeOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--bg-panel);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: slideModal 150ms ease forwards;
}

@keyframes slideModal {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.modal-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--sp-1);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.modal-body {
  padding: var(--sp-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* ========== DETAIL ROWS ========== */
.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
}

.detail-label {
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 2px;
}

.detail-value {
  color: var(--text-primary);
}

.detail-divider {
  grid-column: 1 / -1;
  height: 1px;
  background: var(--border-subtle);
  margin: var(--sp-2) 0;
}

/* ========== ALERT ITEM ========== */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-panel-alt);
  margin-bottom: var(--sp-2);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.alert-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
}

.alert-item.selected {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.alert-severity-bar {
  width: 3px;
  align-self: stretch;
  border-radius: 2px;
  flex-shrink: 0;
}

.alert-severity-bar.critical { background: var(--status-critical); }
.alert-severity-bar.warning  { background: var(--status-warning); }
.alert-severity-bar.info     { background: var(--status-info); }
.alert-severity-bar.healthy  { background: var(--status-healthy); }

.alert-content { flex: 1; min-width: 0; }
.alert-message { font-size: var(--text-sm); color: var(--text-primary); font-weight: 500; }
.alert-meta    { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }

/* ========== TIMELINE EVENT ========== */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: var(--sp-3);
  padding-bottom: var(--sp-4);
  position: relative;
}

.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 16px;
  bottom: 0;
  width: 1px;
  background: var(--border-subtle);
}

.timeline-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
  border: 2px solid var(--bg-panel);
}

.timeline-dot.critical { background: var(--status-critical); }
.timeline-dot.warning  { background: var(--status-warning); }
.timeline-dot.healthy  { background: var(--status-healthy); }
.timeline-dot.info     { background: var(--status-info); }
.timeline-dot.muted    { background: var(--text-muted); }

.timeline-body { flex: 1; min-width: 0; }
.timeline-title { font-size: var(--text-sm); color: var(--text-primary); font-weight: 500; }
.timeline-time  { font-size: var(--text-xs); color: var(--text-muted); margin-top: 1px; }

/* ========== EMPTY STATE ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-10);
  gap: var(--sp-3);
  color: var(--text-muted);
  text-align: center;
}

.empty-state svg {
  opacity: 0.3;
}

.empty-state-title {
  font-size: var(--text-md);
  color: var(--text-secondary);
  font-weight: 500;
}

/* ========== FILTER TAGS ========== */
.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: var(--text-xs);
  border: 1px solid var(--border-default);
  background: var(--bg-panel-alt);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.filter-tag:hover {
  border-color: var(--border-emphasis);
  color: var(--text-primary);
}

.filter-tag.active {
  background: var(--accent-glow);
  border-color: var(--border-accent);
  color: var(--text-accent);
}

/* ========== CHART CONTAINER ========== */
.chart-container {
  position: relative;
  width: 100%;
}

/* ========== EXPIRY WARNING ========== */
.expiry-indicator {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
}

.expiry-bar {
  flex: 1;
  height: 3px;
  background: var(--border-subtle);
  border-radius: 2px;
  overflow: hidden;
}

.expiry-fill {
  height: 100%;
  border-radius: 2px;
}

/* ========== NODE CARD ========== */
.node-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  transition: border-color var(--transition-fast);
  cursor: pointer;
}

.node-card:hover {
  border-color: var(--border-emphasis);
}

.node-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.node-id {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ========== TRUST LEVEL ========== */
.trust-level {
  display: flex;
  gap: 3px;
  align-items: center;
}

.trust-pip {
  width: 8px;
  height: 8px;
  border-radius: 1px;
  background: var(--border-default);
}

.trust-pip.filled { background: var(--accent); }
.trust-pip.high   { background: var(--status-healthy); }
.trust-pip.med    { background: var(--status-warning); }
.trust-pip.low    { background: var(--status-critical); }

/* ========== ROLLOUT PROGRESS ========== */
.rollout-track {
  background: var(--border-subtle);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  width: 100%;
}

.rollout-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* ========== LOADING PLACEHOLDER ========== */
.skeleton {
  background: linear-gradient(90deg, var(--bg-panel) 25%, var(--bg-hover) 50%, var(--bg-panel) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-md);
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== TOOLTIP ========== */
[data-tooltip] {
  position: relative;
  cursor: help;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e2d45;
  color: var(--text-primary);
  font-size: var(--text-xs);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  border: 1px solid var(--border-default);
  z-index: 500;
}
[data-tooltip]:hover::after { opacity: 1; }
