/* results.css - Unified styles for results export */

/* ================= GLOBAL RESETS ================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-family: 'Inter', sans-serif; }
body { background: #f4f7f6; color: #1a202c; line-height: 1.5; }

/* ================= COLORS & VARIABLES ================= */
:root {
  --gold: #d4af37;
  --gold-bg: #fffbf0;
  --silver: #94a3b8;
  --bronze: #cd7f32;
  --gray: #e2e8f0;
  --red: #e63946;
  --text-dark: #1e293b;
  --text-light: #64748b;
  --primary-color: #3b82f6;
  --border-color: #e2e8f0;
  --orange-summary: #f7b867;
  --orange-row: #fff4e6;
}

/* ================= SHARED STYLES ================= */
.badge-mistake { display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.mistake-b { background: #fee2e2; color: #ef4444; }
.mistake-m { background: #fef3c7; color: #d97706; }
.mistake-s { background: #e0f2fe; color: #0284c7; }

.tr-container { max-width: 900px; margin: 0 auto; padding: 40px 20px 80px; }

/* ================= HEADER CARD ================= */
.tr-header-card { 
  display: flex; 
  align-items: center; 
  background: #ffffff; 
  border: 1px solid var(--gray); 
  border-radius: 8px; 
  margin-bottom: 30px; 
  padding: 20px; 
  position: relative; 
  overflow: hidden; 
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.tr-header-card::before { 
  content: ''; 
  position: absolute; 
  left: 0; top: 0; bottom: 0; 
  width: 6px; 
  background: var(--red); 
}
.tr-header-content {
  display: flex;
  align-items: center;
  gap: 20px;
}
.tr-logo { max-width: 70px; height: auto; border-radius: 6px; object-fit: contain; }
.tr-header-text { display: flex; flex-direction: column; justify-content: center; }
.tr-eyebrow { font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-light); margin-bottom: 4px; }
.tr-title { font-family: 'Montserrat', sans-serif; font-size: clamp(20px, 5vw, 42px); font-weight: 900; color: var(--text-dark); text-transform: uppercase; line-height: 1.1; letter-spacing: -0.5px; }
.tr-organizer { font-size: 14px; color: var(--text-light); margin-top: 4px; font-weight: 500; }

/* ================= QUICK LINKS (STICKY NAV) ================= */
.tr-quick-links-wrapper {
  position: sticky; top: 0; z-index: 100;
  background: rgba(244, 247, 246, 0.95); backdrop-filter: blur(8px);
  padding: 15px 0; margin-bottom: 30px;
  border-bottom: 1px solid var(--gray);
}
.tr-quick-links {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 5px;
  scrollbar-width: none; -ms-overflow-style: none; /* Hides scrollbar */
}
.tr-quick-links::-webkit-scrollbar { display: none; }
.tr-pill {
  white-space: nowrap; text-decoration: none; padding: 8px 16px; border-radius: 20px;
  font-size: 13px; font-weight: 600; color: var(--text-dark);
  background: #ffffff; border: 1px solid var(--gray);
  transition: all 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.tr-pill:hover, .tr-pill:active { background: var(--text-dark); color: #ffffff; border-color: var(--text-dark); }

/* ================= CATEGORIES & RESULT CARDS ================= */
.tr-category { margin-bottom: 50px; scroll-margin-top: 80px; }
.tr-cat-title { font-family: 'Montserrat', sans-serif; font-size: 22px; font-weight: 800; color: var(--text-dark); padding-bottom: 10px; border-bottom: 2px solid var(--gray); margin-bottom: 20px; }

.tr-card { 
  display: flex; 
  align-items: center; 
  background: #ffffff; 
  border: 1px solid var(--gray); 
  border-radius: 8px; 
  margin-bottom: 12px; 
  padding: 16px 20px; 
  transition: transform 0.2s, box-shadow 0.2s; 
  position: relative; 
  overflow: hidden; 
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
.tr-card:hover { transform: translateY(-2px); box-shadow: 0 8px 15px rgba(0,0,0,0.05); }

/* Medal colors for card borders */
.tr-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--gray); }
.tr-card.rank-1 { background: var(--gold-bg); border-color: rgba(212, 175, 55, 0.3); }
.tr-card.rank-1::before { background: var(--gold); }
.tr-card.rank-2::before { background: var(--silver); }
.tr-card.rank-3::before { background: var(--bronze); }

/* Rank Numbers */
.tr-rank { width: 45px; font-family: 'Montserrat', sans-serif; font-size: 26px; font-weight: 900; color: var(--gray); }
.tr-card.rank-1 .tr-rank { color: var(--gold); }
.tr-card.rank-2 .tr-rank { color: var(--silver); }
.tr-card.rank-3 .tr-rank { color: var(--bronze); }

/* Competitor Info */
.tr-info { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.tr-names { font-size: 15px; font-weight: 700; color: var(--text-dark); line-height: 1.3; }
.tr-club { font-size: 12px; color: var(--text-light); margin-top: 3px; }

/* Scores */
.tr-score-area { text-align: right; }
.tr-score { font-family: 'Montserrat', sans-serif; font-size: 24px; font-weight: 800; color: var(--text-dark); line-height: 1; }
.tr-percentage { font-size: 11px; font-weight: 600; color: var(--text-light); margin-top: 4px; display: block; text-transform: uppercase; }
.tr-mistakes { display: flex; gap: 4px; margin-top: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* Nuoli-indikaattori */
.tr-arrow {
  font-size: 20px;
  color: var(--gray);
  margin-left: 12px;
  align-self: center;
  transition: transform 0.2s, color 0.2s;
  flex-shrink: 0;
}
.tr-card:hover .tr-arrow {
  transform: translateX(4px);
  color: var(--text-light);
}

/* ================= SCORESHEET SPECIFIC (TABLES) ================= */
.scoresheet-container {
  max-width: 1000px;
  margin: 20px auto;
  padding: 30px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.tori-uke-line {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--gray);
  padding-bottom: 15px;
}

.scores-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 14px;
}

.scores-table th, .scores-table td {
  border: 1px solid var(--gray);
  padding: 10px;
  text-align: center;
}

.scores-header-row th {
  background-color: #f8fafc;
  font-weight: 700;
  color: var(--text-dark);
}

/* Unified Orange Theme Scoresheet Colors */
.scores-table tbody tr:nth-child(odd) {
  background-color: var(--orange-row);
}
.scores-table tbody tr:nth-child(even) {
  background-color: white;
}

tr.summary-row td {
  font-weight: 800;
  background-color: var(--orange-summary) !important;
  border-top: 2px solid #e67e22;
}

/* Grouping visuals */
.group-break-row td {
  padding: 0;
  height: 4px;
  background: black !important;
  border: none !important;
}

.group-label-wrapper { position: relative; width: 100%; }
.group-label {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  padding: 2px 12px;
  border-radius: 999px;
  border: 2px solid black;
  font-weight: 800;
  font-size: 0.75rem;
  z-index: 10;
  white-space: nowrap;
}

.judges-list td {
  font-weight: 500;
}

/* ================= MEDAL TABLE ================= */
.tr-medal-card {
  background: #ffffff;
  border: 1px solid var(--gray);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
  margin-bottom: 20px;
}
.tr-medal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tr-medal-table th, .tr-medal-table td {
  padding: 12px 15px;
  text-align: left;
  border-bottom: 1px solid var(--gray);
}
.tr-medal-table th {
  background: #f8fafc;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}
.tr-medal-table tr:last-child td {
  border-bottom: none;
}
.tr-medal-table tr:hover td {
  background: #f1f5f9;
}

.tr-th-rank, .tr-td-rank { width: 40px; text-align: center !important; }
.tr-th-medal, .tr-td-medal { width: 60px; text-align: center !important; }
.tr-th-total, .tr-td-total { width: 60px; text-align: center !important; font-weight: 800; }

.tr-td-rank { font-weight: 700; color: var(--text-light); }
.tr-td-origin { font-weight: 600; color: var(--text-dark); }

.medal-circle {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  vertical-align: middle;
}
.medal-circle.gold { background: var(--gold); box-shadow: 0 0 0 2px var(--gold-bg); }
.medal-circle.silver { background: var(--silver); box-shadow: 0 0 0 2px #f1f5f9; }
.medal-circle.bronze { background: var(--bronze); box-shadow: 0 0 0 2px #fff4e6; }

@media (max-width: 600px) {
  .tr-medal-table { font-size: 13px; }
  .tr-medal-table th, .tr-medal-table td { padding: 10px 8px; }
  .tr-th-origin, .tr-td-origin { font-size: 12px; }
}

/* ================= MOBILE STYLES (Below 600px) ================= */
@media (max-width: 600px) {
  .tr-header-card { padding: 16px; }
  .tr-header-content { gap: 12px; }
  .tr-logo { max-width: 50px; }
  .tr-eyebrow { font-size: 11px; }
  .tr-title { font-size: 24px; }
  
  .tr-card { flex-wrap: wrap; padding: 15px; gap: 10px; }
  .tr-rank { width: 100%; font-size: 18px; margin-bottom: -5px; display: flex; align-items: center; gap: 5px; }
  .tr-card.rank-1 .tr-rank::after { content: ' 🥇'; font-size: 16px; }
  .tr-card.rank-2 .tr-rank::after { content: ' 🥈'; font-size: 16px; }
  .tr-card.rank-3 .tr-rank::after { content: ' 🥉'; font-size: 16px; }
  
  .tr-info { width: 100%; flex: none; }
  .tr-score-area { width: 100%; display: flex; justify-content: space-between; align-items: flex-end; border-top: 1px dashed var(--gray); padding-top: 12px; margin-top: 5px; text-align: left; }
  
  .tr-score-text { display: flex; align-items: baseline; gap: 8px; }
  .tr-percentage { display: inline; margin-top: 0; }
  .tr-mistakes { margin-top: 0; }

  .scoresheet-container { padding: 15px; margin: 10px; }
  .tori-uke-line { flex-direction: column; gap: 10px; }
  .scores-table { font-size: 12px; }
  .scores-table th, .scores-table td { padding: 5px; }
}

@media print {
  body { background: white; }
  .tr-container, .scoresheet-container { width: 100%; max-width: none; margin: 0; padding: 0; box-shadow: none; border: none; }
  .tr-quick-links-wrapper { display: none; }
  .tr-card { page-break-inside: avoid; border: 1px solid #eee; }
}
