/*----------------------------------------*/
/* 1. Reset & Root Variables              */
/*----------------------------------------*/

:root {
  /* Colors based on Spec v2.0 */
  --pk-green: #01411C;
  --dark-bg: #0A1628;
  --neon-green: #00FF88;
  --neon-blue: #00D4FF;
  --white: #FFFFFF;
  --gold: #FFD700;
  --speed-red: #E74C3C;
  --speed-yellow: #F39C12;
  --speed-green: #27AE60;

  /* UI Grays & Borders */
  --gray-800: #1a202c;
  --gray-700: #2d3748;
  --gray-900: #171923;
  --gray-400: #cbd5e0;
  --gray-300: #e2e8f0;

  /* Fonts */
  --font-en: 'Inter', sans-serif;
  --font-ur: 'Noto Nastaliq Urdu', serif;
}

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

body {
  font-family: var(--font-en);
  /* Default fallback */
  background-color: var(--dark-bg);
  color: var(--white);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}



/* Language font assignments handled by rtl.css, but set english defaults here */
.lang-en {
  font-family: var(--font-en);
}

.lang-en [data-i18n] {
  font-family: var(--font-en);
}

/* Hidden utility */
.hidden {
  display: none !important;
}

/*----------------------------------------*/
/* 2. Layout Structure                    */
/*----------------------------------------*/

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: rgba(10, 22, 40, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gray-700);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  direction: ltr;
  /* Force LTR context */
  flex-direction: row-reverse;
  /* Force Logo right, Toggle left */
}

.main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Logo & Header Elements */
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  direction: ltr;
  /* Protect 'PakSpeed' text orientation */
  text-decoration: none;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.05em;
  font-family: 'Montserrat', sans-serif;
}

html[dir="rtl"] .logo {
  flex-direction: row-reverse;
}

.logo-accent {
  color: #FFB300;
}

.btn-lang {
  background-color: var(--gray-800);
  border: 1px solid var(--gray-700);
  color: var(--white);
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  font-family: var(--font-en);
  /* Always easy to read toggle */
}

.btn-lang:hover {
  background-color: var(--gray-700);
  color: var(--neon-green);
}

/*----------------------------------------*/
/* 3. Section: IDLE                       */
/*----------------------------------------*/

.section-idle {
  text-align: center;
  width: 100%;
  margin-bottom: 3rem;
  animation: fadeIn 0.8s ease-out;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  line-height: 1.2;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--gray-400);
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .hero-title {
    font-size: 3.5rem;
  }

  .hero-subtitle {
    font-size: 1.5rem;
  }
}

.btn-start-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 3rem auto;
}

@media (min-width: 768px) {
  .btn-start-wrap {
    width: 280px;
    height: 280px;
  }
}

.btn-start {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 4px solid var(--pk-green);
  background: var(--gray-800);
  color: var(--white);
  font-size: 2rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 40px rgba(1, 65, 28, 0.6);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  z-index: 10;
}

@media (min-width: 768px) {
  .btn-start {
    font-size: 2.5rem;
  }
}

.btn-start:hover {
  border-color: var(--neon-green);
  box-shadow: 0 0 60px rgba(0, 255, 136, 0.4);
  transform: scale(1.05);
}

.btn-start:active {
  transform: scale(0.95);
}

/* Inner pulse ring for start button */
.btn-start::before {
  content: '';
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  border-radius: 50%;
  border: 2px solid var(--neon-green);
  opacity: 0;
  animation: pulse-ring 2s infinite cubic-bezier(0.215, 0.61, 0.355, 1);
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.95);
    opacity: 0;
  }

  50% {
    opacity: 0.3;
  }

  100% {
    transform: scale(1.2);
    opacity: 0;
  }
}

.isp-display {
  display: inline-block;
  background-color: rgba(1, 65, 28, 0.3);
  color: var(--neon-green);
  padding: 0.375rem 1rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  margin-top: 1rem;
  transition: opacity 0.3s;
}

