/* CAT Calculator Styles - Optimized for Performance */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', sans-serif;
  background: #ffffff;
  min-height: 100vh;
  color: #111;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  background: #ffffff;
  padding: 1.2rem 0;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: #000;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.5px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2.5rem;
}

.nav-links a {
  color: #666;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: #000;
}

.nav-links a.active {
  color: #000;
  font-weight: 600;
}

.login-btn {
  background: #000;
  color: white !important;
  padding: 0.6rem 1.4rem;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.login-btn:hover {
  background: #333;
  transform: translateY(-1px);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #333;
  font-weight: 500;
}

.logout-btn {
  background: none;
  border: 1px solid #eee;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  color: #666;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  text-decoration: none;
}

.logout-btn:hover {
  background: #f5f5f5;
  border-color: #ddd;
}

/* Hero Section - Minimal */
.hero-section {
  background: #ffffff;
  padding: 4rem 0 2rem;
  text-align: center;
}

.hero-title {
  font-family: 'Inter', sans-serif;
  font-size: 2.5rem;
  font-weight: 800;
  color: #000;
  margin-bottom: 1rem;
  letter-spacing: -1px;
  line-height: 1.2;
}

.hero-subtitle {
  color: #666;
  font-size: 1.1rem;
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Browser Warning Box */
.browser-warning {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0.75rem;
  max-width: 650px;
  margin: 1.5rem auto 0;
  padding: 1rem 1.5rem;
  background: #FFF7ED;
  border: 1px solid #FED7AA;
  border-radius: 10px;
  color: #C2410C;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(251, 146, 60, 0.1);
}

.browser-warning .warning-icon {
  flex-shrink: 0;
  color: #EA580C;
  margin-top: 2px;
}

.warning-content {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  flex: 1;
}

.warning-message {
  line-height: 1.4;
  display: block;
}

.warning-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.link-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: #9A3412;
}

.link-input {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 0.75rem;
  background: white;
  border: 1px solid #FDBA74;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #9A3412;
  font-family: 'Monaco', 'Courier New', monospace;
  cursor: pointer;
}

.link-input:focus {
  outline: none;
  border-color: #EA580C;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.1);
}

.copy-link-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  background: #EA580C;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-link-btn:hover {
  background: #C2410C;
  transform: translateY(-1px);
}

.copy-link-btn:active {
  transform: translateY(0);
}

.copy-link-btn svg {
  width: 14px;
  height: 14px;
}

/* Main Content */
.calculator-page {
  padding: 2rem 0 5rem;
}

/* Calculator Card */
.calculator-card {
  background: #ffffff;
  border: 1px solid #eee;
  border-radius: 16px;
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

/* URL Input Section */
.url-section {
  text-align: center;
}

.url-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #111;
  margin-bottom: 0.75rem;
}

.url-description {
  color: #666;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.url-input-wrapper {
  display: flex;
  gap: 1rem;
  max-width: 600px;
  margin: 0 auto 1.5rem;
}

.url-input {
  flex: 1;
  padding: 1rem 1.25rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.2s ease;
  background: #fcfcfc;
}

.url-input:focus {
  outline: none;
  border-color: #000;
  background: #fff;
}

.fetch-btn {
  background: #000;
  color: white;
  padding: 1rem 2rem;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  font-size: 1rem;
}

.fetch-btn:hover:not(:disabled) {
  background: #333;
  transform: translateY(-1px);
}

.fetch-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.help-box {
  background: #f9f9f9;
  border-radius: 8px;
  padding: 1rem 1.5rem;
  text-align: left;
  max-width: 600px;
  margin: 0 auto;
  border: 1px solid #eee;
}

.help-summary {
  font-weight: 600;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.help-content {
  margin-top: 1rem;
  color: #666;
  font-size: 0.9rem;
  line-height: 1.6;
}

.help-content ol {
  padding-left: 1.5rem;
}

.help-content li {
  margin-bottom: 0.5rem;
}

/* Loading State */
.loading-state {
  text-align: center;
  padding: 3rem;
  display: none;
}

.loading-spinner, .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #eee;
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1.5rem;
}

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

