/* Global Website Speed Test - Light Theme */

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

:root {
  --primary: #0066FF;
  --primary-light: #3388FF;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --bg: #FFFFFF;
  --bg-alt: #F8FAFC;
  --text: #1E293B;
  --text-muted: #64748B;
  --border: #E2E8F0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
}

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Header */
.navbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}

.navbar-brand img {
  height: 28px;
}

/* Hero */
.hero-section {
  padding: 48px 0 32px;
  text-align: center;
  background: var(--bg-alt);
}

.hero-section h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 12px;
}

.hero-section p {
  color: var(--text-muted);
  margin-bottom: 24px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

/* URL Form */
.url-form {
  max-width: 480px;
  margin: 0 auto;
}

.url-input-wrapper {
  display: flex;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
}

.url-input-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,102,255,0.1);
}

.url-input-wrapper input {
  flex: 1;
  border: none;
  padding: 10px 12px;
  font-size: 15px;
  outline: none;
  background: transparent;
  min-width: 0;
}

.url-input-wrapper button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-size: 14px;
}

.url-input-wrapper button:hover { background: var(--primary-light); }
.url-input-wrapper button:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-test {
  display: flex;
  align-items: center;
  gap: 6px;
}

.error-message {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--danger);
  padding: 12px;
  border-radius: 6px;
  margin-top: 12px;
  font-size: 14px;
}

/* Progress */
.progress-section {
  padding: 32px 0;
}

.progress-section h2 {
  text-align: center;
  font-size: 18px;
  margin-bottom: 20px;
}

.overall-progress {
  max-width: 360px;
  margin: 0 auto 24px;
}

.progress-bar-bg {
  background: var(--border);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  background: var(--primary);
  height: 100%;
  transition: width 0.3s;
}

.progress-text {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

.regions-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
}

.region-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px 10px;
  text-align: center;
  position: relative;
  transition: all 0.3s ease;
  min-height: 90px;
}

.region-card.pending { opacity: 0.5; }
.region-card.testing {
  border-color: var(--primary);
  background: linear-gradient(180deg, rgba(0,102,255,0.05) 0%, var(--bg) 100%);
  box-shadow: 0 0 12px rgba(0,102,255,0.15);
}
.region-card.complete {
  border-color: var(--success);
  background: linear-gradient(180deg, rgba(16,185,129,0.05) 0%, var(--bg) 100%);
  opacity: 1;
}
.region-card.failed {
  border-color: var(--danger);
  background: linear-gradient(180deg, rgba(239,68,68,0.05) 0%, var(--bg) 100%);
}

