/* RATE Thailand Results Stylesheet */
:root {
  --rate-navy: #001256;
  --rate-navy-dark: #000c3b;
  --rate-navy-light: #001d70;
  --rate-blue-sub: #3a4a80;
  --rate-bg: #f1f5f9;
  
  --color-gold-bg: #fff9db;
  --color-gold-border: #fcd34d;
  --color-gold-text: #854d0e;
  
  --color-silver-bg: #f3f4f6;
  --color-silver-border: #cbd5e1;
  --color-silver-text: #334155;
  
  --color-bronze-bg: #fef3c7;
  --color-bronze-border: #fde68a;
  --color-bronze-text: #92400e;
  
  --color-green-bg: #ecfdf5;
  --color-green-border: #a7f3d0;
  --color-green-text: #065f46;
  
  --color-blue-bg: #eff6ff;
  --color-blue-border: #bfdbfe;
  --color-blue-text: #1e40af;
  
  --font-rate-thai: 'IBM Plex Sans Thai', 'Kanit', sans-serif;
  --font-rate-en: 'Space Grotesk', 'Inter', sans-serif;
}

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

body {
  background-color: var(--rate-bg);
  font-family: var(--font-rate-thai);
  color: #1e293b;
  line-height: 1.5;
  min-height: 100vh;
}

/* Navbar */
.rate-navbar {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 2px 10px rgba(0, 18, 86, 0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
  flex: 1;
}

.brand-logo-circle {
  font-size: 28px;
  background: #f0f4ff;
  border: 2px solid #001256;
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-family: var(--font-rate-thai);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--rate-navy);
  line-height: 1.1;
}

.brand-sub-en {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--rate-navy);
  line-height: 1.3;
}

.brand-sub-th {
  font-size: 0.68rem;
  font-weight: 400;
  color: var(--rate-blue-sub);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

@media (max-width: 720px) {
  .navbar-content {
    gap: 8px;
    padding: 8px 10px;
  }

  .brand-group {
    align-items: flex-start;
    gap: 8px;
  }

  .brand-logo-circle {
    width: 42px;
    height: 42px;
    font-size: 22px;
  }

  .brand-title {
    font-size: 1rem;
  }

  .brand-sub-en {
    font-size: 0.6rem;
  }

  .navbar-actions {
    gap: 6px;
  }

  .live-status-pill {
    padding: 4px 7px;
  }

  .live-text {
    display: none;
  }

  .btn-referee-link {
    font-size: 0;
    padding: 7px 9px;
  }

  .btn-referee-link::before {
    content: '📱';
    font-size: 16px;
  }
}

.live-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: ratePulse 1.5s infinite;
}

@keyframes ratePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.5; }
}

.btn-referee-link {
  background: var(--rate-navy);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 24px;
  transition: all 0.2s;
}

.btn-referee-link:hover {
  background: var(--rate-navy-light);
  transform: translateY(-1px);
}

/* Hero Banner */
.hero-banner {
  background: linear-gradient(135deg, var(--rate-navy) 0%, var(--rate-navy-light) 100%);
  color: #ffffff;
  padding: 2.2rem 1.5rem 2rem;
  text-align: center;
  position: relative;
  box-shadow: 0 8px 24px rgba(0, 18, 86, 0.15);
}

.hero-inner {
  max-width: 800px;
  margin: 0 auto;
}

.hero-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 0.82rem;
}

.hero-back-link {
  color: #ffffff;
  opacity: 0.8;
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.2s;
}

.hero-back-link:hover {
  opacity: 1;
}

.hero-sync-time {
  opacity: 0.65;
  font-size: 0.78rem;
}

.hero-category-label {
  font-family: 'Inter', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.6;
  margin-bottom: 6px;
}

.hero-title {
  font-family: var(--font-rate-en);
  font-weight: 800;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.team-count-badge {
  font-size: 0.55em;
  font-weight: 400;
  opacity: 0.7;
  font-family: var(--font-rate-thai);
  letter-spacing: 0;
}

.hero-status-row {
  display: flex;
  justify-content: center;
}

.status-badge {
  background: rgba(34, 197, 94, 0.2);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, 0.4);
  padding: 4px 16px;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 700;
}

/* Results Container */
.results-container {
  max-width: 760px;
  margin: -16px auto 40px;
  padding: 0 16px;
  position: relative;
  z-index: 10;
}

/* Filter Card */
.filter-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  border: 1px solid #e2e8f0;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 8px 12px;
  gap: 8px;
}