/*----------------------------------------*/
/* 4. Section: TESTING (Gauge)            */
/*----------------------------------------*/

.section-testing {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.5s ease-out;
}

.test-phase {
  font-size: 1.25rem;
  color: var(--gray-300);
  margin-bottom: 2rem;
  animation: pulse-op 1.5s infinite;
}

@keyframes pulse-op {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.gauge-container {
  width: 280px;
  height: 280px;
  position: relative;
  margin-bottom: 3rem;
}

@media (min-width: 768px) {
  .gauge-container {
    width: 360px;
    height: 360px;
  }
}

.gauge-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.gauge-track {
  fill: none;
  stroke: var(--gray-700);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 691.15;
  /* 2 * PI * 110 */
  stroke-dashoffset: 172.78;
  /* 691.15 * 0.25 (to make it a 270 degree arc) */
}

.gauge-arc {
  fill: none;
  stroke: var(--neon-green);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 691.15;
  stroke-dashoffset: 691.15;
  /* Start empty (full dash offset plus the 25% gap) */
  transition: stroke-dashoffset 0.1s linear, stroke 0.3s ease;
  filter: drop-shadow(0 0 10px rgba(0, 255, 136, 0.5));
}

.gauge-text-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  /* Let clicks pass through to SVG if needed */
}

.gauge-speed-text {
  font-family: var(--font-en);
  font-size: 3rem;
  /* ~48px */
  font-weight: 900;
  color: var(--white);
  line-height: 1.1;
  margin-top: 1rem;
}

.gauge-unit-text {
  font-family: var(--font-en);
  font-size: 1.125rem;
  /* ~18px */
  font-weight: 600;
  color: var(--gray-400);
}

.gauge-label-text {
  font-family: var(--font-ur);
  /* Use primary Urdu font mapping */
  font-size: 0.875rem;
  /* ~14px */
  font-weight: 600;
  color: var(--gray-400);
  margin-top: 0.5rem;
}

/*----------------------------------------*/
/* 5. Section: RESULTS Grid               */
/*----------------------------------------*/

.section-results {
  width: 100%;
  animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .results-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
  }
}

.result-card {
  background-color: rgba(26, 32, 44, 0.7);
  backdrop-filter: blur(8px);
  border: 1px solid var(--gray-700);
  border-radius: 1rem;
  padding: 1.5rem 1rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* Top color bars */
#res-download-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(to right, #00FF88, #27AE60);
}

#res-upload-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(to right, #00D4FF, #2980B9);
}

#res-ping-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(to right, #FFD700, #F39C12);
}

#res-jitter-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(to right, #B48EFF, #8E44AD);
}