.loading-text {
  color: #666;
  font-size: 1rem;
}

/* Error State */
.error-message {
  background: #fff5f5;
  border: 1px solid #fed7d7;
  color: #c53030;
  padding: 1rem;
  border-radius: 8px;
  margin-top: 1.5rem;
  display: none;
  font-size: 0.95rem;
}

/* Results Section */
.results-section {
  margin-top: 3rem;
  display: none;
  animation: fadeIn 0.5s ease;
}

.results-section.show {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.total-score-card {
  background: #000;
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  color: white;
  margin-bottom: 2rem;
}

.total-label {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.total-score {
  font-family: 'Inter', sans-serif;
  font-size: 4rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.5rem;
  letter-spacing: -2px;
}

.total-max {
  font-size: 0.95rem;
  opacity: 0.6;
  margin-bottom: 1rem;
}

.slot-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.15);
  padding: 0.4rem 1rem;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.85rem;
}

/* Percentile Prediction Card */
.percentile-card {
  background: #f9f9f9;
  border: 1px solid #eee;
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  color: #111;
  margin-bottom: 2rem;
}

.percentile-header {
  margin-bottom: 0.5rem;
}

.percentile-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.percentile-value {
  font-family: 'Inter', sans-serif;
  font-size: 3.5rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.5rem;
  letter-spacing: -2px;
  color: #000;
}

.percentile-note,
.percentile-message,
.percentile-disclaimer {
  background: #fff;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #888;
  border: 1px solid #eee;
  display: inline-block;
  margin-bottom: 0.75rem;
}

.section-results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .section-results-grid {
    grid-template-columns: 1fr;
  }
}

.section-result-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.75rem;
  border: 1.5px solid #e0e0e0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.section-result-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
  border-color: #ccc;
}

.result-section-name {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 1.5rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.section-metric-row {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px dashed #e5e5e5;
}

.section-metric-row:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.metric-label-text {
  display: block;
  font-size: 0.75rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.metric-value-large {
  font-family: 'Inter', sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: #000;
  letter-spacing: -1px;
  line-height: 1;
}

.metric-value-medium {
  font-family: 'Inter', sans-serif;
  font-size: 1.8rem;
  font-weight: 600;
  color: #000;
  letter-spacing: -0.5px;
  line-height: 1;
}

.question-type-breakdown {
  display: flex;
  justify-content: space-around;
  gap: 1rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #fafafa;
  border-radius: 8px;
  border: 1px solid #f0f0f0;
}

.breakdown-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.breakdown-label {
  font-size: 0.65rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.35rem;
  font-weight: 500;
}

.breakdown-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: #333;
}

.breakdown-value.correct {
  color: #059669;
}

.breakdown-value.incorrect {
  color: #DC2626;
}

.section-percentile-display {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 0.5rem;
}

.section-percentile-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #000;
  letter-spacing: -0.5px;
}


/* Leaderboard CTA */
.leaderboard-cta {
  text-align: center;
  padding: 2rem;
  margin-top: 2rem;
}