.search-icon {
  font-size: 15px;
  color: #64748b;
}

.search-input-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-rate-thai);
  font-size: 14px;
  color: #1e293b;
}

.clear-search-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  display: none;
}

.filter-award-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.award-tab {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #475569;
  font-family: var(--font-rate-thai);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.award-tab.active {
  background: var(--rate-navy);
  color: #ffffff;
  border-color: var(--rate-navy);
}

/* Active Track Banner */
.active-track-banner {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  color: #fff;
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #334155;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.track-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pulse-ring {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #ef4444;
  box-shadow: 0 0 10px #ef4444;
  animation: ratePulse 1s infinite;
}

.track-label {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
}

.track-team-info strong {
  font-size: 16px;
  color: #38bdf8;
  margin-right: 6px;
}

.track-team-info span {
  font-size: 12px;
  color: #cbd5e1;
}

.track-timer {
  font-family: var(--font-rate-en);
  font-size: 22px;
  font-weight: 800;
  color: #facc15;
  letter-spacing: 1px;
}

/* Results List & Cards */
.results-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.loading-state {
  text-align: center;
  padding: 40px;
  color: #64748b;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: var(--rate-navy);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Individual Team Card */
.team-result-card {
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 14px 16px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.team-result-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

/* Tier Color Variations */
.team-result-card.tier-gold {
  background: var(--color-gold-bg);
  border-color: var(--color-gold-border);
}
.team-result-card.tier-silver {
  background: var(--color-silver-bg);
  border-color: var(--color-silver-border);
}
.team-result-card.tier-bronze {
  background: var(--color-bronze-bg);
  border-color: var(--color-bronze-border);
}
.team-result-card.tier-green {
  background: var(--color-green-bg);
  border-color: var(--color-green-border);
}
.team-result-card.tier-blue {
  background: var(--color-blue-bg);
  border-color: var(--color-blue-border);
}

/* Card Main Row */
.card-main-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.rank-badge-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-rate-en);
  font-size: 18px;
  font-weight: 800;
  background: rgba(0, 0, 0, 0.06);
  color: #1e293b;
  flex-shrink: 0;
}

.tier-gold .rank-badge-box {
  background: #fef08a;
  color: #854d0e;
}
.tier-silver .rank-badge-box {
  background: #e2e8f0;
  color: #334155;
}
.tier-bronze .rank-badge-box {
  background: #fed7aa;
  color: #9a3412;
}

.team-main-meta {
  flex: 1;
  min-width: 0;
}

.team-code-tag {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  display: block;
}

.team-name-title {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.school-name-text {
  font-size: 12px;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.province-name-text,
.detail-province {
  margin-top: 3px;
  font-size: 11px;
  color: #64748b;
}

/* Card Score / Time Box */
.time-score-box {
  text-align: right;
  flex-shrink: 0;
}

.best-time-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #64748b;
}

.best-time-value {
  font-family: var(--font-rate-en);
  font-size: 20px;
  font-weight: 800;
  color: var(--rate-navy);
  line-height: 1.1;
}

.award-pill-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-block;
  margin-top: 3px;
  background: rgba(0, 0, 0, 0.05);
  color: #334155;
}

.tier-gold .award-pill-tag { background: #fef08a; color: #854d0e; }
.tier-silver .award-pill-tag { background: #e2e8f0; color: #334155; }
.tier-bronze .award-pill-tag { background: #fed7aa; color: #9a3412; }
.tier-green .award-pill-tag { background: #bbf7d0; color: #166534; }
.tier-blue .award-pill-tag { background: #bae6fd; color: #075985; }

/* Accordion Toggle */
.card-accordion-btn {
  background: none;
  border: none;
  color: #64748b;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 0 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
  width: 100%;
}

.card-details-panel {
  display: none;
  padding-top: 10px;
  margin-top: 6px;
  font-size: 12px;
  color: #334155;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.card-details-panel.open {
  display: block;
}

.details-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 600px) {
  .details-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.round-breakdown-row {
  display: flex;
  gap: 12px;
  background: rgba(0, 0, 0, 0.03);
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 11px;
}

.round-pill strong {
  color: var(--rate-navy);
}

/* Footer */
.rate-footer {
  text-align: center;
  padding: 30px 16px;
  font-size: 12px;
  color: #64748b;
  border-top: 1px solid #e2e8f0;
  background: #ffffff;
}

.footer-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}
