/* ==========================================================================
   HyperSpeed Benchmark — Design System & Styles
   ========================================================================== */

/* --- 1. CSS Variables (Design System) --- */
:root {
  /* Dark Theme (Default) */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.6);
  --bg-card-hover: rgba(30, 41, 59, 0.8);
  --border-card: rgba(99, 102, 241, 0.2);
  
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #6366f1;    /* Indigo */
  --accent-glow: rgba(99, 102, 241, 0.5);
  --accent-cyan: #22d3ee;       /* Download */
  --accent-magenta: #e879f9;    /* Upload */
  --accent-green: #34d399;      /* Good */
  --accent-yellow: #fbbf24;     /* Warning */
  --accent-red: #f87171;        /* Bad */
  
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.2);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-card-hover: rgba(241, 245, 249, 0.9);
  --border-card: rgba(99, 102, 241, 0.15);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --shadow-card: 0 4px 24px rgba(148, 163, 184, 0.1);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

/* --- 2. CSS Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}
a { color: var(--accent-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-cyan); }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
h1, h2, h3 { font-weight: 700; line-height: 1.2; }

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.w-100 { width: 100%; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-3 { margin-bottom: 1rem; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.4s ease forwards; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  70% { box-shadow: 0 0 0 15px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

@keyframes spin { 100% { transform: rotate(360deg); } }
.settings-panel summary:hover .icon-spin { animation: spin 4s linear infinite; }
.settings-panel[open] summary .icon-spin { animation: spin 4s linear infinite; }

/* --- 3. Layout --- */
header {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-card);
  position: relative;
  gap: 0.5rem;
}
.header-left { display: flex; align-items: baseline; gap: 0.5rem; justify-content: center; }
.logo { font-size: 1.25rem; font-weight: 900; letter-spacing: -0.025em; background: linear-gradient(135deg, var(--accent-cyan), var(--accent-primary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.logo-sub { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.header-right { position: absolute; right: 1rem; top: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.icon-btn { font-size: 1.25rem; padding: 0.5rem; border-radius: var(--radius-sm); transition: background var(--transition-fast); }
.icon-btn:hover { background: var(--bg-card-hover); }
#lang-select { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border-card); border-radius: var(--radius-sm); padding: 0.4rem 0.5rem; font-size: 0.875rem; outline: none; }

/* Tabs */
#tab-bar {
  display: flex;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-card);
  padding: 0 1rem;
}
#tab-bar::-webkit-scrollbar { display: none; }
.tab {
  white-space: nowrap;
  padding: 1rem 1.25rem;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent-primary); border-bottom-color: var(--accent-primary); }

/* Main Content Area */
.panel { flex: 1; padding: 1.5rem 1rem; max-width: 800px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 1.5rem; }
.panel > h2 { text-align: center; margin-bottom: 0.5rem; font-size: 1.5rem; }

/* Grid System */
.grid-2-col { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 768px) { .grid-2-col { grid-template-columns: 1fr 1fr; } }

/* Cards (Glassmorphism) */
.dashboard-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}
.dashboard-card:hover { border-color: rgba(99, 102, 241, 0.4); }
.dashboard-card h3 { font-size: 1.1rem; color: var(--text-secondary); margin-bottom: 1rem; font-weight: 600; }

/* --- 4. Tab 1: Speed Test Components --- */
.equalizer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 1rem 0;
  margin-bottom: 1rem;
}
.eq-value-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}
.gauge-value {
  font-family: var(--font-mono);
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
  text-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}
.gauge-unit { font-size: 1.1rem; font-weight: 600; color: var(--text-secondary); margin-top: 0.2rem; }
.gauge-phase { font-size: 0.9rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; margin-top: 0.5rem; }

