/* ============================================
   ML Compute Exchange - Interactive Demo
   Custom Styles & Animations
   ============================================ */

/* Base */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { font-family: 'Inter', system-ui, sans-serif; background: #030712; color: #e2e8f0; overflow-x: hidden; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #1e293b; }
::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* ---- Animated Mesh Background ---- */
.mesh-bg {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
  background: radial-gradient(ellipse at 20% 50%, rgba(6,182,212,0.08) 0%, transparent 50%),
              radial-gradient(ellipse at 80% 20%, rgba(139,92,246,0.06) 0%, transparent 50%),
              radial-gradient(ellipse at 50% 80%, rgba(16,185,129,0.05) 0%, transparent 50%),
              #030712;
}
.mesh-bg::before, .mesh-bg::after {
  content: ''; position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.4;
  animation: float 20s ease-in-out infinite;
}
.mesh-bg::before {
  width: 600px; height: 600px; top: -200px; left: -100px;
  background: radial-gradient(circle, rgba(6,182,212,0.15), transparent 70%);
}
.mesh-bg::after {
  width: 500px; height: 500px; bottom: -150px; right: -100px;
  background: radial-gradient(circle, rgba(139,92,246,0.12), transparent 70%);
  animation-delay: -10s; animation-direction: reverse;
}

/* Grid pattern overlay */
.grid-overlay {
  position: fixed; inset: 0; z-index: 1;
  background-image:
    linear-gradient(rgba(148,163,184,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
}

/* ---- Animations ---- */
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(40px, -30px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(30px, 40px) scale(1.02); }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes progressFill {
  from { width: 0%; }
}

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

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

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0.3; }
}

@keyframes scanline {
  0% { top: -10%; }
  100% { top: 110%; }
}

/* ---- Utility Classes ---- */
.fade-in-up { animation: fadeInUp 0.6s ease-out both; }
.fade-in { animation: fadeIn 0.4s ease-out both; }
.slide-in-left { animation: slideInLeft 0.5s ease-out both; }
.slide-in-right { animation: slideInRight 0.5s ease-out both; }
.scale-in { animation: scaleIn 0.4s ease-out both; }

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }
.delay-6 { animation-delay: 0.6s; }
.delay-7 { animation-delay: 0.7s; }
.delay-8 { animation-delay: 0.8s; }

/* ---- Glass Card ---- */
.glass {
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 12px;
}
.glass:hover {
  border-color: rgba(148, 163, 184, 0.2);
}
.glass-light {
  background: rgba(30, 41, 59, 0.5);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(148, 163, 184, 0.08);
  border-radius: 10px;
}

