/* American Captain font */
@font-face {
  font-family: 'American Captain';
  src: url('/fonts/american-captain.ttf') format('truetype'),
       url('/fonts/american-captain.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

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

/* Base — Pleiadian Records deep void aesthetic */
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #020208;
  color: #c5cae9;
  min-height: 100vh;
  position: relative;
}

/* Stretched background image at 40% opacity */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: url('/images/bg-mycelium.jpg') center / cover no-repeat;
  opacity: 0.25;
  z-index: -2;
  pointer-events: none;
}

/* Logo-XL centered behind panes at 50% opacity */
body::after {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  height: 500px;
  background: url('/images/logo-xl-bg.png') center / contain no-repeat;
  opacity: 0.50;
  z-index: -1;
  pointer-events: none;
}

/* Header */
header {
  background: rgba(6, 6, 15, 0.80);
  padding: 16px 24px;
  border-bottom: 1px solid rgba(79, 195, 247, 0.08);
  display: flex;
  align-items: center;
  gap: 16px;
}

header .header-logo {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  object-fit: contain;
  transition: opacity 0.15s;
}

header .header-logo:hover {
  content: url('/images/logo-dash-on.png');
}

header h1 {
  font-family: 'American Captain', system-ui, sans-serif;
  font-size: 1.6rem;
  color: #e8eaf6;
  font-weight: normal;
  letter-spacing: 2px;
  text-transform: uppercase;
}

header .subtitle {
  font-size: 0.85rem;
  color: #3d97c4;
}

/* Alert Banner */
.alert-banner {
  background: rgba(220, 38, 38, 0.75);
  color: #fff;
  padding: 4px 24px;
  font-family: 'American Captain', system-ui, sans-serif;
  font-weight: normal;
  font-size: 0.85rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  text-align: center;
  animation: pulse 2s ease-in-out infinite;
}

.alert-banner.hidden {
  display: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Status Bar */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  background: rgba(6, 6, 15, 0.80);
  border-bottom: 1px solid rgba(79, 195, 247, 0.06);
  padding: 8px 24px;
}

.status-item {
  display: flex;
  flex-direction: column;
  padding: 8px 16px;
  min-width: 120px;
}

.status-item label {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #888;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.status-item span {
  font-size: 1rem;
  font-weight: 500;
  color: #e8eaf6;
  font-variant-numeric: tabular-nums;
}

/* Status bar actions (refresh button) */
.status-bar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  padding: 0 8px;
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(79, 195, 247, 0.04);
  border: 1px solid rgba(79, 195, 247, 0.10);
  color: #3d97c4;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  white-space: nowrap;
}

.refresh-btn:hover {
  background: rgba(79, 195, 247, 0.08);
  color: #4fc3f7;
  border-color: rgba(79, 195, 247, 0.20);
  box-shadow: 0 0 8px rgba(79, 195, 247, 0.06);
}

.refresh-btn:active {
  background: rgba(79, 195, 247, 0.02);
}

.refresh-icon {
  font-size: 1rem;
  line-height: 1;
  display: inline-block;
  transition: transform 0.4s ease;
}

