/* ==========================================================================
   SpeedTest Pro - Modern Cyber-Tech Design System & Styling
   Monetization Optimized Layout (Google AdSense & Adsterra Ready)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@500;700&display=swap');

:root {
  /* Color Palette - Dark Theme (Default) */
  --bg-primary: #0b0f19;
  --bg-secondary: #121829;
  --bg-card: rgba(22, 31, 51, 0.75);
  --bg-card-hover: rgba(30, 42, 69, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 242, 254, 0.3);
  
  --text-main: #f0f4f8;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --accent-cyan: #00f2fe;
  --accent-blue: #4facfe;
  --accent-green: #00ff88;
  --accent-purple: #7928ca;
  --accent-pink: #ff0080;
  --accent-orange: #ff9900;

  --gradient-neon: linear-gradient(135deg, #00f2fe 0%, #4facfe 50%, #00ff88 100%);
  --gradient-download: linear-gradient(135deg, #00f2fe, #4facfe);
  --gradient-upload: linear-gradient(135deg, #7928ca, #ff0080);
  --gradient-ping: linear-gradient(135deg, #00ff88, #10b981);
  --gradient-card: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);

  --shadow-neon: 0 0 25px rgba(0, 242, 254, 0.25);
  --shadow-card: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #f4f7fc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(240, 244, 255, 1);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-glow: rgba(0, 114, 255, 0.3);
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  
  --shadow-neon: 0 10px 30px rgba(0, 114, 255, 0.15);
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.06);
}

/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Background Animated Gradient Blobs */
body::before, body::after {
  content: '';
  position: fixed;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(140px);
  z-index: -1;
  opacity: 0.25;
  pointer-events: none;
}

body::before {
  top: -150px;
  left: -150px;
  background: radial-gradient(circle, #00f2fe, #7928ca);
}

body::after {
  bottom: -150px;
  right: -150px;
  background: radial-gradient(circle, #00ff88, #4facfe);
}

/* Container Structure */
.app-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 20px 80px 20px;
}

/* Header & Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 25px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: var(--gradient-neon);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0b0f19;
  font-size: 1.4rem;
  box-shadow: var(--shadow-neon);
}

.logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.logo-text span {
  background: var(--gradient-neon);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.theme-toggle-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-neon);
}

/* Strategic Ad Placements (AdSense / Adsterra) */
.ad-slot {
  margin: 20px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 10px;
  min-height: 90px;
  transition: var(--transition);
}

.ad-slot.ad-top-leaderboard {
  min-height: 90px;
  width: 100%;
}

.ad-slot.ad-rectangle {
  min-height: 250px;
  width: 100%;
}

.ad-slot.ad-native-banner {
  min-height: 120px;
  width: 100%;
}

.ad-placeholder-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ad-placeholder-label i {
  color: var(--accent-orange);
}

/* Layout Grid System */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 30px;
  margin-bottom: 40px;
}

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

/* Speedometer Glass Panel */
.speed-hero-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 35px 25px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.speed-hero-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-neon);
}

/* Top Live Stats Bar (Ping, Jitter, Loss) */
.live-metrics-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 15px;
  width: 100%;
  margin-bottom: 30px;
}

@media (max-width: 640px) {
  .live-metrics-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

.metric-pill {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  text-align: center;
  transition: var(--transition);
  position: relative;
}

.metric-pill.active {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.2);
}

.metric-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.metric-val {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 2px;
}

.metric-unit {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 400;
  margin-left: 2px;
}

/* Canvas Gauge Wrapper */
.gauge-wrapper {
  position: relative;
  width: 340px;
  height: 340px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 10px 0 25px 0;
}

@media (max-width: 480px) {
  .gauge-wrapper {
    width: 280px;
    height: 280px;
  }
}

#speedGauge {
  width: 100%;
  height: 100%;
}

.gauge-center-display {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  top: 55%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.gauge-status-badge {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-cyan);
  margin-bottom: 6px;
}

.gauge-speed-val {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 3.6rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-main);
  letter-spacing: -1px;
}