/* ---- Status Indicators ---- */
.status-dot {
  width: 10px; height: 10px; border-radius: 50%; position: relative; flex-shrink: 0;
}
.status-dot::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  animation: pulse-ring 2s ease-out infinite;
}
.status-dot.online { background: #10b981; }
.status-dot.online::after { background: rgba(16,185,129,0.3); }
.status-dot.offline { background: #ef4444; }
.status-dot.offline::after { background: rgba(239,68,68,0.3); }
.status-dot.switching { background: #f59e0b; }
.status-dot.switching::after { background: rgba(245,158,11,0.3); animation-duration: 1s; }
.status-dot.maintenance { background: #6366f1; }
.status-dot.maintenance::after { background: rgba(99,102,241,0.3); }

/* ---- Toggle Switch ---- */
.toggle-track {
  width: 52px; height: 28px; border-radius: 14px; padding: 3px;
  cursor: pointer; transition: background 0.3s;
  background: #374151;
}
.toggle-track.active { background: #06b6d4; }
.toggle-thumb {
  width: 22px; height: 22px; border-radius: 50%; background: white;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle-track.active .toggle-thumb { transform: translateX(24px); }

/* ---- Sidebar ---- */
.sidebar {
  width: 260px; min-height: 100vh;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(20px);
  border-right: 1px solid rgba(148, 163, 184, 0.08);
}
.sidebar-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; margin: 2px 8px; border-radius: 8px;
  color: #94a3b8; cursor: pointer; transition: all 0.2s;
  font-size: 14px; font-weight: 500;
}
.sidebar-item:hover { background: rgba(148,163,184,0.08); color: #e2e8f0; }
.sidebar-item.active {
  background: rgba(6,182,212,0.1); color: #06b6d4;
  border: 1px solid rgba(6,182,212,0.2);
}
.sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 9999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
}
.badge-queued { background: rgba(148,163,184,0.15); color: #94a3b8; }
.badge-assigned { background: rgba(99,102,241,0.15); color: #818cf8; }
.badge-running { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-completed { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-failed { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-mining { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-ai { background: rgba(6,182,212,0.15); color: #22d3ee; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; border: none; outline: none;
}
.btn-primary {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  color: white; box-shadow: 0 2px 8px rgba(6,182,212,0.3);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  box-shadow: 0 4px 16px rgba(6,182,212,0.4);
  transform: translateY(-1px);
}
.btn-secondary {
  background: rgba(148,163,184,0.1); color: #e2e8f0;
  border: 1px solid rgba(148,163,184,0.2);
}
.btn-secondary:hover { background: rgba(148,163,184,0.2); }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); color: white; }
.btn-success:hover { background: linear-gradient(135deg, #34d399, #10b981); transform: translateY(-1px); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; }
.btn-danger:hover { background: linear-gradient(135deg, #f87171, #ef4444); transform: translateY(-1px); }

/* ---- Progress Bar ---- */
.progress-track {
  height: 6px; border-radius: 3px;
  background: rgba(148,163,184,0.15); overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #06b6d4, #22d3ee);
  transition: width 0.4s ease-out;
}

/* ---- Upload Dropzone ---- */
.dropzone {
  border: 2px dashed rgba(148,163,184,0.2);
  border-radius: 12px; padding: 48px;
  text-align: center; cursor: pointer;
  transition: all 0.3s;
}
.dropzone:hover, .dropzone.dragover {
  border-color: #06b6d4;
  background: rgba(6,182,212,0.05);
}
.dropzone.dragover {
  transform: scale(1.01);
  box-shadow: 0 0 30px rgba(6,182,212,0.1);
}

/* ---- Table ---- */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th {
  padding: 12px 16px; text-align: left; font-size: 12px;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  color: #64748b; border-bottom: 1px solid rgba(148,163,184,0.1);
}
.data-table td {
  padding: 14px 16px; font-size: 14px;
  border-bottom: 1px solid rgba(148,163,184,0.05);
}
.data-table tr { transition: background 0.2s; cursor: pointer; }
.data-table tr:hover { background: rgba(148,163,184,0.05); }

/* ---- Server Card ---- */
.server-card {
  position: relative; overflow: hidden;
  transition: all 0.3s;
}
.server-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.server-card .mode-indicator {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.server-card .mode-indicator.mining {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.server-card .mode-indicator.ai {
  background: linear-gradient(90deg, #06b6d4, #22d3ee);
}

/* ---- Heatmap Canvas ---- */
.heatmap-container {
  position: relative; border-radius: 8px; overflow: hidden;
  background: #1e293b;
}
.heatmap-container canvas { display: block; width: 100%; }
.heatmap-scanline {
  position: absolute; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(6,182,212,0.5), transparent);
  animation: scanline 3s linear infinite;
  pointer-events: none;
}

/* ---- Gauge ---- */
.gauge-ring {
  transform: rotate(-90deg);
}
.gauge-bg { stroke: rgba(148,163,184,0.1); }
.gauge-fill {
  transition: stroke-dashoffset 1.5s cubic-bezier(0.4,0,0.2,1);
}

/* ---- Role Cards on Landing ---- */
.role-card {
  position: relative; overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4,0,0.2,1);
}
.role-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.role-card::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(6,182,212,0.05));
  opacity: 0; transition: opacity 0.4s;
}
.role-card:hover::before { opacity: 1; }

/* ---- Metric Card ---- */
.metric-card {
  position: relative; overflow: hidden;
}
.metric-card::after {
  content: ''; position: absolute; top: 0; right: 0;
  width: 80px; height: 80px; border-radius: 50%;
  filter: blur(40px); opacity: 0.15;
}
.metric-card.cyan::after { background: #06b6d4; }
.metric-card.emerald::after { background: #10b981; }
.metric-card.violet::after { background: #8b5cf6; }
.metric-card.amber::after { background: #f59e0b; }

/* ---- Shimmer loading ---- */
.shimmer {
  background: linear-gradient(90deg, transparent, rgba(148,163,184,0.05), transparent);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ---- Toast ---- */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 500;
  animation: slideInRight 0.3s ease-out;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.toast-success {
  background: rgba(16,185,129,0.15);
  border: 1px solid rgba(16,185,129,0.3);
  color: #34d399;
}
.toast-info {
  background: rgba(6,182,212,0.15);
  border: 1px solid rgba(6,182,212,0.3);
  color: #22d3ee;
}

/* ---- Verification Overlay ---- */
.detection-box {
  position: absolute; border: 2px solid #ef4444;
  border-radius: 4px; pointer-events: none;
}
.detection-label {
  position: absolute; top: -22px; left: -2px;
  background: #ef4444; color: white;
  padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}

/* ---- Chart Container ---- */
.chart-wrapper {
  position: relative; padding: 16px;
}
.chart-wrapper canvas {
  max-height: 280px;
}

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .sidebar { width: 220px; }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
}

/* ---- View Transitions ---- */
.view-enter {
  animation: fadeInUp 0.4s ease-out both;
}

/* ---- Notification dot ---- */
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #ef4444;
  position: absolute; top: -2px; right: -2px;
  animation: pulse-ring 2s infinite;
}

/* ---- Landing stats counter ---- */
.stat-value {
  font-variant-numeric: tabular-nums;
}

/* ---- Tab bar ---- */
.tab-bar {
  display: flex; gap: 4px; padding: 4px;
  background: rgba(15,23,42,0.5);
  border-radius: 10px;
  border: 1px solid rgba(148,163,184,0.08);
}
.tab-item {
  padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: #94a3b8; cursor: pointer;
  transition: all 0.2s;
}
.tab-item:hover { color: #e2e8f0; }
.tab-item.active {
  background: rgba(6,182,212,0.1);
  color: #06b6d4;
}

/* ---- Spinner ---- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(148,163,184,0.2);
  border-top-color: #06b6d4;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---- Technical Details Layer ---- */
.tech-toggle {
  position: fixed; bottom: 24px; right: 24px; z-index: 9998;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 12px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all 0.3s;
  border: 1px solid rgba(251,146,60,0.3);
  background: rgba(251,146,60,0.1);
  color: #fb923c;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.tech-toggle:hover {
  background: rgba(251,146,60,0.2);
  border-color: rgba(251,146,60,0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(251,146,60,0.15);
}
.tech-toggle.active {
  background: rgba(251,146,60,0.2);
  border-color: #fb923c;
  box-shadow: 0 0 20px rgba(251,146,60,0.2);
}
.tech-toggle svg { width: 16px; height: 16px; }

.tech-panel {
  margin-top: 16px;
  padding: 20px;
  border-radius: 10px;
  background: rgba(251,146,60,0.04);
  border: 1px solid rgba(251,146,60,0.15);
  animation: fadeInUp 0.4s ease-out both;
  position: relative;
}
.tech-panel::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, #fb923c, #f59e0b, transparent);
  border-radius: 10px 10px 0 0;
}
.tech-panel-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid rgba(251,146,60,0.1);
}
.tech-panel-header svg { width: 16px; height: 16px; color: #fb923c; flex-shrink: 0; }
.tech-panel-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: #fb923c;
}
.tech-panel-source {
  margin-left: auto;
  font-size: 10px; font-weight: 600;
  padding: 2px 8px; border-radius: 4px;
  background: rgba(251,146,60,0.1);
  color: #fdba74;
  white-space: nowrap;
}
.tech-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}
.tech-item {
  padding: 10px 12px; border-radius: 8px;
  background: rgba(15,23,42,0.5);
  border: 1px solid rgba(148,163,184,0.06);
}
.tech-item-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: #64748b; margin-bottom: 4px;
}
.tech-item-value {
  font-size: 12px; color: #e2e8f0;
}
.tech-code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px; color: #22d3ee;
  background: rgba(6,182,212,0.08);
  padding: 1px 6px; border-radius: 4px;
}
.tech-endpoint {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 6px;
  background: rgba(15,23,42,0.5);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px; margin-bottom: 4px;
}
.tech-method {
  padding: 2px 6px; border-radius: 3px;
  font-size: 10px; font-weight: 700;
  flex-shrink: 0;
}
.tech-method.get { background: rgba(16,185,129,0.15); color: #34d399; }
.tech-method.post { background: rgba(6,182,212,0.15); color: #22d3ee; }
.tech-method.put { background: rgba(245,158,11,0.15); color: #fbbf24; }
.tech-method.delete { background: rgba(239,68,68,0.15); color: #f87171; }
.tech-endpoint-path { color: #94a3b8; }
.tech-note {
  font-size: 11px; color: #94a3b8; line-height: 1.6;
  padding: 8px 0 0;
}
.tech-flow {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap; padding: 8px 0;
}
.tech-flow-step {
  padding: 4px 10px; border-radius: 6px;
  font-size: 11px; font-weight: 500;
  background: rgba(148,163,184,0.08);
  color: #cbd5e1;
  border: 1px solid rgba(148,163,184,0.1);
}
.tech-flow-arrow { color: #475569; font-size: 12px; }
.tech-schema {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px; color: #94a3b8; line-height: 1.7;
  padding: 10px 14px; border-radius: 8px;
  background: rgba(15,23,42,0.6);
  border: 1px solid rgba(148,163,184,0.06);
  white-space: pre; overflow-x: auto;
}