.refresh-btn.spinning .refresh-icon {
  animation: spin 0.5s linear;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* State color classes — Pleiadian palette */
.state-sleeping { color: #ffd54f; }
.state-waking   { color: #4fc3f7; }
.state-running  { color: #69f0ae; }
.state-dead     { color: #ef4444; }
.state-unknown  { color: #3d97c4; }

/* Tier color classes — Pleiadian palette */
.tier-normal       { color: #69f0ae; }
.tier-low_compute  { color: #ffd54f; }
.tier-critical     { color: #e040fb; }
.tier-dead         { color: #ef4444; }

/* Process indicator */
.process-alive { color: #69f0ae; }
.process-dead  { color: #ef4444; }

/* Tab navigation */
.tab-nav {
  display: flex;
  gap: 0;
  background: rgba(6, 6, 15, 0.80);
  border-bottom: 1px solid rgba(79, 195, 247, 0.06);
  padding: 0 24px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tab-nav::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #3d97c4;
  font-family: 'American Captain', system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: normal;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 12px 18px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1);
  white-space: nowrap;
  outline: none;
}

.tab-btn:hover {
  color: #4fc3f7;
  background: rgba(79, 195, 247, 0.03);
  text-shadow: 0 0 8px rgba(79, 195, 247, 0.15);
}

.tab-btn.active {
  color: #e8eaf6;
  border-bottom-color: #4fc3f7;
  text-shadow: 0 0 6px rgba(79, 195, 247, 0.20);
}

/* Tab panels */
.tab-panel {
  display: block;
}

.tab-panel.hidden {
  display: none;
}

/* Main content */
main {
  padding: 24px;
}

/* Overview grid */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

/* Panel card */
.panel {
  background: rgba(6, 6, 15, 0.80);
  border: 1px solid rgba(79, 195, 247, 0.08);
  border-radius: 8px;
  overflow: hidden;
}

.panel-header {
  font-family: 'American Captain', system-ui, sans-serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #3d97c4;
  font-weight: normal;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(79, 195, 247, 0.06);
}

.panel-body {
  padding: 16px;
}

.muted {
  color: #5c6bc0;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Stat rows */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(79, 195, 247, 0.04);
  font-size: 0.9rem;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  color: #888;
}

/* Coming soon placeholders */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
  gap: 12px;
}

.coming-soon-icon {
  font-size: 3rem;
  opacity: 0.4;
}

.coming-soon-title {
  font-family: 'American Captain', system-ui, sans-serif;
  font-size: 1.5rem;
  font-weight: normal;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #3d97c4;
}

.coming-soon-desc {
  font-size: 0.9rem;
  color: #666;
  max-width: 420px;
  line-height: 1.5;
}

/* Control panel */
#control-panel {
  padding: 16px 24px;
  display: flex;
  gap: 12px;
  align-items: center;
  background: rgba(6, 6, 15, 0.80);
  border-bottom: 1px solid rgba(79, 195, 247, 0.06);
}

/* Control buttons */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn-start {
  background: #69f0ae;
  color: #020208;
  font-weight: 700;
}

.btn-start:hover:not(:disabled) {
  background: #4ade80;
  box-shadow: 0 0 12px rgba(105, 240, 174, 0.15);
}

.btn-stop {
  background: #e040fb;
  color: #fff;
}

.btn-stop:hover:not(:disabled) {
  background: #ce39e0;
  box-shadow: 0 0 12px rgba(224, 64, 251, 0.15);
}

.btn:disabled,
.btn-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Conversations --- */
.turn { border: 1px solid rgba(79, 195, 247, 0.08); border-radius: 6px; margin-bottom: 8px; overflow: hidden; }
.turn-header { display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer; background: rgba(6, 6, 15, 0.80); transition: all 0.2s cubic-bezier(0.22, 1, 0.36, 1); }
.turn-header:hover { background: rgba(16, 16, 42, 0.80); }
.turn-header.expanded { background: rgba(16, 16, 42, 0.80); border-bottom: 1px solid rgba(79, 195, 247, 0.08); }
.expand-icon { font-size: 10px; color: #888; width: 14px; }
.turn-time { color: #4fc3f7; font-size: 13px; font-variant-numeric: tabular-nums; }
.turn-state { color: #888; font-size: 12px; }
.turn-tools { color: #aaa; font-size: 12px; }
.turn-cost { color: #888; font-size: 12px; margin-left: auto; }
.turn-detail { padding: 14px; background: rgba(2, 2, 8, 0.80); }
.turn-section { margin-bottom: 12px; }
.turn-section > label { display: block; font-size: 11px; color: #888; text-transform: uppercase; margin-bottom: 4px; }
.thinking-block { white-space: pre-wrap; word-break: break-word; max-height: 400px; overflow-y: auto; font-size: 13px; color: #c5cae9; background: rgba(16, 16, 42, 0.80); padding: 10px; border-radius: 4px; }
.tool-call { border: 1px solid rgba(79, 195, 247, 0.06); border-radius: 4px; margin-bottom: 6px; }
.tool-call-header { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; background: rgba(16, 16, 42, 0.80); font-size: 13px; transition: background 0.15s; }
.tool-call-header:hover { background: #14143a; }
.tool-call-header.expanded { border-bottom: 1px solid rgba(79, 195, 247, 0.06); }
.tool-name { color: #4fc3f7; font-weight: 600; }
.tool-duration { color: #888; font-size: 11px; }
.tool-error { color: #ff5252; font-size: 11px; font-weight: 600; }
.tool-call-detail { padding: 10px; background: rgba(2, 2, 8, 0.80); }
.tool-section { margin-bottom: 8px; }
.tool-section > label { display: block; font-size: 10px; color: #666; text-transform: uppercase; margin-bottom: 2px; }
.tool-section pre { white-space: pre-wrap; word-break: break-word; max-height: 300px; overflow-y: auto; font-size: 12px; color: #ccc; background: #111; padding: 8px; border-radius: 4px; }
.error-text { color: #ff5252; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 12px 0; }
.page-btn { background: rgba(79, 195, 247, 0.04); color: #4fc3f7; border: 1px solid rgba(79, 195, 247, 0.10); border-radius: 4px; padding: 6px 14px; cursor: pointer; font-size: 13px; transition: all 0.15s; }
.page-btn:hover:not(:disabled) { background: rgba(79, 195, 247, 0.08); box-shadow: 0 0 6px rgba(79, 195, 247, 0.06); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { color: #888; font-size: 13px; }
.empty-state { text-align: center; padding: 40px; color: #666; font-size: 14px; }

/* --- Config Tab --- */
.config-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.btn-sm { padding: 6px 14px; font-size: 12px; border-radius: 4px; border: 1px solid #333; background: #16213e; color: #e0e0e0; cursor: pointer; }
.btn-sm:hover { background: #222244; }
.btn-primary { background: #1565c0; border-color: #1565c0; color: #fff; }
.btn-primary:hover { background: #1976d2; }
.btn-sm.active { background: #c62828; border-color: #c62828; color: #fff; }
.config-section { margin-bottom: 16px; border: 1px solid rgba(79, 195, 247, 0.08); border-radius: 6px; overflow: hidden; }
.config-section h3 { padding: 8px 14px; background: rgba(6, 6, 15, 0.80); font-family: 'American Captain', system-ui, sans-serif; font-size: 14px; font-weight: normal; letter-spacing: 1.5px; text-transform: uppercase; color: #4fc3f7; border-bottom: 1px solid rgba(79, 195, 247, 0.06); }
.config-fields { padding: 10px 14px; }
.config-field { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.config-field label { width: 200px; font-size: 12px; color: #888; flex-shrink: 0; }
.config-field input { flex: 1; background: rgba(2, 2, 8, 0.80); border: 1px solid rgba(79, 195, 247, 0.08); border-radius: 4px; padding: 6px 10px; color: #c5cae9; font-size: 13px; font-family: monospace; transition: border-color 0.15s; }
.config-field input:focus { border-color: rgba(79, 195, 247, 0.25); outline: none; box-shadow: 0 0 6px rgba(79, 195, 247, 0.06); }
.config-field input[readonly] { opacity: 0.5; }
.sensitive-section { border-color: #c62828; }
.sensitive-section h3 { background: #2a0a0a; color: #ff5252; }
.toast { padding: 8px 16px; border-radius: 4px; font-size: 13px; margin-bottom: 10px; }
.toast-success { background: #1b5e20; color: #a5d6a7; }
.toast-error { background: #b71c1c; color: #ef9a9a; }

/* --- Soul Tab --- */
.soul-toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.soul-editor { width: 100%; min-height: 400px; background: rgba(2, 2, 8, 0.80); border: 1px solid rgba(79, 195, 247, 0.08); border-radius: 6px; padding: 14px; color: #c5cae9; font-size: 14px; font-family: 'Courier New', monospace; line-height: 1.6; resize: vertical; }
.soul-editor:focus { border-color: rgba(79, 195, 247, 0.25); outline: none; box-shadow: 0 0 8px rgba(79, 195, 247, 0.06); }

/* --- Heartbeat Tab --- */
.heartbeat-table { width: 100%; border-collapse: collapse; }
.heartbeat-table th { text-align: left; padding: 8px 12px; background: rgba(6, 6, 15, 0.80); color: #4fc3f7; font-family: 'American Captain', system-ui, sans-serif; font-size: 13px; font-weight: normal; letter-spacing: 1.5px; text-transform: uppercase; border-bottom: 1px solid rgba(79, 195, 247, 0.06); }
.heartbeat-table td { padding: 8px 12px; border-bottom: 1px solid rgba(79, 195, 247, 0.04); font-size: 13px; color: #c5cae9; }
.task-name { font-weight: 600; }
.task-cron code { color: #4fc3f7; font-size: 12px; }
.task-last-run { color: #888; font-size: 12px; }
.task-run-count { color: #888; text-align: center; }
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #333; border-radius: 20px; transition: 0.3s; }
.toggle-slider::before { content: ""; position: absolute; height: 14px; width: 14px; left: 3px; bottom: 3px; background: #888; border-radius: 50%; transition: 0.3s; }
.toggle input:checked + .toggle-slider { background: #1565c0; }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); background: #fff; }

/* --- Mycelium Tab --- */
#tab-mycelium {
  position: relative;
  padding: 0;
  overflow: hidden;
}

#tab-mycelium {
  height: calc(100vh - 120px);
}

#mycelium-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
}

/* --- Sidebar Panel (Revenue & Activity Feed) --- */

/* Sidebar overlay per D-01 -- positioned absolute inside #tab-mycelium */
.mycelium-sidebar {
  position: absolute;
  top: 0;
  right: 0;
  width: 360px;
  height: 100%;
  background: rgba(6, 6, 15, 0.80);
  border-left: 1px solid rgba(79, 195, 247, 0.12);
  transform: translateX(0);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mycelium-sidebar.collapsed {
  transform: translateX(100%);
}

/* Toggle button -- left: -36px positions it just outside the sidebar edge */
.sidebar-toggle {
  position: absolute;
  left: -36px;
  top: 16px;
  width: 32px;
  height: 32px;
  background: rgba(6, 6, 15, 0.80);
  border: 1px solid rgba(79, 195, 247, 0.15);
  border-right: none;
  border-radius: 4px 0 0 4px;
  color: #4fc3f7;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 11;
}

.sidebar-toggle:hover {
  background: rgba(79, 195, 247, 0.12);
}

/* Audio mute toggle -- positioned below sidebar toggle, matching visual style (D-05) */
.audio-toggle {
  position: absolute;
  left: -36px;
  top: 56px;
  width: 32px;
  height: 32px;
  background: rgba(6, 6, 15, 0.80);
  border: 1px solid rgba(79, 195, 247, 0.15);
  border-right: none;
  border-radius: 4px 0 0 4px;
  color: #6b7280;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  z-index: 20;
}

.audio-toggle:hover {
  background: rgba(79, 195, 247, 0.12);
}

/* Chrome blue when unmuted (D-06) */
.audio-toggle.unmuted {
  color: #4fc3f7;
  border-color: rgba(79, 195, 247, 0.3);
}

/* Flip chevron when open */
.mycelium-sidebar:not(.collapsed) .sidebar-toggle {
  transform: scaleX(-1);
}

/* Sidebar content area with scrolling */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(79, 195, 247, 0.2) transparent;
}

/* Section headings -- American Captain font, chrome blue */
.sidebar-heading {
  font-family: 'American Captain', system-ui, sans-serif;
  font-size: 18px;
  color: #4fc3f7;
  letter-spacing: 1.5px;
  margin-bottom: 12px;
}

/* Divider between revenue and activity sections */
.sidebar-divider {
  border: none;
  border-top: 1px solid rgba(79, 195, 247, 0.08);
  margin: 16px 0;
}

/* Revenue table rows */
.revenue-agent-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(79, 195, 247, 0.05);
  font-size: 13px;
}

.revenue-agent-name {
  color: #c5cae9;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.revenue-agent-values {
  display: flex;
  gap: 12px;
  font-variant-numeric: tabular-nums;
}

.revenue-earned { color: #69f0ae; }
.revenue-royalty { color: #e040fb; }
.revenue-net { color: #c5cae9; }

/* Colony totals section */
.colony-totals {
  background: rgba(79, 195, 247, 0.06);
  border: 1px solid rgba(79, 195, 247, 0.10);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.colony-totals-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}

.colony-totals-label {
  color: #7986cb;
  font-family: 'American Captain', system-ui, sans-serif;
  letter-spacing: 0.8px;
  font-size: 12px;
}

.colony-totals-value {
  font-variant-numeric: tabular-nums;
}

/* Activity feed items */
.activity-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(79, 195, 247, 0.05);
  font-size: 13px;
}

.activity-item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.activity-agent-name {
  color: #4fc3f7;
  font-weight: 500;
  font-size: 12px;
}

.activity-timestamp {
  color: #5c6bc0;
  font-size: 11px;
}

.activity-actions {
  color: #9fa8da;
  font-size: 12px;
  line-height: 1.4;
}

.activity-empty, .activity-unreachable {
  color: #5c6bc0;
  font-style: italic;
  padding: 16px 0;
  text-align: center;
  font-size: 13px;
}

/* Activity feed section should fill remaining space */
.sidebar-section-feed {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-section-feed #activity-content {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(79, 195, 247, 0.2) transparent;
}
