/* ==========================================================================
   THE LITTLE WORLD — Living VPS & Hermes Agent Telemetry
   Design System & Layout matching Twilight Tech Village Dashboard
   ========================================================================== */

:root {
  --bg-deep: #070c16;
  --bg-card: rgba(13, 22, 38, 0.82);
  --bg-card-hover: rgba(20, 34, 58, 0.9);
  --bg-card-border: rgba(56, 189, 248, 0.12);
  --bg-pill: rgba(18, 30, 52, 0.7);
  
  --text-main: #f1f5f9;
  --text-dim: #94a3b8;
  --text-muted: #64748b;
  
  --color-brand: #38bdf8;
  --color-brand-glow: rgba(56, 189, 248, 0.35);
  --color-green: #22c55e;
  --color-green-glow: rgba(34, 197, 94, 0.4);
  --color-amber: #f59e0b;
  --color-amber-glow: rgba(245, 158, 11, 0.4);
  --color-red: #ef4444;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-pixel: 'Silkscreen', cursive;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 16px rgba(56, 189, 248, 0.2);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#world-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 50% 20%, #0d192f 0%, #060a12 100%);
  position: relative;
}

/* ==========================================================================
   TOP STATUS STRIP
   ========================================================================== */
#top-status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  height: 64px;
  background: rgba(8, 14, 25, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  z-index: 10;
  gap: 16px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(30, 58, 138, 0.4));
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-brand);
  box-shadow: 0 0 12px var(--color-brand-glow);
}
.brand-icon svg { width: 22px; height: 22px; }

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 400;
}

/* Status Chip */
.system-status-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.25);
  border-radius: var(--radius-full);
}

.status-chip-text {
  display: flex;
  flex-direction: column;
}

.chip-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #86efac;
}

.chip-sub {
  font-size: 0.65rem;
  color: rgba(134, 239, 172, 0.75);
}

.status-pip {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-pip.healthy {
  background-color: var(--color-green);
  box-shadow: 0 0 10px var(--color-green-glow);
  animation: pulse-glow 2s infinite ease-in-out;
}
.status-pip.warning {
  background-color: var(--color-amber);
  box-shadow: 0 0 10px var(--color-amber-glow);
}
.status-pip.error {
  background-color: var(--color-red);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.8; }
}

/* Metrics Cluster */
.metrics-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}

.metric-pill, .time-weather-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: var(--bg-pill);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}
.metric-pill:hover {
  background: var(--bg-card-hover);
  border-color: rgba(56, 189, 248, 0.3);
}

.metric-icon {
  width: 20px;
  height: 20px;
  color: var(--color-brand);
  display: flex;
  align-items: center;
  justify-content: center;
}
.metric-icon svg { width: 17px; height: 17px; }

.metric-body {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.63rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.metric-val {
  font-size: 0.86rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pip-inline {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.pip-inline.green { background: var(--color-green); box-shadow: 0 0 6px var(--color-green); }

.sun-icon {
  font-size: 1.1rem;
}

/* Action Buttons */
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(30, 64, 175, 0.4));
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.action-btn svg { width: 14px; height: 14px; }
.action-btn:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.4), rgba(30, 64, 175, 0.6));
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}
.action-btn.secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-dim);
}
.action-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: none;
}

/* ==========================================================================
   VIEWPORT STAGE (THE CANVAS LIVING WORLD)
   ========================================================================== */
#viewport-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #060b14;
  cursor: crosshair;
}

#world-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Tooltip on Canvas Hover */
#canvas-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(10, 18, 32, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  z-index: 50;
  transform: translate(-50%, -120%);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
#canvas-tooltip.hidden {
  opacity: 0;
  visibility: hidden;
}
.tooltip-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}
.tooltip-title {
  font-size: 0.76rem;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-pixel);
  letter-spacing: 0.02em;
}
.tooltip-body {
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* ==========================================================================
   BOTTOM ACTIVITY & TELEMETRY STRIP
   ========================================================================== */
#bottom-activity-strip {
  display: grid;
  grid-template-columns: 1.15fr 1.35fr 1fr;
  gap: 14px;
  padding: 12px 18px;
  height: 190px;
  background: rgba(8, 14, 25, 0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 10;
}

.activity-panel {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-left h2 {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}
.panel-icon { font-size: 0.9rem; }

.event-counter, .pulse-tag {
  font-size: 0.64rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

.pulse-tag {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--color-brand);
  font-weight: 600;
}
.pulse-dot {
  width: 6px;
  height: 6px;
  background: var(--color-brand);
  border-radius: 50%;
  animation: pulse-glow 1.5s infinite;
}

/* Happenings list */
.happenings-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}
.happenings-list::-webkit-scrollbar { width: 4px; }
.happenings-list::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 4px; }

