/* styles.css — IBM Carbon-inspired dark console
   Vertical stack of DEV / STAGE / PROD tiles. Flat, sharp (no rounding),
   structured grid, IBM Plex type. Blue & green reserved for route state. */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Jost:wght@400;500;600;700&display=swap');

:root {
  /* Carbon Gray 100 (dark) surface ramp */
  --bg:            #161616;
  --bg-2:          #0b0b0b;
  --layer:         #262626;
  --layer-hover:   #333333;
  --layer-2:       #393939;
  --border-subtle: #393939;
  --border-strong: #525252;

  /* Text */
  --text:          #f4f4f4;
  --text-secondary:#c6c6c6;
  --text-helper:   #8d8d8d;

  /* Route state — IBM blue + Carbon green, ONLY for blue/green deployment state */
  --route-blue:    #4589ff;   /* IBM Blue 50/60 family */
  --route-blue-core:#0f62fe;  /* IBM signature blue */
  --route-blue-bg: rgba(15, 98, 254, 0.20);
  --route-green:   #42be65;   /* Carbon green */
  --route-green-bg:rgba(36, 160, 72, 0.22);
  --route-off:     #8d8d8d;

  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  /* Cogent wordmark font: real Adobe "futura-pt" if a Typekit kit is present,
     else "Jost" (free geometric Futura clone). */
  --font-brand: 'futura-pt', 'Jost', 'Century Gothic', sans-serif;

  --transition: 0.15s cubic-bezier(0.2, 0, 0.38, 0.9); /* Carbon productive motion */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#bg-canvas { display: none; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  width: 100%;
  max-width: 1280px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 1.5rem 1.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

/* ---------- Top Bar (UI shell) ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#logo-canvas {
  width: 104px;
  height: 104px;
  display: block;
  flex-shrink: 0;
  will-change: transform;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-family: var(--font-brand);
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
}

/* Title stagger-in (from app.js), kept subtle */
.char {
  display: inline-block;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s cubic-bezier(0.2, 0, 0.38, 0.9),
              transform 0.5s cubic-bezier(0.2, 0, 0.38, 0.9);
}
.char.animated { opacity: 1; transform: translateY(0); }

.brand-sub {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-helper);
  margin-top: 0.15rem;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border-subtle);
  background: var(--layer);
}

.refresh-indicator {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-helper);
}

.refresh-progress-container {
  width: 64px;
  height: 3px;
  background: var(--layer-2);
  overflow: hidden;
}
.refresh-progress-bar {
  width: 0%;
  height: 100%;
  background: var(--route-blue);
  transition: width 0.1s linear;
}

/* ---------- Buttons (Carbon) ---------- */
.btn-console {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 400;
  color: #ffffff;
  background: var(--route-blue-core);
  border: 1px solid transparent;
  border-radius: 0;
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-console:hover { background: #0353e9; }
.btn-console:active { background: #002d9c; }
.btn-console:focus-visible { outline: 2px solid #ffffff; outline-offset: -3px; }
.btn-console[disabled] { background: var(--layer-2); color: var(--text-helper); cursor: default; }

/* Secondary (config) button */
#btn-config-toggle {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
}
#btn-config-toggle:hover { background: var(--layer); }

/* ---------- Environment Stack ---------- */
.env-stack {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;                       /* hairline grid lines between tiles */
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
}

.env-card {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem 2.5rem;
  background: var(--layer);
  border-left: 6px solid var(--border-strong); /* state accent bar */
  transition: background var(--transition), border-color var(--transition);
  position: relative;
}
.env-card:hover { background: var(--layer-hover); }

/* Top line: huge label + big route tag */
.env-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.env-id {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.env-label {
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 700;
  line-height: 0.9;
  letter-spacing: -0.03em;
  color: var(--text);
}
.env-name {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text-helper);
  letter-spacing: 0.02em;
}

.env-route { display: flex; align-items: center; }
.status-halo { display: none; }

/* Route tag — Carbon tag, square, bold */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--font-sans);
  font-size: clamp(1.5rem, 2.8vw, 2.25rem);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
  padding: 0.55rem 1.3rem;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text-secondary);
  white-space: nowrap;
}
.status-badge::before {
  content: '';
  width: 16px;
  height: 16px;
  background: currentColor;       /* square indicator, Carbon-style */
  flex-shrink: 0;
}