.eq-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  height: 80px;
  width: 100%;
  max-width: 320px;
}
.eq-bar {
  flex: 1;
  background: rgba(255, 255, 255, 0.05); /* Visible empty bars */
  border-radius: 4px 4px 0 0;
  transition: all 0.1s ease;
  min-height: 8px;
  position: relative;
  overflow: hidden;
}
.eq-bar.active {
  background: var(--accent-primary);
  box-shadow: 0 0 10px var(--accent-glow);
}
.eq-bar.active::after {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.4), transparent);
}
.eq-labels {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 320px;
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-start {
  display: block;
  margin: 0 auto;
  background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
  color: white;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 1rem 3rem;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-glow);
  transition: transform 0.1s, box-shadow var(--transition-fast);
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}
.btn-start::before {
  content: '';
  position: absolute;
  top: 0; left: 0; height: 100%;
  width: var(--progress, 0%);
  background: rgba(255, 255, 255, 0.25);
  transition: width 0.2s linear;
  z-index: 1;
}
.btn-start span { position: relative; z-index: 2; }

.btn-start:hover { transform: translateY(-2px); box-shadow: 0 0 30px var(--accent-glow); }
.btn-start:active { transform: translateY(1px); }
.btn-start.running { 
  background: var(--bg-card); 
  color: var(--accent-red); 
  border: 1px solid var(--accent-red); 
  box-shadow: none; 
}
.btn-start.running::before {
  background: rgba(248, 113, 113, 0.2);
}

/* Settings Panel */
.settings-panel { margin: 0 auto; max-width: 400px; width: 100%; background: var(--bg-secondary); border: 1px solid var(--border-card); border-radius: var(--radius-md); overflow: hidden; }
.settings-panel summary { padding: 1rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; background: var(--bg-card); outline: none; user-select: none; }
.settings-panel summary::marker { content: ""; }
.settings-panel[open] summary { border-bottom: 1px solid var(--border-card); }
.presets { display: flex; padding: 1rem 1rem 0; gap: 0.5rem; }
.preset { flex: 1; padding: 0.5rem; border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 600; background: var(--bg-primary); border: 1px solid var(--border-card); color: var(--text-secondary); transition: all var(--transition-fast); }
.preset.active { background: rgba(99, 102, 241, 0.1); border-color: var(--accent-primary); color: var(--accent-primary); }
.checkboxes { padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.check-item { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; cursor: pointer; }
.check-item input { width: 1.2rem; height: 1.2rem; accent-color: var(--accent-primary); cursor: pointer; }
.check-item input:disabled { opacity: 0.5; cursor: not-allowed; }
.check-item .time { margin-left: auto; font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted); background: var(--bg-primary); padding: 0.2rem 0.4rem; border-radius: 4px; }
.check-item.fixed { opacity: 0.7; }
.time-estimate { text-align: center; padding: 0.75rem; background: var(--bg-primary); font-size: 0.875rem; font-weight: 600; color: var(--accent-cyan); border-top: 1px solid var(--border-card); }

/* Results Grid */
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
.result-card { background: var(--bg-card); border: 1px solid var(--border-card); border-radius: var(--radius-lg); padding: 1.25rem; display: flex; flex-direction: column; align-items: center; text-align: center; backdrop-filter: blur(12px); box-shadow: var(--shadow-card); }
.result-label { font-size: 0.875rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; font-weight: 600; }
.result-value { font-family: var(--font-mono); font-size: 2rem; font-weight: 700; color: var(--text-primary); line-height: 1.1; margin-bottom: 0.25rem; }
.result-unit { font-size: 0.8rem; color: var(--text-muted); }

/* Geo Card */
.geo-card { background: var(--bg-secondary); border: 1px solid var(--border-card); border-radius: var(--radius-md); padding: 1rem; display: flex; align-items: center; gap: 1rem; }
.geo-icon { font-size: 2rem; }
.geo-details { flex: 1; display: flex; flex-direction: column; }
.geo-text.primary { font-weight: 600; font-size: 1rem; }
.geo-text.secondary { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 0.25rem; }
.geo-footer { display: flex; justify-content: space-between; align-items: center; font-family: var(--font-mono); font-size: 0.8rem; }
.vpn-badge { background: rgba(248, 113, 113, 0.15); color: var(--accent-red); padding: 0.15rem 0.4rem; border-radius: 4px; font-weight: 600; border: 1px solid rgba(248, 113, 113, 0.3); }