.happening-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.35;
  padding: 2px 0;
}
.happening-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.happening-dot.green { background: var(--color-green); }
.happening-dot.amber { background: var(--color-amber); }
.happening-dot.blue { background: var(--color-brand); }
.happening-time {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.happening-msg {
  color: #e2e8f0;
  flex: 1;
}

/* Live activity bars */
.activity-bars-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.activity-row {
  display: grid;
  grid-template-columns: 100px 110px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 0.72rem;
}

.activity-agent-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #fff;
}
.activity-agent-name svg { width: 14px; height: 14px; color: var(--color-brand); }

.activity-status-text {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 0.68rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.progress-fill.amber {
  background: linear-gradient(90deg, #d97706, #f59e0b);
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}
.progress-fill.blue {
  background: linear-gradient(90deg, #0284c7, #38bdf8);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}
.progress-fill.green {
  background: linear-gradient(90deg, #16a34a, #22c55e);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

/* Selected Entity Card */
.selected-card-panel {
  display: flex;
  flex-direction: row;
  gap: 14px;
  padding: 12px;
  position: relative;
  background: linear-gradient(135deg, rgba(16, 27, 48, 0.9), rgba(10, 18, 32, 0.95));
}

.card-hero-thumb {
  width: 90px;
  height: 100%;
  border-radius: var(--radius-md);
  background: #0f1c32 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="90" height="130" viewBox="0 0 90 130"><rect width="90" height="130" fill="%230c182d"/><circle cx="45" cy="40" r="16" fill="%23f59e0b" opacity="0.3"/><polygon points="45,20 20,70 70,70" fill="%23047857"/><rect x="35" y="70" width="20" height="30" fill="%2378350f"/><rect x="40" y="80" width="10" height="12" fill="%23fde047"/></svg>') center/cover no-repeat;
  border: 1px solid rgba(56, 189, 248, 0.2);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.card-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.7);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--color-brand);
}

.card-details {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  overflow: hidden;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title-row h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
}

.card-subtitle {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 1px;
}

.card-quote {
  font-size: 0.7rem;
  color: #cbd5e1;
  font-style: italic;
  line-height: 1.35;
  margin: 6px 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.view-details-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-sm);
  color: var(--color-brand);
  font-size: 0.68rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  align-self: flex-start;
}
.view-details-btn svg { width: 12px; height: 12px; }
.view-details-btn:hover {
  background: rgba(56, 189, 248, 0.25);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

/* ==========================================================================
   MODAL DIALOGS (DYNAMIC EXPANSION & INSPECTION)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.2s ease;
}
.modal-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  width: 440px;
  background: #0d1626;
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}
.close-modal-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0 4px;
}
.close-modal-btn:hover { color: #fff; }

.modal-desc {
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.modal-tabs {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: var(--radius-md);
}
.tab-btn {
  flex: 1;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s;
}
.tab-btn.active {
  background: rgba(56, 189, 248, 0.2);
  color: #fff;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.form-group.hidden { display: none; }
.form-group label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
}
.form-group input {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.85rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus {
  border-color: var(--color-brand);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}
.btn-cancel, .btn-confirm {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-cancel {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-dim);
}
.btn-cancel:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.btn-confirm {
  background: var(--color-brand);
  border: none;
  color: #070c16;
}
.btn-confirm:hover {
  background: #7dd3fc;
  box-shadow: 0 0 12px var(--color-brand-glow);
}

/* Inspect modal */
.inspect-card {
  width: 520px;
}
.inspect-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.inspect-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.inspect-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 6px 0;
}
.stat-box {
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
}
.stat-box .title { font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; }
.stat-box .val { font-size: 0.88rem; font-weight: 700; color: #fff; font-family: var(--font-mono); }

.log-terminal {
  background: #050912;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #93c5fd;
  max-height: 140px;
  overflow-y: auto;
  line-height: 1.45;
}
