/* Hero Compute Dashboard — Custom Styles */

/* Compact sizing (skill requirement) */
body { font-size: 0.85rem; }
.form-control, .form-select { font-size: 0.85rem; }
.form-label { font-size: 0.85rem; margin-bottom: 0.25rem; }
.btn { font-size: 0.85rem; }
.tab-content { font-size: 0.85rem; }
.nav-tabs .nav-link { font-size: 0.85rem; padding: 0.4rem 0.75rem; }
textarea.form-control { font-size: 0.8rem; }

/* Status color variables */
:root {
  --status-ok: #198754;
  --status-warn: #ffc107;
  --status-error: #dc3545;
}

/* ── Sidebar navigation ───────────────────────────── */
.sidebar-nav {
  width: 220px;
  border-right: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
}
.sidebar-nav .offcanvas-body {
  display: flex;
  flex-direction: column;
  height: 100%;
}
@media (min-width: 992px) {
  .sidebar-nav {
    position: sticky;
    top: 0;
    height: calc(100vh - 42px);
    overflow-y: auto;
  }
}
.sidebar-links { display: flex; flex-direction: column; padding: 0.5rem 0; }
.sidebar-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.5rem 1rem;
  color: var(--bs-body-color);
  text-decoration: none;
  font-size: 0.82rem;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.sidebar-link:hover {
  background: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
  text-decoration: none;
}
.sidebar-link.active {
  background: var(--bs-tertiary-bg);
  border-left-color: var(--bs-primary);
  font-weight: 600;
  color: var(--bs-primary);
}
.sidebar-link i { font-size: 1rem; width: 1.25rem; text-align: center; }
.sidebar-footer {
  margin-top: auto;
  padding: 0.75rem 0;
  border-top: 1px solid var(--bs-border-color);
  font-size: 0.75rem;
}
.main-content { min-height: calc(100vh - 42px); }

/* Status dots */
.status-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.status-ok    { background: var(--status-ok); }
.status-warn  { background: var(--status-warn); }
.status-error { background: var(--status-error); }
.status-off   { background: #6c757d; }

/* Stat rows in sidebar cards */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--bs-border-color);
}
.stat-row:last-child { border-bottom: none; }
.stat-label { font-size: 0.8rem; }
.stat-value { font-weight: 600; font-size: 0.85rem; }

/* Logs viewer */
.logs-viewer {
  max-height: 500px;
  overflow-y: auto;
  background: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 6px;
  padding: 8px;
  font-size: 0.8rem;
}

/* Log entries */
.log-entry {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-family: monospace;
  font-size: 0.75rem;
}
.log-entry:last-child { border-bottom: none; }
.log-msg { color: var(--bs-body-color); }

/* Code blocks */
.code-block { white-space: pre-wrap; word-break: break-all; }
pre { background: var(--bs-tertiary-bg); padding: 1rem; border-radius: 0.5rem; overflow-x: auto; font-size: 0.8rem; }

/* Light mode overrides */
[data-bs-theme="light"] .log-msg { color: #1f2328; }
[data-bs-theme="light"] .log-entry { border-bottom-color: rgba(0, 0, 0, 0.05); }

/* VM state badges */
.badge-running { background-color: var(--status-ok) !important; }
.badge-stopped { background-color: #6c757d !important; }
.badge-error { background-color: var(--status-error) !important; }
.badge-provisioning, .badge-starting, .badge-stopping, .badge-restarting {
  background-color: var(--status-warn) !important;
  color: #000 !important;
}

/* Slice grid */
.slice-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--bs-border-color);
}
.slice-free { background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); }
.slice-used { background: var(--status-ok); color: #fff; }

/* VM expandable log rows */
.vm-chevron { transition: transform 0.15s; display: inline-block; }
.vm-row.expanded .vm-chevron { transform: rotate(90deg); }
.vm-row { cursor: pointer; }
.vm-log-panel { background: var(--bs-secondary-bg); }

/* Deployment log line colors */
.log-line-error { color: var(--status-error); }
.log-line-success { color: var(--status-ok); }
.log-line-info { color: var(--bs-body-color); }

/* Health metric cards — equal height via flexbox */
.health-card { border: 1px solid var(--bs-border-color); transition: border-color 0.15s; height: 100%; }
.health-card:hover { border-color: var(--bs-primary); }
.health-card .card-body { display: flex; flex-direction: column; min-height: 6rem; }
.health-card .health-spacer { flex: 1; }

/* ── Grafana-style chart panels ─────────────────── */
.chart-panel { border: 1px solid var(--bs-border-color); }
.chart-panel-header {
  padding: 0.4rem 0.75rem !important;
  border-bottom: 1px solid var(--bs-border-color);
  background: transparent;
}
.chart-panel-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--bs-body-color);
  letter-spacing: 0.01em;
}
.chart-panel-value {
  font-size: 1rem;
  font-weight: 700;
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Cascadia Mono', monospace;
}
.chart-panel-body {
  padding: 0 !important;
  position: relative;
  height: 160px;
  min-height: 160px;
  max-height: 160px;
  overflow: hidden;
}
.chart-panel-body canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Stat indicator cards (compact top bar) */
.panel-stat { border: 1px solid var(--bs-border-color); transition: border-color 0.15s; }
.panel-stat:hover { border-color: var(--bs-primary); }

