/* Modern Dark Cyber Glassmorphism & Antigravity Design System */
:root {
  --bg-primary: #0b0f19;
  --glass-bg: rgba(22, 30, 49, 0.65);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-pink: #ec4899;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Background Glow Effects */
.background-glow {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.15) 0%, rgba(139, 92, 246, 0.1) 40%, rgba(0,0,0,0) 70%);
  z-index: -1;
  pointer-events: none;
  filter: blur(60px);
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Glassmorphism Common Utilities */
.glass-card, .glass-header {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--glass-shadow);
  transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1), box-shadow 0.5s ease;
}

/* Antigravity Floating Effect */
@keyframes zeroGravityFloat {
  0% { transform: translateY(0px) rotate(0deg); }
  33% { transform: translateY(-7px) rotate(0.4deg); }
  66% { transform: translateY(5px) rotate(-0.4deg); }
  100% { transform: translateY(0px) rotate(0deg); }
}

.zero-gravity-active .glass-card {
  animation: zeroGravityFloat 6s ease-in-out infinite;
}

.zero-gravity-active .metric-card:nth-child(1) { animation-delay: 0s; }
.zero-gravity-active .metric-card:nth-child(2) { animation-delay: 1.2s; }
.zero-gravity-active .metric-card:nth-child(3) { animation-delay: 2.4s; }
.zero-gravity-active .metric-card:nth-child(4) { animation-delay: 3.6s; }

/* Header */
.glass-header {
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

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

.logo-icon {
  font-size: 1.8rem;
}

.brand h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand h1 span {
  color: var(--accent-cyan);
}

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

.toggle-card {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 14px;
  border-radius: 30px;
  border: 1px solid var(--glass-border);
  transition: all 0.2s ease;
}

.toggle-card:hover {
  background: rgba(255, 255, 255, 0.08);
}

.toggle-card input {
  accent-color: var(--accent-cyan);
}

/* Layout */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* Gauge Section */
.gauge-section {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  justify-content: space-between;
  min-height: 420px;
}

.network-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.25);
  color: var(--accent-cyan);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent-cyan);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.gauge-container {
  position: relative;
  margin: 10px 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.gauge-readout {
  position: absolute;
  bottom: 25px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.current-value {
  font-size: 2.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 0%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1;
}

.current-unit {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 4px;
}

.test-phase {
  font-size: 0.8rem;
  color: var(--accent-purple);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 6px;
}

/* Primary Button */
.primary-btn {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-blue) 100%);
  color: #fff;
  border: none;
  padding: 14px 40px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(6, 182, 212, 0.4);
  transition: all 0.3s ease;
  width: 80%;
  max-width: 280px;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(6, 182, 212, 0.6);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Real-Time Speed Graph Container */
.graph-container {
  width: 100%;
  height: 180px;
  margin-top: 20px;
  position: relative;
}

#speedChart {
  width: 100% !important;
  height: 100% !important;
  filter: drop-shadow(0 0 10px rgba(6, 182, 212, 0.4));
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.metric-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.metric-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.download-icon { color: var(--accent-cyan); }
.upload-icon { color: var(--accent-purple); }
.ping-icon { color: var(--accent-emerald); }
.game-icon { color: var(--accent-pink); }

.metric-body {
  margin-top: 14px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
}

.metric-unit {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.dual-metric {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.sub-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.metric-value-sm {
  font-size: 1.3rem;
  font-weight: 700;
}

.unit-sm {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Bufferbloat */
.bufferbloat-body {
  display: flex;
  align-items: center;
  gap: 14px;
}

.grade-badge {
  font-size: 1.6rem;
  font-weight: 800;
  padding: 4px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.grade-a-plus { background: rgba(16, 185, 129, 0.2); color: var(--accent-emerald); }
.grade-a { background: rgba(6, 182, 212, 0.2); color: var(--accent-cyan); }
.grade-b { background: rgba(59, 130, 246, 0.2); color: var(--accent-blue); }
.grade-c { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.grade-f { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

.grade-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* History Section */
.history-section {
  padding: 24px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.history-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.history-actions {
  display: flex;
  gap: 10px;
}

.secondary-btn, .ghost-btn {
  border: 1px solid var(--glass-border);
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}

.secondary-btn:hover { background: rgba(255, 255, 255, 0.12); }
.ghost-btn:hover { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

.table-wrapper {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.history-table th {
  padding: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--glass-border);
  font-weight: 600;
}

.history-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.empty-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 24px !important;
}

/* Real-Time Speed Chart Container */
.graph-container {
  width: 100%;
  height: 180px;
  margin-top: 20px;
  position: relative;
}

#speedChart {
  width: 100% !important;
  height: 100% !important;
  filter: drop-shadow(0 0 10px rgba(6, 182, 212, 0.45));
}

/* Footer Styling */
.app-footer {
  margin-top: 24px;
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border-radius: 12px;
}

.app-footer strong {
  color: #f8fafc;
  font-weight: 600;
}

/* ===== Live Speed Graph Section ===== */
/* ===== Info Cards Section ===== */
.info-cards-section {
  max-width: 860px;
  width: 100%;
  margin: 0 auto 2rem auto;
  padding: 0 1rem;
}

.info-section-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
}

.info-section-icon {
  font-size: 1.3rem;
}

.info-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
  margin: 0;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.info-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 640px) {
  .info-cards-grid {
    grid-template-columns: 1fr;
  }
}

.info-card {
  padding: 1.25rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.info-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(6, 182, 212, 0.15);
}

.info-card-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-card-icon {
  font-size: 1.4rem;
}

.info-card-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
}

.info-card-desc {
  font-size: 0.78rem;
  color: var(--text-secondary, #94a3b8);
  line-height: 1.5;
  margin: 0;
}

.info-rating-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.info-rating {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  color: var(--text-secondary, #94a3b8);
}

.rating-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.info-rating.excellent .rating-dot { background: #22c55e; box-shadow: 0 0 5px #22c55e88; }
.info-rating.good .rating-dot { background: #f59e0b; box-shadow: 0 0 5px #f59e0b88; }
.info-rating.poor .rating-dot { background: #ef4444; box-shadow: 0 0 5px #ef444488; }

.info-rating.excellent { color: #86efac; }
.info-rating.good { color: #fcd34d; }
.info-rating.poor { color: #fca5a5; }

.info-card-tip {
  font-size: 0.72rem;
  color: var(--accent-cyan, #06b6d4);
  margin: 0;
  padding-top: 0.25rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-style: italic;
}

/* ===== Live Speed Graph Section ===== */
.graph-section {
  margin: 0 auto 1.5rem auto;
  max-width: 860px;
  width: 100%;
  padding: 1.5rem 1.75rem;
}

.graph-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.graph-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.graph-icon {
  font-size: 1.25rem;
}

.graph-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary, #f8fafc);
  margin: 0;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.graph-legend {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 6px currentColor;
}

.legend-label {
  font-size: 0.8rem;
  color: var(--text-secondary, #94a3b8);
  font-weight: 500;
}

.graph-canvas-wrapper {
  position: relative;
  height: 220px;
  width: 100%;
}

.graph-canvas-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Remove old .graph-container if present */
.graph-container {
  display: none;
}