/* Meta strip: labeled data columns */
.env-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}
.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}
.meta-key {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-helper);
}
.meta-val {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* GitOps repo link inside a meta value — inherits the tile text color
   (white on blue/green tiles) and underlines on hover. */
.gitops-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  border-bottom-color: rgba(255, 255, 255, 0.35);
  transition: border-color var(--transition), opacity var(--transition);
}
.gitops-link:hover { border-bottom-color: currentColor; opacity: 0.85; }

.status-text-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  color: var(--text-secondary);
  min-width: 0;
}
.status-text-pill > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-dot {
  width: 9px;
  height: 9px;
  background: var(--text-helper);  /* square, Carbon */
  flex-shrink: 0;
}
.status-dot.live { background: var(--route-green); }

/* Preview toggles */
.interactive-toggle { display: inline-flex; gap: 0.4rem; }
.toggle-pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  background: transparent;
  transition: var(--transition);
}
.toggle-pill:hover { background: var(--layer-hover); color: var(--text); }

/* ---------- Route State (blue/green ONLY) — whole tile fills with route color ---------- */

/* GREEN tile */
.env-card.color-green {
  background: #24a148;            /* Carbon green 60 — solid fill */
  border-left-color: #0e6027;    /* darker edge for depth */
}
.env-card.color-green:hover { background: #198038; }

/* BLUE tile */
.env-card.color-blue {
  background: #0f62fe;            /* IBM signature blue — solid fill */
  border-left-color: #002d9c;
}
.env-card.color-blue:hover { background: #0353e9; }

/* Shared treatment for any filled (green/blue) tile */
.env-card.color-green,
.env-card.color-blue {
  border-color: transparent;
}
.env-card.color-green .env-label,
.env-card.color-blue .env-label,
.env-card.color-green .meta-val,
.env-card.color-blue .meta-val { color: #ffffff; }

.env-card.color-green .env-name,
.env-card.color-blue .env-name,
.env-card.color-green .meta-key,
.env-card.color-blue .meta-key,
.env-card.color-green .status-text-pill,
.env-card.color-blue .status-text-pill { color: rgba(255, 255, 255, 0.85); }

/* Dividers / borders go translucent-white on the colored fill */
.env-card.color-green .env-meta,
.env-card.color-blue .env-meta { border-top-color: rgba(255, 255, 255, 0.28); }

/* Route tag becomes a high-contrast white-glass chip */
.env-card.color-green .status-badge,
.env-card.color-blue .status-badge {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.55);
}
.env-card.color-green .status-dot,
.env-card.color-blue .status-dot { background: #ffffff; }

/* ---------- Status loader: in-progress vs complete ---------- */
/* In-progress: the dot becomes an animated spinner ring (used for prod
   while a deployments rollover is still pending). Placed after the colored
   -card overrides so it wins on equal specificity. */
.status-text-pill.is-progress .status-dot {
  width: 12px;
  height: 12px;
  background: transparent;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: status-spin 0.7s linear infinite;
}
.status-text-pill.is-progress { font-weight: 500; }

/* Complete: steady filled square (Carbon green), reads as "done". */
.status-text-pill.is-complete .status-dot {
  background: var(--route-green);
  box-shadow: 0 0 0 2px rgba(66, 190, 101, 0.25);
}
.env-card.color-green .status-text-pill.is-complete .status-dot,
.env-card.color-blue .status-text-pill.is-complete .status-dot {
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.30);
}

@keyframes status-spin { to { transform: rotate(360deg); } }

/* Toggle pills on the colored fill */
.env-card.color-green .toggle-pill,
.env-card.color-blue .toggle-pill {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.5);
}
.env-card.color-green .toggle-pill:hover,
.env-card.color-blue .toggle-pill:hover { background: rgba(255, 255, 255, 0.2); }

/* Unconfigured stays neutral gray */
.env-card.color-unconfigured .status-badge { color: var(--route-off); }

/* ---------- Control Panel ---------- */
.control-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.control-note {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-helper);
}
.control-note code {
  color: var(--text-secondary);
  background: var(--layer);
  border: 1px solid var(--border-subtle);
  padding: 0.05rem 0.3rem;
}

/* ---------- Config Drawer ---------- */
.config-drawer {
  margin-top: 1rem;
  background: var(--layer);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s cubic-bezier(0.2, 0, 0.38, 0.9), opacity 0.2s ease;
}
.config-drawer.open { max-height: 900px; opacity: 1; }
.drawer-content { padding: 1.5rem; }
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.drawer-header h3 { font-size: 1rem; font-weight: 600; }
.drawer-hint, .drawer-copy { font-size: 0.82rem; color: var(--text-helper); }
.drawer-copy { margin-bottom: 1rem; line-height: 1.6; }

