/* ==========================================================================
   B A C SPEEDTEST - DESIGN SYSTEM & THEME
   Inspired by officialbac.in & status.officialbac.in
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700;800;900&family=Righteous&family=JetBrains+Mono:wght@400;500;600;700;800&display=swap');

:root {
  --primary-emerald: #10b981;
  --primary-emerald-dark: #059669;
  --primary-teal: #0d9488;
  --primary-gradient: linear-gradient(135deg, #10b981 0%, #0d9488 100%);
  --primary-gradient-hover: linear-gradient(135deg, #059669 0%, #0f766e 100%);
  
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-secondary: #f1f5f9;
  --bg-surface-dark: #0f172a;
  
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-emerald: rgba(16, 185, 129, 0.25);
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-white: #ffffff;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
  --shadow-emerald: 0 8px 25px -4px rgba(16, 185, 129, 0.25);
  --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.4);

  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-brand: 'Righteous', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
}

/* Base Resets */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-main);
  background: radial-gradient(ellipse at top, #ffffff 0%, #f8fafc 50%, #f1f5f9 100%) no-repeat fixed;
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Typography Utility */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text-main);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.font-brand {
  font-family: var(--font-brand) !important;
}

.font-mono {
  font-family: var(--font-mono) !important;
}

/* Gradient Text */
.text-gradient-emerald {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Layout Containers */
.container {
  width: 100%;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

@media (min-width: 640px) {
  .container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

/* Cards & Surfaces (Official BAC Glassmorphism) */
.glass-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg), 0 0 20px -5px rgba(16, 185, 129, 0.08);
}

.glass-card-dark {
  background: #0f172a;
  border: 1px solid #1e293b;
  color: #ffffff;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.875rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: var(--shadow-emerald);
}

.btn-primary:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 10px 30px -2px rgba(16, 185, 129, 0.4);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background: var(--bg-surface-secondary);
  border-color: var(--border-strong);
  color: var(--primary-emerald-dark);
}

.btn-pill {
  border-radius: var(--radius-full);
}

.btn-lg {
  padding: 0.875rem 2rem;
  font-size: 1.125rem;
  border-radius: var(--radius-full);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.badge-emerald {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

.badge-teal {
  background: #f0fdfa;
  color: #0f766e;
  border-color: #99f6e4;
}

.badge-amber {
  background: #fffbeb;
  color: #b45309;
  border-color: #fde68a;
}

.badge-rose {
  background: #fff1f2;
  color: #be123c;
  border-color: #fecdd3;
}

.badge-dark {
  background: #0f172a;
  color: #34d399;
  border-color: #334155;
}

/* Pulse indicator */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-emerald);
  box-shadow: 0 0 10px var(--primary-emerald);
  position: relative;
}

.pulse-dot.pulse {
  animation: pulse-ring 2s cubic-bezier(0.455, 0.03, 0.515, 0.955) infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ==========================================================================
   HEADER / NAVBAR
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 50;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid var(--border-subtle);
  transition: all 0.3s ease;
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.875rem;
  padding-bottom: 0.875rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  background: var(--primary-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-brand);
  font-size: 1.25rem;
  font-weight: 900;
  box-shadow: var(--shadow-emerald);
  transition: transform 0.2s ease;
}

.brand-link:hover .brand-icon {
  transform: scale(1.05);
}

.brand-text {
  font-family: var(--font-brand);
  font-size: 1.5rem;
  letter-spacing: 0.05em;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-menu {
  display: none;
  align-items: center;
  gap: 1.5rem;
  list-style: none;
}

@media (min-width: 900px) {
  .nav-menu {
    display: flex;
  }
}

.nav-link {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s ease;
  padding: 0.5rem 0.25rem;
  position: relative;
}

.nav-link:hover, .nav-link.active {
  color: var(--primary-emerald-dark);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--primary-emerald);
  border-radius: 2px;
}

/* Mobile Toggle Button */
.mobile-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 1.25rem;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
}

.mobile-toggle-btn:hover {
  background: #f8fafc;
  color: var(--primary-emerald-dark);
  border-color: var(--border-emerald);
}

@media (min-width: 900px) {
  .mobile-toggle-btn {
    display: none;
  }
}

/* Mobile Navigation Drawer Overlay (Matches officialbac.in style) */
.mobile-drawer {
  position: fixed;
  top: 73px;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: calc(100vh - 73px);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: 45;
  border-top: 1px solid var(--border-subtle);
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 2rem 0 3rem;
}

.mobile-drawer.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

@media (min-width: 900px) {
  .mobile-drawer {
    display: none !important;
  }
}

.mobile-drawer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.mobile-nav-list {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  max-width: 380px;
  gap: 0.75rem;
  list-style: none;
}