.region-rank {
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 18px;
  display: none;
  background: var(--bg);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  line-height: 28px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.region-icon {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.region-name {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 2px;
}

.region-status {
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.region-card.testing .region-status { color: var(--primary); font-weight: 600; }
.region-card.complete .region-status { color: var(--success); font-weight: 600; }
.region-card.failed .region-status { color: var(--danger); font-weight: 600; }

.region-metrics {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 4px;
}

.region-metrics .metric-line {
  display: flex;
  justify-content: center;
  gap: 4px;
  line-height: 1.4;
}

.region-metrics .metric-label {
  color: var(--text-muted);
}

.region-metrics .metric-value {
  font-weight: 600;
  color: var(--text);
}

.region-metrics .metric-value.delta-improved { color: var(--success); }
.region-metrics .metric-value.delta-degraded { color: var(--danger); }

.test-status {
  text-align: center;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  margin-top: 20px;
  padding: 12px;
  background: var(--bg-alt);
  border-radius: 8px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* Results */
.results-section {
  padding: 32px 0;
}

.grade-display {
  text-align: center;
  margin-bottom: 24px;
}

.grade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.grade-badge.grade-a-plus { background: #D1FAE5; color: #059669; }
.grade-badge.grade-a { background: #ECFCCB; color: #65A30D; }
.grade-badge.grade-b { background: #DBEAFE; color: #2563EB; }
.grade-badge.grade-c { background: #FEF3C7; color: #D97706; }
.grade-badge.grade-d { background: #FFEDD5; color: #EA580C; }
.grade-badge.grade-f { background: #FEE2E2; color: #DC2626; }

.grade-label {
  color: var(--text-muted);
  font-size: 14px;
}

.grade-score {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.tested-url {
  font-family: monospace;
  font-size: 14px;
  color: var(--primary);
  text-align: center;
  word-break: break-all;
  margin-bottom: 4px;
}

.test-timestamp {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 24px;
}

.summary-card, .details-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.summary-card h3, .details-card h3 {
  font-size: 15px;
  margin-bottom: 12px;
}

.summary-table, .details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.summary-table th, .summary-table td,
.details-table th, .details-table td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.summary-table th, .details-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
}

.summary-table tr:last-child td,
.details-table tr:last-child td {
  border-bottom: none;
}

.details-card { overflow-x: auto; }
.details-table { min-width: 480px; }

.region-col { font-weight: 600; white-space: nowrap; }
.metric-first { font-weight: 600; }
.metric-repeat { font-size: 12px; color: var(--text-muted); }
.delta-improved { color: var(--success) !important; }
.delta-degraded { color: var(--danger) !important; }
.failed-row { background: rgba(239,68,68,0.05); }

.btn-primary {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.btn-primary:hover { background: var(--primary-light); }

.btn-secondary {
  display: inline-block;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 24px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.btn-secondary:hover { background: var(--bg-alt); border-color: var(--text-muted); }

/* Education - Horizontal Layout */
.education-section {
  padding: 32px 0;
  background: var(--bg-alt);
}

.education-section h2 {
  text-align: center;
  font-size: 18px;
  margin-bottom: 16px;
}

.education-list {
  max-width: 800px;
  margin: 0 auto;
}

.education-item {
  display: flex;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}

.education-item:last-child { border-bottom: none; }

.education-item h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  min-width: 140px;
  flex-shrink: 0;
}

.education-item p {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* Footer */
.footer {
  padding: 24px 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 8px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
}

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

.footer-copyright {
  color: var(--text-muted);
  font-size: 12px;
}

/* Utilities */
.hidden { display: none !important; }
.text-danger { color: var(--danger); }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.pulse { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.region-card.testing.pulse {
  animation: cardPulse 1.5s ease-in-out infinite;
}
@keyframes cardPulse {
  0%, 100% { box-shadow: 0 0 12px rgba(0,102,255,0.15); }
  50% { box-shadow: 0 0 20px rgba(0,102,255,0.3); }
}

.region-card.complete {
  animation: completeFlash 0.4s ease-out;
}
@keyframes completeFlash {
  0% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.fade-in { animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile */
@media (max-width: 640px) {
  .hero-section { padding: 32px 0 24px; }
  .hero-section h1 { font-size: 22px; }
  .hero-section p { font-size: 14px; }

  .url-input-wrapper {
    flex-direction: column;
  }
  .url-input-wrapper button { width: 100%; }

  .regions-grid { grid-template-columns: 1fr; gap: 10px; }
  .region-card { padding: 10px 6px; min-height: 85px; }
  .region-name { font-size: 11px; }
  .region-status { font-size: 9px; }
  .region-metrics { font-size: 8px; }
  .region-rank { width: 24px; height: 24px; line-height: 24px; font-size: 14px; top: -6px; right: -6px; }

  .education-item {
    flex-direction: column;
    gap: 2px;
  }
  .education-item h4 { min-width: auto; font-size: 12px; }
  .education-item p { font-size: 12px; }

  .summary-table, .details-table { font-size: 13px; }
  .summary-table th, .summary-table td,
  .details-table th, .details-table td { padding: 6px 4px; }

  .grade-badge { width: 64px; height: 64px; font-size: 24px; }
  .footer-links { flex-direction: column; gap: 8px; }
}

@media (max-width: 400px) {
  .container { padding: 0 12px; }
  .hero-section h1 { font-size: 20px; }
  .region-icon { font-size: 10px; }
  .region-name { font-size: 10px; }
}

/* Print Styles */
@media print {
  body { background: #fff; font-size: 12px; }
  .navbar, .hero-section, .progress-section, .education-section, .footer { display: none !important; }
  .results-section { display: block !important; padding: 0; }
  .results-section .container { max-width: 100%; padding: 0; }
  .grade-display { margin-bottom: 16px; }
  .grade-badge { width: 60px; height: 60px; font-size: 24px; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .summary-card, .details-card { border: 1px solid #ccc; margin-bottom: 12px; page-break-inside: avoid; }
  .btn-primary, .btn-secondary { display: none !important; }
  .fade-in { animation: none; }
  .tested-url { font-size: 12px; }
  .test-timestamp { font-size: 11px; margin-bottom: 16px; }
  .summary-table, .details-table { font-size: 11px; }
  .details-table { min-width: auto; }
}