/* Node hero header */
.node-hero { border-left: 3px solid var(--bs-primary); }

/* ── VM Console modal ───────────────────────────── */
.console-modal-content {
  border: 1px solid var(--bs-border-color);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.console-drag-handle {
  cursor: grab;
  user-select: none;
  border-bottom: 1px solid var(--bs-border-color);
}
.console-drag-handle:active { cursor: grabbing; }
.console-grip { opacity: 0.4; font-size: 1rem; cursor: grab; }
.console-grip:hover { opacity: 0.7; }
#vmConsoleDialog.is-dragging { transition: none !important; }

/* Toast container z-index */
.toast-z { z-index: 1090; }

/* Confirm modal must stack above other modals (e.g. VM details) */
#confirmModal { z-index: 1070; }

/* ── Explorer Node Cards ──────────────────────────── */
.node-card { border: 1px solid var(--bs-border-color); transition: border-color 0.2s, box-shadow 0.2s; }
.node-card:hover { border-color: var(--bs-primary); box-shadow: 0 4px 16px rgba(var(--bs-primary-rgb), 0.12); }

/* Mini slice grid */
.node-slice-grid { display: flex; flex-wrap: wrap; gap: 3px; }
.node-slice {
  width: 14px; height: 14px; border-radius: 3px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.node-slice:hover { transform: scale(1.3); }
.node-slice-free { background: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color); }
.node-slice-used { background: var(--status-ok); }

/* Logs viewer variants */
.logs-viewer-compact { max-height: 200px; font-family: monospace; font-size: 0.75rem; }
.logs-viewer-medium { max-height: 300px; font-family: monospace; font-size: 0.75rem; }

/* Deployment log panel */
.deploy-log-panel { max-height: 200px; overflow-y: auto; }

/* Explorer method list */
.explorer-method-scroll { max-height: calc(100vh - 16rem); overflow-y: auto; }

/* Clickable elements */
.clickable { cursor: pointer; }

/* Truncated text */
.text-truncate-300 { max-width: 300px; }

/* ── Animations ──────────────────────────────────── */

/* Fade-in for cards on load */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeSlideUp 0.4s ease-out both; }
.fade-in-1 { animation-delay: 0.05s; }
.fade-in-2 { animation-delay: 0.10s; }
.fade-in-3 { animation-delay: 0.15s; }
.fade-in-4 { animation-delay: 0.20s; }
.fade-in-5 { animation-delay: 0.25s; }
.fade-in-6 { animation-delay: 0.30s; }
.fade-in-7 { animation-delay: 0.35s; }
.fade-in-8 { animation-delay: 0.40s; }

/* Value counter pop */
@keyframes countPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.count-pop { animation: countPop 0.3s ease-out; }

/* Pulse glow on live-updating elements */
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(25, 135, 84, 0); }
  50%      { box-shadow: 0 0 8px 2px rgba(25, 135, 84, 0.25); }
}
.pulse-glow { animation: pulseGlow 2s infinite; }

/* Progress bar smooth transitions */
.progress-bar { transition: width 0.8s ease-in-out, background-color 0.3s; }

/* Sparkline canvas */
.sparkline-wrap { position: relative; height: 32px; margin-top: 4px; }
.sparkline-wrap canvas { width: 100%; height: 100%; border-radius: 4px; }