.json-preview {
  background: var(--bg-2);
  border: 1px solid var(--border-subtle);
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #78a9ff;
  overflow-x: auto;
  line-height: 1.55;
  max-height: 320px;
}

.instructions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1.25rem;
}
.instr-card {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  padding: 1rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}
.instr-card h4 { font-size: 0.84rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; }
.instr-card p { line-height: 1.55; }
code, .code-block { font-family: var(--font-mono); }
.instr-card code:not(.code-block) {
  background: var(--layer-2);
  color: #f1c21b;
  padding: 0.05rem 0.3rem;
  font-size: 0.78rem;
}
.code-block {
  display: block;
  margin-top: 0.4rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-2);
  border: 1px solid var(--border-subtle);
  color: #42be65;
  font-size: 0.76rem;
  word-break: break-all;
}

/* ---------- Skeletons ---------- */
.skeleton-pulse {
  background: linear-gradient(90deg, var(--layer-2) 25%, var(--border-strong) 50%, var(--layer-2) 75%);
  background-size: 200% 100%;
  animation: loading-pulse 1.4s infinite linear;
}
.skeleton-text { display: inline-block; height: 14px; width: 90px; }
.skeleton-text.short { width: 70px; }
.skeleton-badge { display: inline-block; width: 120px; height: 44px; }
@keyframes loading-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Error Banner ---------- */
.error-banner {
  display: none;
  align-items: center;
  gap: 0.6rem;
  background: rgba(250, 77, 86, 0.12);
  border: 1px solid #fa4d56;
  border-left-width: 3px;
  color: #ff8389;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
}

/* refresh spin hook (app.js sets animation: logo-pulse) */
@keyframes logo-pulse {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ---------- Environment Detail Modal ---------- */
.env-card.has-detail { cursor: pointer; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  width: 100%;
  max-width: 520px;
  background: var(--layer);
  border: 1px solid var(--border-strong);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  transform: translateY(8px);
  transition: transform 0.18s cubic-bezier(0.2, 0, 0.38, 0.9);
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}
.modal-head h3 {
  font-family: var(--font-brand);
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--layer-hover); color: var(--text); }

.modal-body { padding: 1.5rem; }
.modal-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-helper);
  margin-bottom: 0.75rem;
}
.broker-list { list-style: none; }
.broker-list li {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text);
  padding: 0.7rem 0.9rem;
  background: var(--bg-2);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--route-blue-core);
  margin-bottom: 0.5rem;
  word-break: break-all;
}
.broker-list li:last-child { margin-bottom: 0; }

/* Modal: active-cluster sub-line above the endpoint list */
.modal-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 1.1rem;
}

/* Modal: clickable service endpoint rows (label + live host) */
.broker-list li.ep-item { padding: 0; }
.broker-list li.ep-item a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 0.9rem;
  color: inherit;
  text-decoration: none;
  transition: background var(--transition);
}
.broker-list li.ep-item a:hover { background: var(--layer); }
.ep-label {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-helper);
  flex-shrink: 0;
}
.ep-host { color: var(--route-blue); word-break: break-all; text-align: right; }

/* Modal: host-parity drift warning (Carbon warning yellow) */
.modal-note {
  margin-top: 1.1rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: #f1c21b;
  background: rgba(241, 194, 27, 0.10);
  border: 1px solid rgba(241, 194, 27, 0.35);
  padding: 0.65rem 0.8rem;
}
.modal-note:empty { display: none; }

/* Second section label (Kafka Proxy) gets breathing room above it */
.modal-label-spaced { margin-top: 1.4rem; }

/* Empty-state row (e.g. prod has no external kafka-proxy svc) */
.broker-list li.ep-empty {
  color: var(--text-helper);
  border-left-color: var(--border-strong);
  font-style: italic;
}

/* ---------- Footer ---------- */
.app-footer {
  padding-top: 1.25rem;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-helper);
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .app-container { padding: 0 1rem 1rem; }
  .env-card { padding: 1.5rem 1.25rem 1.5rem 1.25rem; gap: 1.25rem; }
  .env-main { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .env-meta { gap: 1.5rem; }
}

@media (max-width: 520px) {
  #logo-canvas { width: 76px; height: 76px; }
  .brand-name { font-size: 1.25rem; }
  .topbar-meta { width: 100%; justify-content: space-between; }
  .brand-sub { display: none; }
  .status-badge { font-size: 1.4rem; }
}