.gauge-speed-unit {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

/* Main Action Button (Start / Stop Test) */
.test-action-container {
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  width: 100%;
}

.btn-start-test {
  background: var(--gradient-neon);
  color: #070a12;
  border: none;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  padding: 16px 48px;
  border-radius: 40px;
  cursor: pointer;
  box-shadow: 0 0 30px rgba(0, 242, 254, 0.4);
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn-start-test:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 0 45px rgba(0, 242, 254, 0.6);
}

.btn-start-test:active {
  transform: translateY(1px);
}

.btn-start-test.running {
  background: linear-gradient(135deg, #ff0080, #ff9900);
  color: #ffffff;
  box-shadow: 0 0 30px rgba(255, 0, 128, 0.4);
}

/* User IP & Connection Info Card */
.connection-info-strip {
  margin-top: 25px;
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.info-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.info-item i {
  color: var(--accent-cyan);
  font-size: 1.1rem;
}

.info-item span.label {
  color: var(--text-dim);
}

.info-item span.val {
  color: var(--text-main);
  font-weight: 600;
}

/* Sidebar Styling & Ads */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.card-widget {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.widget-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.widget-title i {
  color: var(--accent-cyan);
}

/* Quality Experience Rating Cards */
.quality-scores-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quality-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.quality-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quality-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(0, 242, 254, 0.1);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.quality-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
}

.quality-status {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 12px;
}

.status-excellent { background: rgba(0, 255, 136, 0.15); color: #00ff88; }
.status-good { background: rgba(0, 242, 254, 0.15); color: #00f2fe; }
.status-fair { background: rgba(255, 153, 0, 0.15); color: #ff9900; }
.status-poor { background: rgba(255, 0, 128, 0.15); color: #ff0080; }

/* History Table Section */
.history-section {
  margin-top: 40px;
}

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 25px;
}

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

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

.history-table th, .history-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.history-table th {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.history-table td {
  font-size: 0.95rem;
}

.btn-secondary {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  transition: var(--transition);
}

.btn-secondary:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* SEO Educational Articles Section */
.seo-articles-section {
  margin-top: 50px;
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 25px;
  margin-top: 20px;
}

.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 25px;
  transition: var(--transition);
}

.article-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-glow);
}

.article-card h3 {
  font-size: 1.2rem;
  color: var(--accent-cyan);
  margin-bottom: 12px;
}

.article-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

/* Footer & Legal Modals */
.footer {
  margin-top: 60px;
  padding-top: 30px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
}

.footer-links a:hover {
  color: var(--accent-cyan);
}

/* Sticky Bottom Adsterra/AdSense Banner */
.sticky-bottom-ad {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--accent-cyan);
  padding: 10px 20px;
  z-index: 999;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.5);
  transition: var(--transition);
}

.close-ad-btn {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 30px;
  position: relative;
  color: var(--text-main);
}

.modal-close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Adsterra Direct Link CTA Button */
.btn-adsterra-direct {
  background: linear-gradient(135deg, #ff0080, #7928ca);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 30px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  margin-top: 10px;
  transition: var(--transition);
}

.btn-adsterra-direct:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 20px rgba(255, 0, 128, 0.4);
}

/* ==========================================================================
   SEO Enhancements (FAQ Accordion, Tips & Comparison Tables)
   ========================================================================== */

.seo-faq-section {
  margin-top: 45px;
}

.faq-grid {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-top: 25px;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition);
}

.faq-item:hover {
  border-color: var(--accent-cyan);
}

.faq-question {
  width: 100%;
  text-align: left;
  padding: 18px 22px;
  background: none;
  border: none;
  color: var(--text-main);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.faq-question i {
  color: var(--accent-cyan);
  transition: transform 0.3s ease;
}

.faq-item.active .faq-question i {
  transform: rotate(180deg);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease-in-out, padding 0.35s ease;
  padding: 0 22px;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

.faq-item.active .faq-answer {
  max-height: 350px;
  padding: 0 22px 20px 22px;
}

/* Comparison Table SEO Component */
.seo-table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 25px;
  margin-top: 35px;
}

.seo-table-card h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem;
  margin-bottom: 15px;
  color: var(--text-main);
}

.seo-table {
  width: 100%;
  border-collapse: collapse;
}

.seo-table th, .seo-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.seo-table th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent-cyan);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.seo-table td {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Tips Steps Grid */
.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 25px;
}

.step-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  position: relative;
}

.step-num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gradient-neon);
  color: #0b0f19;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.step-card h4 {
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 8px;
}

.step-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