/* ── Skeleton loading placeholders ───────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skel {
  display: inline-block;
  background: linear-gradient(90deg,
    var(--bs-tertiary-bg) 25%,
    var(--bs-secondary-bg) 50%,
    var(--bs-tertiary-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
  vertical-align: middle;
  color: transparent !important; /* hide any fallback text */
}
.skel-value  { width: 3.5rem; height: 1.25rem; }
.skel-text   { width: 5rem;   height: 0.65rem; margin-top: 2px; }
.skel-spark  {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  border-radius: 4px;
  z-index: 1; /* sits above the empty canvas */
}

/* Slice map — utilization bar */
.slice-util-bar { height: 6px; border-radius: 3px; overflow: hidden; display: flex; }
.slice-util-bar .bar-seg { transition: width 0.6s ease-in-out; height: 100%; }
.slice-util-bar .bar-used { background: var(--status-ok); }
.slice-util-bar .bar-reserved { background: var(--status-warn); }
.slice-util-bar .bar-degraded { background: var(--status-error); }
.slice-util-bar .bar-free { background: var(--bs-tertiary-bg); }

/* Slice map — grid cells (parent card must not clip popovers) */
.slice-map-card { overflow: visible; }
.slice-map-card .card-body { overflow: visible; }
.slice-map { display: flex; flex-wrap: wrap; gap: 5px; position: relative; overflow: visible; }
.slice-map-cell {
  position: relative;
  width: 28px; height: 28px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700;
  transition: transform 0.15s, box-shadow 0.15s;
  border: 1px solid var(--bs-border-color);
}
.slice-map-cell:hover { transform: scale(1.25); z-index: 20; box-shadow: 0 3px 12px rgba(0,0,0,0.35); }
.slice-map-free { background: var(--bs-tertiary-bg); color: var(--bs-secondary-color); }
.slice-map-used { background: var(--status-ok); color: #fff; }
.slice-map-reserved { background: var(--status-warn); color: #000; }
.slice-map-degraded { background: var(--status-error); color: #fff; }

/* Slice map — hover popover (anchored left to prevent clipping) */
.slice-popover {
  display: none; position: absolute; bottom: calc(100% + 6px); left: 0;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color); border-radius: 6px;
  padding: 6px 10px; white-space: nowrap; font-size: 0.7rem;
  font-weight: 400; box-shadow: 0 4px 16px rgba(0,0,0,0.3); z-index: 30;
  color: var(--bs-body-color); pointer-events: none;
}
.slice-popover::after {
  content: ''; position: absolute; top: 100%; left: 10px;
  border: 5px solid transparent; border-top-color: var(--bs-border-color);
}
.slice-map-cell:hover .slice-popover { display: block; }

/* Slice legend dots */
.slice-legend-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 2px; margin-right: 3px; vertical-align: middle;
}

/* Live dot pulse */
@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
.status-dot-live { animation: dotPulse 1.5s ease-in-out infinite; }

/* Activity feed slide-in */
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}
.activity-item { animation: slideIn 0.3s ease-out both; }

/* ── Utility classes (replacing inline styles) ── */
.progress-thin { height: 6px; }
.text-xxs { font-size: 0.5rem !important; }
.text-mono-sm { font-size: 0.75rem; }
.chart-body-lg { height: 140px; min-height: 140px; max-height: 140px; }
.chart-body-sm { height: 120px; min-height: 120px; max-height: 120px; }
.modal-narrow { max-width: 560px; }
.logs-viewer-vh { max-height: 65vh; font-size: 0.75rem; }
.text-purple { color: #6f42c1; }

/* API Explorer */
.method-list-item { cursor: pointer; padding: 0.35rem 0.75rem; font-size: 0.8rem; font-family: monospace; }
.method-list-item:hover { background: var(--bs-tertiary-bg); }
.method-list-item.active { background: var(--bs-primary); color: #fff; border-radius: 0.25rem; }
.rpc-terminal { background: var(--bs-tertiary-bg); border: 1px solid var(--bs-border-color); border-radius: 6px; padding: 0.75rem; font-family: monospace; font-size: 0.75rem; overflow-x: auto; white-space: pre-wrap; max-height: 400px; overflow-y: auto; }
