/* Global Reset & Base Variables */
:root {
  --bg-primary: #0a0b10;
  --bg-secondary: rgba(20, 21, 30, 0.6);
  --card-bg: rgba(30, 32, 48, 0.4);
  --card-border: rgba(255, 255, 255, 0.07);
  --card-glow: rgba(0, 0, 0, 0.3);
  
  /* Harmonious Palette HSL values */
  --color-green: #10b981;
  --color-green-glow: rgba(16, 185, 129, 0.25);
  --color-yellow: #f59e0b;
  --color-yellow-glow: rgba(245, 158, 11, 0.25);
  --color-red: #ef4444;
  --color-red-glow: rgba(239, 68, 68, 0.25);
  --color-blue: #3b82f6;
  --color-blue-glow: rgba(59, 130, 246, 0.25);
  --color-purple: #8b5cf6;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #6b7280;
  
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --transition-speed: 0.3s;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* Glassmorphism background glowing orbs */
.glass-bg-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.25;
  mix-blend-mode: screen;
  animation: floatOrb 20s infinite ease-in-out alternate;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--color-blue) 0%, transparent 80%);
  top: -100px;
  right: -50px;
  animation-duration: 25s;
}

.orb-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--color-purple) 0%, transparent 80%);
  bottom: -200px;
  left: -100px;
  animation-duration: 30s;
}

.orb-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, var(--color-green) 0%, transparent 80%);
  top: 40%;
  left: 30%;
  animation-duration: 22s;
  opacity: 0.15;
}

@keyframes floatOrb {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(80px, 50px) scale(1.15);
  }
}

/* Dashboard Layout */
.dashboard-wrapper {
  width: 100%;
  max-width: 1200px;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  z-index: 1;
}

/* Header styling */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 1rem 1.75rem;
  border-radius: 1.25rem;
  box-shadow: 0 8px 32px 0 var(--card-glow);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-area h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #fff 0%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.pulse-icon {
  width: 14px;
  height: 14px;
  background-color: var(--color-blue);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--color-blue);
  position: relative;
}

.pulse-icon::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  border: 1px solid var(--color-blue);
  border-radius: 50%;
  animation: logoPulse 2s infinite ease-out;
}

@keyframes logoPulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.8); opacity: 0; }
}

.status-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all var(--transition-speed) ease;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-checking {
  background-color: var(--color-blue-glow);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.4);
}
.status-checking .badge-dot {
  background-color: var(--color-blue);
  box-shadow: 0 0 8px var(--color-blue);
  animation: badgeBlink 1s infinite alternate;
}

.status-connected {
  background-color: var(--color-green-glow);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
}
.status-connected .badge-dot {
  background-color: var(--color-green);
  box-shadow: 0 0 8px var(--color-green);
}

.status-warning {
  background-color: var(--color-yellow-glow);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}
.status-warning .badge-dot {
  background-color: var(--color-yellow);
  box-shadow: 0 0 8px var(--color-yellow);
}

.status-disconnected {
  background-color: var(--color-red-glow);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.4);
}
.status-disconnected .badge-dot {
  background-color: var(--color-red);
  box-shadow: 0 0 8px var(--color-red);
  animation: badgeBlink 0.5s infinite alternate;
}

@keyframes badgeBlink {
  0% { opacity: 0.4; }
  100% { opacity: 1; }
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.5rem;
}

/* Glass Card styling */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 8px 32px 0 var(--card-glow);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4);
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.card-header .subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Speedometer/Gauge Card specifically */
.main-gauge-card {
  grid-column: span 4;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.main-gauge-card .card-header {
  width: 100%;
  align-items: center;
}

.gauge-container {
  position: relative;
  width: 180px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(0deg);
}

.gauge-track {
  stroke: rgba(255, 255, 255, 0.05);
}

.gauge-fill {
  stroke: var(--color-blue);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease-out, stroke 0.4s ease;
  filter: drop-shadow(0 0 6px var(--color-blue-glow));
}

.gauge-value-box {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#ping-value {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -1px;
  font-family: var(--font-mono);
  line-height: 1;
}

#ping-value.loading {
  font-size: 2.25rem;
  color: var(--text-dark);
}

.gauge-value-box .unit {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 0.25rem;
}

.gauge-footer {
  font-size: 0.9rem;
  font-weight: 600;
}

.severity-text {
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
  transition: all 0.3s ease;
}

.severity-good { color: var(--color-green); }
.severity-medium { color: var(--color-yellow); }
.severity-poor { color: var(--color-red); }

/* Metrics Info Side Cards */
.metrics-container {
  grid-column: span 8;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.metric-card {
  flex-direction: row;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem;
}

.metric-icon {
  font-size: 1.75rem;
  width: 3.25rem;
  height: 3.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
}

.metric-data {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.metric-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-mono);
}

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

/* Latency History Chart Card */
.chart-card {
  grid-column: span 7;
}

.chart-header-row {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.chart-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.ping-dot { background-color: var(--color-blue); }
.avg-dot { background-color: var(--color-purple); }

.chart-container {
  position: relative;
  flex: 1;
  min-height: 220px;
  width: 100%;
}

#latency-chart {
  width: 100%;
  height: 100%;
  min-height: 220px;
}

/* Control Panel Card */
.control-card {
  grid-column: span 5;
}

.control-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.custom-select {
  background: rgba(20, 21, 30, 0.8);
  border: 1px solid var(--card-border);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(156,163,171,0.8)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.2em;
  padding-right: 2.5rem;
  transition: border-color var(--transition-speed);
}

.custom-select:focus {
  border-color: var(--color-blue);
  box-shadow: 0 0 8px var(--color-blue-glow);
}

.button-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  outline: none;
}

.btn-primary {
  background: var(--color-blue);
  color: #fff;
  box-shadow: 0 4px 12px var(--color-blue-glow);
}

.btn-primary:hover {
  background: #2563eb;
  transform: translateY(-1px);
}

.btn-primary.paused {
  background: var(--color-green);
  box-shadow: 0 4px 12px var(--color-green-glow);
}

.btn-primary.paused:hover {
  background: #059669;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--card-border);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

/* Diagnostic Console inside Control Panel */
.diagnostic-console {
  background: rgba(10, 11, 15, 0.85);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.console-header {
  background: rgba(20, 21, 30, 0.9);
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
}

.blink-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-green);
  box-shadow: 0 0 6px var(--color-green);
  animation: badgeBlink 0.8s infinite alternate;
}

.console-body {
  height: 100px;
  padding: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  color: #a7f3d0;
  scroll-behavior: smooth;
}

.log-line {
  line-height: 1.4;
}

.log-line.system {
  color: var(--text-muted);
}

.log-line.error {
  color: #f87171;
}

.log-line.warning {
  color: #fbbf24;
}

/* Footer styling */
.app-footer-bottom {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dark);
  margin-top: 1rem;
}

.app-footer-bottom strong {
  color: var(--text-muted);
}

#target-host {
  font-family: var(--font-mono);
}

/* Responsive Grid Tweaks */
@media (max-width: 1024px) {
  .main-gauge-card {
    grid-column: span 5;
  }
  .metrics-container {
    grid-column: span 7;
    grid-template-columns: 1fr;
  }
  .chart-card {
    grid-column: span 12;
  }
  .control-card {
    grid-column: span 12;
  }
}

@media (max-width: 640px) {
  .dashboard-wrapper {
    padding: 1rem;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
  .status-container {
    align-self: flex-end;
  }
  .main-gauge-card {
    grid-column: span 12;
  }
  .metrics-container {
    grid-column: span 12;
  }
  .dashboard-grid {
    gap: 1rem;
  }
}