/* --- 5. Shared Components --- */
.table-responsive { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.75rem; text-align: left; border-bottom: 1px solid var(--border-card); }
th { font-weight: 600; color: var(--text-secondary); }
tr:last-child td { border-bottom: none; }

.btn-primary, .btn-secondary { padding: 0.75rem 1.5rem; border-radius: var(--radius-sm); font-weight: 600; transition: all var(--transition-fast); display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
.btn-primary { background: var(--accent-primary); color: white; }
.btn-primary:hover:not(:disabled) { background: #4f46e5; box-shadow: var(--shadow-glow); }
.btn-secondary { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-card); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-card-hover); }
.btn-primary:disabled, .btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-group { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.btn-group button { flex: 1; }

.highlight { color: var(--accent-cyan); font-weight: 700; }

/* Promo Zones */
.promo-widget { width: 100%; min-height: 50px; display: flex; justify-content: center; align-items: center; margin-top: 1.5rem; overflow: hidden; border-radius: var(--radius-sm); }
.bizer-promo { background: rgba(99, 102, 241, 0.1); border: 1px dashed var(--accent-primary); padding: 1rem; width: 100%; text-align: center; border-radius: var(--radius-sm); font-weight: 600; }

/* --- 6. Specific Tab Components --- */
/* Gaming */
.bb-container { text-align: center; }
.bb-grade { font-size: 3rem; font-weight: 900; font-family: var(--font-mono); line-height: 1; margin-bottom: 0.5rem; text-shadow: 0 0 20px rgba(255,255,255,0.1); }
.bb-grade.A { color: var(--accent-green); text-shadow: 0 0 20px rgba(52, 211, 153, 0.3); }
.bb-grade.B { color: var(--accent-cyan); }
.bb-grade.C { color: var(--accent-yellow); }
.bb-grade.D, .bb-grade.F { color: var(--accent-red); }

/* Calculator */
.calc-controls { margin-bottom: 1rem; }
input[type=range] { width: 100%; accent-color: var(--accent-primary); }
.calc-display { font-size: 1.25rem; text-align: center; margin-bottom: 1rem; background: var(--bg-secondary); padding: 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border-card); }
.calc-display .arrow { color: var(--text-muted); margin: 0 0.5rem; }
.calc-presets { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.preset-btn { flex: 1; min-width: 100px; padding: 0.5rem; background: var(--bg-secondary); border: 1px solid var(--border-card); color: var(--text-secondary); border-radius: var(--radius-sm); font-size: 0.8rem; }
.preset-btn.active { background: var(--accent-primary); color: white; border-color: var(--accent-primary); }

/* Profile */
.dna-grid { display: grid; grid-template-columns: auto 1fr; gap: 0.75rem 1.5rem; font-size: 0.9rem; }
.dna-grid .label { color: var(--text-secondary); font-weight: 500; }
.dna-grid .val { color: var(--text-primary); font-family: var(--font-mono); text-align: right; }

.share-buttons { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.5rem; }
.share-btn { padding: 0.6rem; text-align: center; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem; color: white !important; cursor: pointer; }
.share-btn.tg { background: #0088cc; }
.share-btn.tw { background: #1da1f2; }
.share-btn.wa { background: #25d366; }

/* Footer */
footer { margin-top: auto; padding: 2rem 1rem; background: var(--bg-secondary); border-top: 1px solid var(--border-card); text-align: center; }
.footer-content { max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; gap: 1rem; align-items: center; }
footer span { color: var(--text-muted); font-size: 0.875rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; font-size: 0.875rem; }
.footer-links .separator { color: var(--border-card); }

/* Mobile Adjustments */
@media (max-width: 480px) {
  .result-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
  .result-card { padding: 1rem 0.5rem; }
  .result-value { font-size: 1.5rem; }
  .gauge-container { max-width: 280px; }
  .gauge-value { font-size: 2.5rem; }
}