.leaderboard-btn {
  background: #000;
  color: #fff;
  border: 1px solid #000;
  padding: 0.875rem 2rem;
  font-size: 1rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.leaderboard-btn:hover {
  background: #333;
  color: #fff;
}

/* Leaderboard Section */
.leaderboard-section {
  margin-top: 2rem;
  background: white;
  border-radius: 12px;
  border: 1px solid #eee;
  overflow: hidden;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.leaderboard-header {
  background: #f9f9f9;
  padding: 1.5rem;
  text-align: center;
  border-bottom: 1px solid #eee;
}

.leaderboard-header h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: #000;
}

.leaderboard-subtitle {
  font-size: 0.9rem;
  color: #666;
}

.leaderboard-table-container {
  overflow-x: auto;
}

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

.leaderboard-table th,
.leaderboard-table td {
  padding: 1rem;
  text-align: center;
  border-bottom: 1px solid #eee;
  font-size: 0.95rem;
}

.leaderboard-table th {
  background: #fff;
  font-weight: 600;
  color: #666;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.leaderboard-table tbody tr:last-child td {
  border-bottom: none;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-weight: 600;
  font-size: 0.85rem;
  background: #f0f0f0;
  color: #666;
}

.rank-1 .rank-badge { background: #000; color: white; }
.rank-2 .rank-badge { background: #333; color: white; }
.rank-3 .rank-badge { background: #666; color: white; }

/* Leaderboard Footer & Pagination */
.leaderboard-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid #eee;
  background: #fafafa;
  flex-wrap: wrap;
  gap: 1rem;
}

.leaderboard-info {
  color: #666;
  font-size: 0.9rem;
  font-weight: 500;
}

.leaderboard-info span {
  color: #000;
  font-weight: 600;
}

.leaderboard-pagination {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.pagination-btn {
  padding: 0.5rem 0.875rem;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
  background: #f5f5f5;
  border-color: #999;
  color: #000;
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-btn.active {
  background: #000;
  color: white;
  border-color: #000;
}

.pagination-ellipsis {
  padding: 0.5rem 0.5rem;
  color: #999;
  font-weight: 500;
}

.user-cell { font-weight: 500; color: #000; }
.score-cell { font-weight: 500; color: #333; }
.total-cell { font-weight: 700; color: #000; }
.percentile-cell { font-weight: 600; color: #000; }
.slot-cell { 
  background: #f5f5f5; 
  color: #666; 
  padding: 0.2rem 0.6rem; 
  border-radius: 4px; 
  font-size: 0.8rem;
}

.loading-row, .no-data-row {
  padding: 3rem !important;
  color: #888;
}

.current-user {
  background: #fcfcfc !important;
  font-weight: 600;
}

/* Footer - Minimal */
footer {
  background: #fff;
  color: #111;
  padding: 4rem 0 2rem;
  border-top: 1px solid #eee;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-section h4 {
  color: #000;
  margin-bottom: 1.2rem;
  font-weight: 600;
  font-size: 1rem;
}

.footer-section p,
.footer-section a {
  color: #666;
  text-decoration: none;
  line-height: 1.6;
  font-size: 0.95rem;
  transition: color 0.2s ease;
}

.footer-section ul {
  list-style: none;
}

.footer-section li {
  margin-bottom: 0.75rem;
}

.footer-section a:hover {
  color: #000;
}

.footer-bottom {
  border-top: 1px solid #eee;
  padding-top: 2rem;
  text-align: center;
  color: #888;
  font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 20px;
  }

  .nav-links {
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
  }

  .hero-title {
    font-size: 2rem;
  }

  .browser-warning {
    flex-direction: row;
    align-items: flex-start;
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    gap: 0.625rem;
    margin: 1.25rem 1rem 0;
  }

  .browser-warning .warning-icon {
    width: 18px;
    height: 18px;
  }

  .warning-link {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .link-input {
    min-width: 100%;
    font-size: 0.8rem;
  }

  .copy-link-btn {
    width: 100%;
    justify-content: center;
  }

  .url-input-wrapper {
    flex-direction: column;
  }

  .fetch-btn {
    width: 100%;
    justify-content: center;
  }

  .total-score {
    font-size: 3rem;
  }

  /* Leaderboard pagination on mobile */
  .leaderboard-footer {
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    gap: 1rem;
  }

  .leaderboard-info {
    font-size: 0.85rem;
    text-align: center;
  }

  .leaderboard-pagination {
    flex-wrap: wrap;
    justify-content: center;
  }

  .pagination-btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
  }
}

/* Mini spinner for button */
.mini-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Leaderboard Toggle Button */
.leaderboard-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #000;
  color: #fff;
  padding: 0.875rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.leaderboard-toggle-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  background: #222;
}

.leaderboard-toggle-btn svg {
  width: 20px;
  height: 20px;
}