.result-card-icon {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.result-value {
  font-family: var(--font-en);
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.result-unit {
  font-family: var(--font-en);
  font-size: 0.75rem;
  color: var(--gray-400);
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.result-label {
  font-size: 0.875rem;
  color: var(--gray-300);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.result-quality {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* Quality colors assigned via JS */
.qual-green {
  color: var(--speed-green);
  background: rgba(39, 174, 96, 0.2);
  border: 1px solid rgba(39, 174, 96, 0.3);
}

.qual-yellow {
  color: var(--speed-yellow);
  background: rgba(243, 156, 18, 0.2);
  border: 1px solid rgba(243, 156, 18, 0.3);
}

.qual-red {
  color: var(--speed-red);
  background: rgba(231, 76, 60, 0.2);
  border: 1px solid rgba(231, 76, 60, 0.3);
}

.qual-gray {
  color: var(--gray-400);
  background: rgba(203, 213, 224, 0.1);
  border: 1px solid var(--gray-700);
}

.isp-result-card {
  display: flex;
  align-items: center;
  background-color: var(--gray-800);
  border: 1px solid var(--gray-700);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.isp-info {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.isp-client-row,
.isp-server-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.isp-client-label {
  font-weight: 700;
  color: var(--gray-300);
  min-width: 60px;
  margin-right: 0.75rem;
}

html[dir="rtl"] .isp-result-card {
  flex-direction: row-reverse;
}

.isp-icon-wrap {
  font-size: 2rem;
  background: var(--gray-900);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--gray-700);
}

.isp-info {
  margin: 0 1rem;
  flex: 1;
  text-align: left;
  /* LTR */
}

html[dir="rtl"] .isp-info {
  text-align: right;
  /* RTL */
}

.isp-name {
  font-family: var(--font-en);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--white);
}

.isp-city {
  font-family: var(--font-en);
  font-size: 0.875rem;
  color: var(--gray-400);
}

.isp-type-badge {
  font-family: var(--font-en);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--white);
  background: rgba(255, 255, 255, 0.1);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid var(--gray-600);
}

.btn-restart {
  display: block;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  background: transparent;
  color: var(--gray-300);
  border: 1px solid var(--gray-700);
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-restart:hover {
  background: var(--gray-800);
  color: var(--white);
  border-color: var(--gray-600);
}

/*----------------------------------------*/
/* 6. Section: FEEDBACK                   */
/*----------------------------------------*/

.section-feedback {
  width: 100%;
  background: rgba(26, 32, 44, 0.4);
  border: 1px solid var(--gray-700);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-top: 2rem;
  animation: slideUp 0.8s ease-out;
}

.section-title {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.feedback-summary {
  text-align: center;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--neon-green);
  margin-bottom: 2rem;
}

.feedback-activities {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .feedback-activities {
    grid-template-columns: repeat(2, 1fr);
  }
}

.activity-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--gray-700);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}

/* For RTL the dom order of flex works, but since we map english/urdu it handles spacing */

.activity-name {
  font-size: 0.875rem;
  color: var(--gray-300);
}

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

/*----------------------------------------*/
/* 7. Section: SHARE & ADS                */
/*----------------------------------------*/

.section-share {
  width: 100%;
  max-width: 400px;
  margin: 3rem auto;
  text-align: center;
  animation: slideUp 1s ease-out;
}

.share-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  width: 100%;
  padding: 1rem;
  border-radius: 0.75rem;
  border: none;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--white);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}

.share-btn:active {
  transform: scale(0.97);
}

.btn-whatsapp {
  background-color: #25D366;
  padding: 1.25rem;
  font-size: 1.25rem;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.3);
}

.btn-whatsapp:hover {
  background-color: #128C7E;
}

.btn-facebook {
  background-color: #1877F2;
}

.btn-facebook:hover {
  background-color: #166FE5;
}

.share-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.share-secondary .share-btn {
  background-color: var(--gray-800);
  border: 1px solid var(--gray-700);
  font-size: 0.875rem;
  padding: 0.75rem;
}

.share-secondary .share-btn:hover {
  background-color: var(--gray-700);
}

.share-btn-download {
  background-color: var(--gray-900);
  border: 1px dashed var(--gray-600);
  color: var(--gray-300);
  font-size: 0.875rem;
}

.share-btn-download:hover {
  background-color: var(--gray-800);
  border-color: var(--gray-500);
  color: var(--white);
}

.ad-zone {
  width: 100%;
  max-width: 728px;
  min-height: 90px;
  margin: 2rem auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: rgba(26, 32, 44, 0.4);
  border: 1px dashed var(--gray-600);
  color: var(--gray-500);
  text-align: center;
  border-radius: 0.5rem;
}

.btn-update-location {
  cursor: pointer;
  margin-left: 8px;
  font-size: 11px;
  color: var(--midnight-blue);
  background: #4ADE80;
  border: none;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: transform 0.1s, background 0.2s;
  box-shadow: 0 2px 4px rgba(74, 222, 128, 0.2);
  white-space: nowrap;
}

.btn-update-location:hover {
  background: #22c55e;
}

