/* ═══════════════════════════════════════════════════════════════════════════
   WCAHT PoASy3 Dashboard — Shared Styles
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #f5f7fa;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f4f8;
  --border: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-blue: #2563eb;
  --accent-cyan: #0891b2;
  --accent-green: #059669;
  --accent-yellow: #d97706;
  --accent-red: #dc2626;
  --accent-purple: #7c3aed;
  --accent-orange: #ea580c;
  --gradient-blue: linear-gradient(135deg, #2563eb, #0891b2);
  --gradient-green: linear-gradient(135deg, #059669, #0891b2);
  --gradient-red: linear-gradient(135deg, #dc2626, #ea580c);
  --gradient-purple: linear-gradient(135deg, #7c3aed, #2563eb);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Top Bar ─────────────────────────────────────────────────────────────── */
.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}
.topbar .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}
.topbar .logo .chain-icon {
  width: 28px;
  height: 28px;
  background: var(--gradient-blue);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.topbar .logo .brand-logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}
.topbar .nav {
  display: flex;
  gap: 4px;
}
.topbar .nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
}
.topbar .nav a:hover,
.topbar .nav a.active {
  color: var(--accent-blue);
  background: rgba(37,99,235,.08);
}
.topbar .status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.topbar .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse 2s ease-in-out infinite;
}
.topbar .status-dot.offline { background: var(--accent-red); animation: none; }

/* ── Topbar right cluster: bell + status pill ─────────────────────────────── */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.notif-bell {
  position: relative;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s;
}
.notif-bell:hover { background: rgba(37,99,235,.08); border-color: rgba(37,99,235,.2); }
.notif-bell .bell-icon { filter: grayscale(.1); }
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--accent-red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}
.notif-panel {
  position: fixed;
  top: 60px;
  right: 16px;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: 70vh;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,.18);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.notif-panel[hidden] { display: none; }
