/* Core Design System & Theme Variables (Premium Glassmorphism Dark Mode) */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Color Palette */
  --bg-primary: #0a0e1a;
  --bg-secondary: #10172a;
  --bg-card: rgba(16, 23, 42, 0.65);
  --bg-glass: rgba(15, 23, 42, 0.45);
  
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-active: rgba(99, 102, 241, 0.3);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  /* Status Colors */
  --color-live: #10b981;
  --color-live-glow: rgba(16, 185, 129, 0.3);
  --color-degraded: #f59e0b;
  --color-degraded-glow: rgba(245, 158, 11, 0.3);
  --color-down: #ef4444;
  --color-down-glow: rgba(239, 68, 68, 0.4);
  --color-not-built: #475569;
  --color-not-built-glow: rgba(71, 85, 105, 0.1);
  --color-external: #06b6d4;
  --color-external-glow: rgba(6, 182, 212, 0.3);

  /* Brand Accents */
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.4);
  --secondary: #3b82f6;
  --secondary-glow: rgba(59, 130, 246, 0.3);
  --accent: #a855f7;
  --accent-glow: rgba(168, 85, 247, 0.3);
  
  /* Font Families */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Card Effects */
  --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  --blur-glass: 12px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.02) 0%, transparent 60%);
  background-attachment: fixed;
}

/* Header & Typography */
header {
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background: rgba(10, 14, 26, 0.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-glass);
  z-index: 100;
}

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

.brand-logo {
  height: 38px;
  width: auto;
}

.brand-title {
  display: flex;
  flex-direction: column;
}

.brand-title h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(to right, #f8fafc, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-title span {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.stat-val {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary);
}

.stat-lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Main Layout */
.app-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  width: 360px;
  background: var(--bg-glass);
  backdrop-filter: blur(var(--blur-glass));
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  transition: all 0.3s ease;
  z-index: 10;
}

.sidebar.right {
  border-right: none;
  border-left: 1px solid var(--border-glass);
}

.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-content {
  flex: 1;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Central Topology View */
.main-viewport {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.map-container {
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  cursor: grab;
}

.map-container:active {
  cursor: grabbing;
}

/* Department Cards */
.dept-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 1.25rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.dept-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--color-not-built);
}

.dept-card.live::before { background: var(--color-live); }
.dept-card.partial::before { background: var(--color-degraded); }
.dept-card.not_built::before { background: var(--color-not-built); }

.dept-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-glass-active);
  box-shadow: var(--shadow-premium);
}

.dept-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.dept-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.dept-score {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
}

.dept-score.high { color: var(--color-live); background: rgba(16, 185, 129, 0.1); }
.dept-score.mid { color: var(--color-degraded); background: rgba(245, 158, 11, 0.1); }
.dept-score.low { color: var(--color-down); background: rgba(239, 68, 68, 0.1); }
.dept-score.none { color: var(--text-muted); }

.dept-details {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.dept-detail-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dept-status-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* AI Advisor Floating Panel */
.ai-advisor-panel {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 380px;
  max-height: 480px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass-active);
  border-radius: 16px;
  box-shadow: var(--shadow-premium), 0 0 20px rgba(99, 102, 241, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 50;
  transition: all 0.3s ease;
}

.ai-advisor-header {
  padding: 1rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(168, 85, 247, 0.15));
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-advisor-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

.ai-advisor-content {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rec-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  padding: 0.75rem;
  font-size: 0.8rem;
  line-height: 1.4;
  cursor: pointer;
  transition: all 0.2s ease;
}

.rec-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(99, 102, 241, 0.2);
}

.rec-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
}