.btn-update-location:active {
  transform: scale(0.95);
}

@media (max-width: 768px) {
  .ad-zone {
    min-height: 50px;
  }
}

/*----------------------------------------*/
/* 8. FOOTER & MISC                       */
/*----------------------------------------*/

.newsletter-section {
  width: 100%;
  max-width: 480px;
  margin: 3rem auto;
  text-align: center;
}

.newsletter-title {
  font-family: var(--font-en);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--white);
  margin-bottom: 0.5rem;
}

.newsletter-subtitle {
  color: var(--gray-400);
  margin: 0 1rem 2rem;
  font-size: 0.85rem;
  line-height: 1.6;
}

.newsletter-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  direction: ltr;
}

@media (min-width: 640px) {
  .newsletter-form {
    flex-direction: row;
    gap: 0.5rem;
  }
}

.newsletter-input {
  flex: 1;
  padding: 0.875rem 1rem;
  border-radius: 0.5rem;
  background-color: rgba(26, 32, 44, 0.7);
  border: 1px solid var(--gray-700);
  color: var(--white);
  font-family: var(--font-en);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

html[dir="rtl"] .newsletter-input {
  text-align: right;
  direction: rtl;
}

.newsletter-input:focus {
  border-color: var(--neon-blue);
  box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.2);
}

.newsletter-btn {
  padding: 0.875rem 2rem;
  border-radius: 0.5rem;
  background: linear-gradient(135deg, #00D4FF, #2980B9);
  color: var(--white);
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.newsletter-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 212, 255, 0.4);
}

.data-notice {
  text-align: center;
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 2rem;
}

.footer {
  width: 100%;
  background: #050B14;
  border-top: 1px solid var(--gray-800);
  padding: 2rem 1rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1rem;
}

.footer-brand {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--gray-400);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

.footer-links a {
  color: var(--gray-500);
  text-decoration: none;
  font-size: 0.75rem;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--neon-green);
}

.footer-mission {
  font-size: 0.7rem;
  color: var(--gray-600);
  margin-top: 1rem;
}

/*----------------------------------------*/
/* 9. SHARE CARD (Hidden for html2canvas) */
/*----------------------------------------*/

.result-card-hidden {
  position: absolute;
  left: -9999px;
  top: -9999px;
  width: 600px;
  height: 600px;
  background-color: var(--dark-bg);
  background-image: linear-gradient(135deg, var(--gray-900), var(--dark-bg));
  font-family: var(--font-en);
  border: 12px solid var(--gray-800);
  color: var(--white);
}

.rc-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  position: relative;
}

.rc-inner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 16px;
  background: linear-gradient(to right, var(--pk-green), var(--neon-green), var(--pk-green));
}

.rc-header {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -2px;
  opacity: 0.8;
  margin-bottom: 20px;
}

.rc-speed {
  font-size: 110px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 30px rgba(0, 255, 136, 0.6);
}

.rc-unit {
  font-size: 32px;
  color: var(--gray-400);
  font-weight: 700;
  margin-bottom: 40px;
}

.rc-dl-label {
  display: none;
  /* remove label if unnecessary */
}

.rc-stats {
  display: flex;
  width: 100%;
  background: rgba(26, 32, 44, 0.8);
  border: 1px solid var(--gray-700);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 40px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.rc-stat {
  flex: 1;
  text-align: center;
  border-right: 1px solid var(--gray-700);
}

.rc-stat:last-child {
  border-right: none;
}

.rc-stat-val {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 8px;
}

.rc-stat-label {
  font-size: 16px;
  color: var(--gray-400);
}

.rc-isp {
  font-size: 28px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.4);
  padding: 12px 32px;
  border-radius: 9999px;
  border: 1px solid var(--gray-700);
  margin-bottom: 30px;
}

.rc-verdict {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: auto;
}

.rc-cta {
  font-size: 20px;
  color: var(--gray-500);
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}