.notif-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  font-weight: 600;
  font-size: 13px;
}
.notif-panel-header button {
  background: transparent;
  border: 0;
  color: var(--accent-blue, #2563eb);
  cursor: pointer;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 4px;
}
.notif-panel-header button:hover { background: rgba(37,99,235,.08); }
.notif-list { overflow-y: auto; max-height: calc(70vh - 44px); }
.notif-empty { padding: 24px 12px; text-align: center; color: var(--text-muted, #94a3b8); font-size: 13px; }
.notif-item {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  border-left: 3px solid #94a3b8;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.notif-item.critical { border-left-color: #dc2626; }
.notif-item.warning { border-left-color: #d97706; }
.notif-item.info { border-left-color: #2563eb; }
.notif-msg { font-size: 13px; color: var(--text-primary, #0f172a); word-break: break-word; }
.notif-time { font-size: 11px; color: var(--text-muted, #94a3b8); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

/* ── Crypto Price Ticker ─────────────────────────────────────────────────── */
.price-ticker-bar {
  background: #0f172a;
  border-bottom: 1px solid #1e293b;
  height: 36px;
  max-height: 36px;
  overflow: hidden;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  position: sticky;
  top: 56px;
  z-index: 99;
  /* clip the scrolling track */
  clip-path: inset(0);
}
.price-ticker-viewport {
  flex: 1;
  overflow: hidden;
  height: 36px;
  position: relative;
}
.price-ticker-track {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  width: max-content;
  height: 36px;
  animation: ticker-scroll 200s linear infinite;
  will-change: transform;
}
.price-ticker-bar:hover .price-ticker-track {
  animation-play-state: paused;
}
@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.ticker-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  border-right: 1px solid #1e293b;
  height: 36px;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: default;
}
.ticker-item img {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  object-fit: contain;
  background: #1e293b;
  flex-shrink: 0;
}
.ticker-item .t-symbol { color: #f1f5f9; font-weight: 700; text-transform: uppercase; }
.ticker-item .t-price  { color: #94a3b8; }
.ticker-item .t-change.up   { color: #10b981; }
.ticker-item .t-change.down { color: #f87171; }
.ticker-item .t-change.flat { color: #64748b; }
.ticker-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px 0 16px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  color: #475569;
  text-transform: uppercase;
  border-right: 1px solid #1e293b;
  height: 36px;
  flex-shrink: 0;
  background: #0f172a;
  position: relative;
  z-index: 1;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.container {
  margin: 0 auto;
  padding: 20px 24px;
}

.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .grid-4, .grid-3, .grid-2, .grid-1-2, .grid-2-1 {
    grid-template-columns: 1fr;
  }
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color .2s, box-shadow .2s, background-color .35s ease-out;
  box-shadow: var(--shadow-sm);
}
.card:hover { border-color: rgba(37,99,235,.25); box-shadow: var(--shadow-md); }

/* Flash highlight when a metric value updates inside a card. */
@keyframes wcaht-card-flash {
  0%   { background-color: rgba(37, 99, 235, 0.18); box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.35), var(--shadow-md); }
  60%  { background-color: rgba(37, 99, 235, 0.07); box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.20), var(--shadow-sm); }
  100% { background-color: var(--bg-card); box-shadow: var(--shadow-sm); }
}
@keyframes wcaht-value-pop {
  0%   { transform: translateY(0);   color: var(--accent-blue); }
  40%  { transform: translateY(-2px); color: var(--accent-blue); }
  100% { transform: translateY(0);   color: inherit; }
}
.card.flash-update { animation: wcaht-card-flash 900ms ease-out; }
.metric-value.flash-update { animation: wcaht-value-pop 700ms ease-out; }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
}
.card-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
.badge-green { background: rgba(5,150,105,.1); color: var(--accent-green); }
.badge-yellow { background: rgba(217,119,6,.1); color: var(--accent-yellow); }
.badge-red { background: rgba(220,38,38,.1); color: var(--accent-red); }
.badge-blue { background: rgba(37,99,235,.1); color: var(--accent-blue); }

/* ── Metric Cards ────────────────────────────────────────────────────────── */
.metric-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.metric-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.metric-change {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
}
.metric-change.up { color: var(--accent-green); }
.metric-change.down { color: var(--accent-red); }

/* ── Section Headers ─────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 16px;
}
.section-title {
  font-size: 16px;
  font-weight: 700;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr:hover { background: var(--bg-card-hover); }

/* ── Status Indicators ───────────────────────────────────────────────────── */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}
.status-indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-green { background: var(--accent-green); box-shadow: 0 0 4px rgba(5,150,105,.4); }
.dot-red { background: var(--accent-red); box-shadow: 0 0 4px rgba(220,38,38,.4); }
.dot-yellow { background: var(--accent-yellow); box-shadow: 0 0 4px rgba(217,119,6,.4); }

/* ── Node Cards ──────────────────────────────────────────────────────────── */
.node-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all .2s;
}
.node-card:hover { border-color: rgba(37,99,235,.25); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.node-card.online { border-left: 3px solid var(--accent-green); }
.node-card.offline { border-left: 3px solid var(--accent-red); opacity: .7; }
.node-card .node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.node-card .node-name {
  font-weight: 600;
  font-size: 14px;
}
.node-card .node-role {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(124,58,237,.1);
  color: var(--accent-purple);
  font-weight: 600;
}
.node-card .node-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 12px;
}
.node-card .node-stat-label {
  color: var(--text-muted);
}
.node-card .node-stat-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ── Alerts (toast overlay, non-pushing) ─────────────────────────────────── */
#alertsContainer {
  position: fixed;
  top: 70px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
  width: calc(100% - 32px);
}
.alert-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,.10);
  background: #fff;
  pointer-events: auto;
  animation: toastIn .18s ease-out, toastOut .25s ease-in 1.75s forwards;
}
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}
@keyframes toastOut {
  to { transform: translateX(20px); opacity: 0; }
}
.alert-banner.critical {
  background: rgba(220,38,38,.95);
  border: 1px solid rgba(220,38,38,.4);
  color: #fff;
}
.alert-banner.warning {
  background: rgba(217,119,6,.95);
  border: 1px solid rgba(217,119,6,.4);
  color: #fff;
}
.alert-banner.info {
  background: rgba(37,99,235,.95);
  border: 1px solid rgba(37,99,235,.4);
  color: #fff;
}

/* ── Event Log ───────────────────────────────────────────────────────────── */
.event-log {
  max-height: 300px;
  overflow-y: auto;
}
.event-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.event-item .event-icon { font-size: 14px; }
.event-item .event-time {
  color: var(--text-muted);
  font-size: 11px;
  min-width: 70px;
}

/* ── Progress Bars ───────────────────────────────────────────────────────── */
.progress-bar {
  background: #e2e8f0;
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  margin-top: 6px;
}
.progress-bar .fill {
  height: 100%;
  border-radius: 4px;
  transition: width .3s ease;
}
.fill-green { background: var(--gradient-green); }
.fill-blue { background: var(--gradient-blue); }
.fill-red { background: var(--gradient-red); }
.fill-purple { background: var(--gradient-purple); }

/* ── Chart Placeholder ───────────────────────────────────────────────────── */
.chart-area {
  width: 100%;
  height: 200px;
  position: relative;
}
.chart-area canvas { width: 100% !important; height: 100% !important; }

/* ── Mono Text ───────────────────────────────────────────────────────────── */
.mono {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
}

/* ── Truncate ────────────────────────────────────────────────────────────── */
.truncate {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}

/* ── Tooltip ─────────────────────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
  cursor: help;
}
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  border: 1px solid #334155;
  color: #f1f5f9;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 10;
}

/* ── Refresh indicator ───────────────────────────────────────────────────── */
.refresh-indicator {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Supply distribution bar ─────────────────────────────────────────────── */
.supply-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  margin-top: 8px;
}
.supply-bar .segment {
  transition: width .3s;
}
.supply-bar .seg-circulating { background: var(--accent-green); }
.supply-bar .seg-burned { background: var(--accent-red); }
.supply-bar .seg-staked { background: var(--accent-purple); }