.rec-badge.quick { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.rec-badge.module { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.rec-badge.arch { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.rec-badge.critical { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.rec-title {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.rec-desc {
  color: var(--text-secondary);
  font-size: 0.75rem;
}

/* SVG Map Elements & Animations */
.node-circle {
  transition: all 0.3s ease;
}

.node-group {
  cursor: pointer;
}

.node-group:hover .node-circle {
  filter: drop-shadow(0 0 8px var(--glow-color));
}

.glow-live {
  animation: pulse-live 2s infinite ease-in-out;
}

.glow-degraded {
  animation: pulse-degraded 1.5s infinite ease-in-out;
}

.glow-down {
  animation: pulse-down 1s infinite ease-in-out;
}

@keyframes pulse-live {
  0%, 100% { filter: drop-shadow(0 0 2px var(--color-live-glow)); }
  50% { filter: drop-shadow(0 0 10px var(--color-live)); }
}

@keyframes pulse-degraded {
  0%, 100% { filter: drop-shadow(0 0 2px var(--color-degraded-glow)); }
  50% { filter: drop-shadow(0 0 10px var(--color-degraded)); }
}

@keyframes pulse-down {
  0%, 100% { filter: drop-shadow(0 0 2px var(--color-down-glow)); }
  50% { filter: drop-shadow(0 0 12px var(--color-down)); }
}

/* Path Animations for Data Streams */
.connection-path {
  fill: none;
  stroke: var(--stroke-color, var(--color-not-built));
  stroke-width: 1.5px;
  transition: stroke 0.3s ease;
}

.connection-path.active {
  stroke-dasharray: 6, 6;
  animation: dash 20s linear infinite;
}

@keyframes dash {
  to {
    stroke-dashoffset: -1000;
  }
}

/* Details Popup Overlay */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.popup-card {
  background: #0f172a;
  border: 1px solid var(--border-glass-active);
  border-radius: 16px;
  width: 500px;
  max-width: 90%;
  box-shadow: var(--shadow-premium);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}

.popup-overlay.active .popup-card {
  transform: translateY(0);
}

.popup-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
}

.popup-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.popup-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.popup-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-glass);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.01);
}

.btn {
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: #4f46e5;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.popup-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
}

.popup-close:hover {
  color: var(--text-primary);
}

.popup-metric-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.popup-metric-lbl {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.popup-metric-val {
  font-weight: 500;
  font-size: 0.85rem;
}

/* Architecture Timeline */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-left: 0.5rem;
}

.timeline-item {
  position: relative;
  padding-left: 1.5rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--timeline-color, var(--color-not-built));
  box-shadow: 0 0 6px var(--timeline-color);
  z-index: 2;
}

.timeline-item::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 13px;
  width: 2px;
  height: calc(100% + 0.5rem);
  background: rgba(255, 255, 255, 0.05);
  z-index: 1;
}

.timeline-item:last-child::after {
  display: none;
}

.timeline-item.done { --timeline-color: var(--color-live); }
.timeline-item.working { --timeline-color: var(--color-degraded); }
.timeline-item.pending { --timeline-color: var(--color-not-built); }

.timeline-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.timeline-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Mini Live Feed */
.live-feed {
  max-height: 120px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
}

.feed-item {
  display: flex;
  gap: 0.5rem;
}

.feed-time {
  color: var(--text-muted);
  flex-shrink: 0;
}

.feed-msg.success { color: var(--color-live); }
.feed-msg.warning { color: var(--color-degraded); }
.feed-msg.danger { color: var(--color-down); }

/* View Toggle Bar */
.view-toggle-bar {
  position: absolute;
  top: 16px;
  left: 24px;
  display: flex;
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  padding: 4px;
  z-index: 40;
}

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.view-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.view-btn.active {
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

/* Grid View styling */
.grid-view-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 80px 24px 24px 24px;
  overflow-y: auto;
  z-index: 20;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.grid-category-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.grid-category-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  border-left: 3px solid var(--primary);
  padding-left: 0.5rem;
}

.grid-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.grid-node-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 1.25rem;
  transition: all 0.2s ease;
  position: relative;
}

.grid-node-card:hover {
  border-color: var(--border-glass-active);
  transform: translateY(-2px);
}

.grid-node-status {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  font-size: 0.7rem;
  font-weight: bold;
}

.grid-node-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
  padding-right: 4rem;
}

.grid-node-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.grid-node-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.03);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Advisor Panel Collapse State */
.ai-advisor-panel.collapsed {
  max-height: 48px;
  overflow: hidden;
}

.ai-advisor-panel.collapsed .ai-advisor-content {
  display: none;
}

.advisor-toggle-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.advisor-toggle-btn:hover {
  background: rgba(255,255,255,0.05);
  color: white;
}

/* Fullscreen Map Mode */
.map-container.fullscreen-mode {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999 !important;
  background-color: var(--bg-primary) !important;
  margin: 0 !important;
  border-radius: 0 !important;
}

.map-container.fullscreen-mode svg {
  width: 100% !important;
  height: 100% !important;
}

/* Floating Controls */
.map-controls {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  gap: 0.5rem;
  z-index: 10000;
}

.map-control-btn {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.85rem;
  backdrop-filter: blur(8px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-premium);
}

.map-control-btn:hover {
  background: var(--border-glass-active);
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
  transform: translateY(-1px);
}

.map-control-btn:active {
  transform: translateY(0);
}

