/* Reset & Base Fonts */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #05070d;
  color: #f1f5f9;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Glassmorphism Containers */
.glass-panel {
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
}

/* Main Layout Grid */
#app-container {
  display: grid;
  grid-template-rows: 64px 1fr;
  height: 100vh;
  width: 100vw;
}

/* Header Dashboard */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(10, 14, 23, 0.9);
  border-bottom: 1px solid rgba(0, 243, 255, 0.2);
}

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

.brand-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 8px #00f3ff);
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, #00f3ff 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.brand span {
  font-size: 0.75rem;
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, #00f3ff 0%, #0066ff 100%);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 25px rgba(0, 243, 255, 0.5);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.8);
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.9);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.stat-pill strong {
  color: #00f3ff;
}

/* Main Split Content Area */
main {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 16px;
  padding: 16px;
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* Left Canvas & Viewport Panel */
.viewport-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  height: 100%;
}

.viewport-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.view-tabs {
  display: flex;
  gap: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: rgba(0, 243, 255, 0.15);
  color: #00f3ff;
  border: 1px solid rgba(0, 243, 255, 0.3);
}

.canvas-container {
  width: 100%;
  flex: 1;
  min-height: 0;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

#world-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Worldviews Matrix Gallery Grid Styles */
.worldviews-container {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  padding: 8px;
}

.worldviews-filter-bar {
  display: flex;
  gap: 12px;
}

.search-input {
  flex: 1;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(0, 243, 255, 0.3);
  border-radius: 8px;
  padding: 8px 14px;
  color: #fff;
  font-size: 0.85rem;
  outline: none;
}

.search-input:focus {
  border-color: #00f3ff;
  box-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
}

.search-select {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 8px 14px;
  color: #00f3ff;
  font-size: 0.85rem;
  outline: none;
}

.worldviews-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  overflow-y: auto;
  padding-right: 6px;
}

.agent-belief-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s ease;
}

.agent-belief-card:hover {
  border-color: #00f3ff;
  box-shadow: 0 0 15px rgba(0, 243, 255, 0.15);
}

.agent-belief-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

.agent-belief-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.agent-belief-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(30, 41, 59, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border: 2px solid #00f3ff;
}

.belief-list-compact {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  line-height: 1.35;
}

.belief-item-compact {
  display: flex;
  gap: 6px;
  background: rgba(30, 41, 59, 0.4);
  padding: 6px 8px;
  border-radius: 6px;
  border-left: 2px solid rgba(255, 255, 255, 0.2);
}

.belief-item-compact.mutated {
  border-left-color: #a855f7;
  background: rgba(168, 85, 247, 0.12);
}

.belief-item-compact strong {
  color: #00f3ff;
}

/* Belief Mutation Live Stream Footer */
.mutation-stream {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

.mutation-stream-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #a855f7;
  font-weight: 700;
}

.stream-container {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  padding: 8px;
}

.stream-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 10px;
  padding: 10px 16px;
}

.mutation-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
  overflow-y: auto;
  padding-right: 6px;
}

.mutation-card {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.82rem;
  animation: slideIn 0.3s ease;
  transition: all 0.2s ease;
}

.mutation-card:hover {
  border-color: #00f3ff;
  box-shadow: 0 0 15px rgba(168, 85, 247, 0.25);
}

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

.mutation-card-agent {
  font-weight: 700;
  color: #00f3ff;
}

.mutation-card-diff {
  color: #94a3b8;
  font-size: 0.72rem;
  line-height: 1.3;
}

.mutation-card-diff del {
  color: #ef4444;
  text-decoration: line-through;
}

.mutation-card-diff ins {
  color: #10b981;
  text-decoration: none;
  font-weight: 600;
}

/* Right Sidebar Panels */
.sidebar-panel {
  display: grid;
  grid-template-rows: 240px 1fr;
  gap: 12px;
  overflow: hidden;
}

/* Leaderboard & Epiphany Meter */
.awareness-leaderboard {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.section-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.leader-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(15, 23, 42, 0.6);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: all 0.2s ease;
}

.leader-item:hover {
  border-color: #00f3ff;
  background: rgba(0, 243, 255, 0.05);
}

.leader-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.leader-progress-bg {
  width: 90px;
  height: 8px;
  background: rgba(51, 65, 85, 0.6);
  border-radius: 999px;
  overflow: hidden;
}

.leader-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #00f3ff 0%, #a855f7 100%);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Live Feed / Dialogue Ticker */
.dialogue-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  overflow: hidden;
}

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
}

.feed-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: fadeIn 0.3s ease;
}

.feed-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #94a3b8;
}

.feed-card-header strong {
  color: #f8fafc;
}

.feed-inspiration {
  background: rgba(0, 243, 255, 0.1);
  color: #00f3ff;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.72rem;
}

.feed-dialogue-line {
  font-size: 0.8rem;
  line-height: 1.4;
  color: #cbd5e1;
}

.feed-dialogue-line span {
  font-weight: 600;
}

/* Agent Inspector Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  width: 650px;
  max-height: 85vh;
  background: #0f172a;
  border: 1px solid rgba(0, 243, 255, 0.3);
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  box-shadow: 0 0 50px rgba(0, 243, 255, 0.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 12px;
}

.modal-agent-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-agent-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(30, 41, 59, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border: 2px solid #00f3ff;
}

.modal-understandings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.understanding-item {
  display: flex;
  gap: 10px;
  background: rgba(30, 41, 59, 0.5);
  padding: 10px 12px;
  border-radius: 8px;
  border-left: 3px solid #00f3ff;
  font-size: 0.85rem;
  line-height: 1.4;
}

.understanding-num {
  font-weight: 800;
  color: #00f3ff;
}

/* Victory Epiphany Modal */
.epiphany-modal {
  width: 700px;
  background: linear-gradient(135deg, #0b0f19 0%, #170d2b 100%);
  border: 2px solid #00f3ff;
  box-shadow: 0 0 80px rgba(0, 243, 255, 0.4);
  text-align: center;
  padding: 32px;
}

.epiphany-header-badge {
  display: inline-block;
  background: linear-gradient(90deg, #ff00ff, #00f3ff);
  color: #000;
  font-weight: 900;
  text-transform: uppercase;
  padding: 4px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  margin-bottom: 16px;
  animation: pulse 1.5s infinite;
}

.epiphany-quote-box {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(0, 243, 255, 0.3);
  padding: 20px;
  border-radius: 12px;
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.6;
  color: #e2e8f0;
  margin: 16px 0;
  position: relative;
}

/* Animations */
@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 10px #00f3ff; }
  50% { transform: scale(1.05); box-shadow: 0 0 25px #ff00ff; }
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 243, 255, 0.6);
}