.mobile-nav-item {
  width: 100%;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.mobile-nav-link:hover, .mobile-nav-link.active {
  border-color: var(--primary-emerald);
  color: var(--primary-emerald-dark);
  background: #f0fdf4;
  transform: translateX(4px);
}

/* ==========================================================================
   SPEEDTEST SPEEDOMETER GAUGE COMPONENT
   ========================================================================== */
.speedometer-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 1rem;
}

.gauge-wrapper {
  position: relative;
  width: 320px;
  height: 320px;
  max-width: 90vw;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 640px) {
  .gauge-wrapper {
    width: 380px;
    height: 380px;
  }
}

#speedGaugeCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Central Gauge Readout & Start Button */
.gauge-center-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.start-button-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-start-test {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: #0f172a;
  background: radial-gradient(circle at 30% 30%, #1e293b 0%, #0f172a 100%);
  border: 3px solid rgba(16, 185, 129, 0.4);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.4), 0 0 25px rgba(16, 185, 129, 0.2);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.btn-start-test:hover {
  transform: scale(1.08);
  border-color: #10b981;
  box-shadow: 0 15px 40px rgba(16, 185, 129, 0.4), 0 0 40px rgba(16, 185, 129, 0.5);
}

.btn-start-test:active {
  transform: scale(0.96);
}

.btn-start-test .btn-start-text {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.btn-start-test .btn-start-sub {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-light);
  margin-top: 2px;
}

/* Speed Real-time Counter (When Testing) */
.live-speed-display {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.live-speed-number {
  font-family: var(--font-mono);
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-main);
  letter-spacing: -0.03em;
}

@media (min-width: 640px) {
  .live-speed-number {
    font-size: 4.25rem;
  }
}

.live-speed-unit {
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary-emerald-dark);
  letter-spacing: 0.08em;
  margin-top: 4px;
}

.live-stage-indicator {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

/* ==========================================================================
   METRIC STAT CARDS
   ========================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.875rem;
}

@media (min-width: 768px) {
  .metrics-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
  }
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  transition: background 0.3s ease;
}

.metric-card.active-metric::before {
  background: var(--primary-gradient);
}

.metric-card.active-metric {
  border-color: #10b981;
  box-shadow: 0 8px 25px -4px rgba(16, 185, 129, 0.15);
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.metric-icon {
  font-size: 0.875rem;
  color: var(--primary-emerald);
}

.metric-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.375rem;
}

.metric-value {
  font-family: var(--font-mono);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

@media (min-width: 640px) {
  .metric-value {
    font-size: 2.125rem;
  }
}

.metric-unit {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-light);
}

.metric-footer {
  margin-top: 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-light);
}

/* Progress bar inside card */
.metric-progress-track {
  width: 100%;
  height: 4px;
  background: #f1f5f9;
  border-radius: 99px;
  margin-top: 0.75rem;
  overflow: hidden;
}

.metric-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary-gradient);
  border-radius: 99px;
  transition: width 0.2s ease;
}

/* ==========================================================================
   NETWORK TELEMETRY CARD (IP / ISP / SERVER)
   ========================================================================== */
.telemetry-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
}

@media (min-width: 640px) {
  .telemetry-card {
    grid-template-columns: repeat(3, 1fr);
  }
}

.telemetry-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.telemetry-icon-box {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: var(--primary-emerald-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.telemetry-title {
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
}

.telemetry-val {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

/* ==========================================================================
   TEST WAVEFORM / LIVE CHART CANVAS
   ========================================================================== */
.chart-container {
  width: 100%;
  height: 120px;
  position: relative;
  margin-top: 1rem;
}

#speedChartCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ==========================================================================
   GRADE BADGES (A+, A, B, C, D)
   ========================================================================== */
.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 900;
}

.grade-A-plus, .grade-A {
  background: #ecfdf5;
  color: #059669;
  border: 2px solid #34d399;
}

.grade-B {
  background: #eff6ff;
  color: #2563eb;
  border: 2px solid #60a5fa;
}

.grade-C {
  background: #fffbeb;
  color: #d97706;
  border: 2px solid #fbbf24;
}

.grade-D {
  background: #fff1f2;
  color: #e11d48;
  border: 2px solid #f43f5e;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  padding: 2.5rem 0 2rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem 1.5rem;
  margin-bottom: 1rem;
}

.footer-links a {
  color: var(--text-muted);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s ease;
}

.footer-links a:hover {
  color: var(--primary-emerald);
}

/* ==========================================================================
   TABLES & HISTORY STYLES
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.custom-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.custom-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.custom-table tbody tr:hover {
  background: #f8fafc;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}
