/* === itGenius Claude Leaderboard — Design System === */
/* Company palette from Engineering Sync + LOTR warmth */

/* Outfit font loaded via <link> in index.html for faster rendering */

:root {
  --bg: #ffffff;
  --surface: #f5f7fa;
  --card-border: #e2e8f0;
  --navy: #122934;
  --accent: #f0663c;
  --accent2: #29c4a9;
  --green: #1a9a7a;
  --yellow: #c88c00;
  --red: #bf2222;
  --text: #122934;
  --text-dim: #3d5a6e;
  --text-muted: #8a9fb0;
  --parchment: #faf8f4;
  --parchment-dark: #f0ece4;
  --gold: #c8a951;
  --gold-light: #f5ecd0;
}

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

body {
  font-family: 'Outfit', Helvetica, Arial, sans-serif;
  background: var(--surface);
  color: var(--text);
  min-height: 100vh;
}

/* --- Auth Screen --- */
.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--navy);
  color: #fff;
}

.auth-screen h1 {
  font-size: 36px;
  font-weight: 700;
  margin-bottom: 8px;
}

.auth-screen .subtitle {
  font-size: 18px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.auth-screen .tagline {
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 24px;
}

.btn-google {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 32px;
  background: #fff;
  color: var(--navy);
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-google:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* --- Header --- */
.header {
  background: var(--navy);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header h1 {
  font-size: 20px;
  font-weight: 700;
}

.header-logo {
  height: 32px;
  width: auto;
}

.auth-logo {
  height: 64px;
  width: auto;
  margin-bottom: 16px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--gold);
}

.btn-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.btn-logout:hover {
  border-color: #fff;
}

.btn-save-webhook {
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-save-webhook:hover { background: #d9572f; }

.btn-test-webhook {
  padding: 8px 16px;
  background: var(--accent2);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-test-webhook:hover { background: #1a9a7a; }

/* --- Navigation Tabs --- */
.nav-tabs {
  background: #fff;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  padding: 0 24px;
  overflow-x: auto;
}

.nav-tab {
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text-dim);
}

.nav-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* --- Main Content --- */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* --- Hero Section --- */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, #1a3a4a 100%);
  border-radius: 16px;
  padding: 32px;
  color: #fff;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 200px;
  height: 100%;
  background: radial-gradient(circle at 80% 50%, rgba(200,169,81,0.1) 0%, transparent 70%);
}

.hero-stat {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 4px;
}

.hero-label {
  font-size: 16px;
  color: #8ab4c7;
  margin-bottom: 16px;
}

.hero-metrics {
  display: flex;
  gap: 32px;
  margin-top: 16px;
}

.hero-metric {
  text-align: center;
}

.hero-metric-value {
  font-size: 24px;
  font-weight: 700;
}

.hero-metric-label {
  font-size: 12px;
  color: #8ab4c7;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* --- Cards --- */
.card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(18,41,52,0.06);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.card-accent {
  border-left: 4px solid var(--accent);
}

.card-success {
  border-left: 4px solid var(--accent2);
}

/* --- Contribution Table --- */
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 10px 12px;
  border-bottom: 2px solid var(--card-border);
  cursor: pointer;
}

.leaderboard-table th:hover {
  color: var(--text-dim);
}

.leaderboard-table td {
  padding: 12px;
  border-bottom: 1px solid #eef2f6;
  font-size: 14px;
}

.leaderboard-table tr:hover {
  background: #f8f9fb;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-cell img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.user-cell .name {
  font-weight: 600;
  color: var(--navy);
}

.user-cell .pod {
  font-size: 12px;
  color: var(--text-muted);
}

.rank-cell {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-dim);
  width: 50px;
}

.rank-cell.top-1 { color: var(--gold); }
.rank-cell.top-2 { color: #8a9fb0; }
.rank-cell.top-3 { color: #b87333; }

.tier-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.tier-hobbit { background: #e6f7f2; color: var(--green); }
.tier-ranger { background: #eef2f6; color: var(--text-dim); }
.tier-elf { background: #e8f0fe; color: #1a73e8; }
.tier-wizard { background: #fef0ec; color: var(--accent); }
.tier-ring-bearer { background: var(--gold-light); color: #8b6914; }

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
}

/* --- Pod Standings --- */
/* --- Pod Bar Chart --- */
.pod-bars {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 8px 0;
}

.pod-bar-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.pod-bar-rank {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  min-width: 36px;
  text-align: center;
  padding-top: 2px;
  line-height: 1;
}

.pod-bar-info {
  flex: 1;
  min-width: 0;
}

.pod-bar-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.pod-bar-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
}

.pod-bar-lore {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.pod-bar-track {
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  height: 34px;
}

.pod-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  width: var(--bar-width);
  animation: barGrow 0.8s ease-out backwards;
  min-width: fit-content;
}

@keyframes barGrow {
  from { width: 0; opacity: 0.3; }
}

.pod-bar-value {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.pod-bar-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Quest Card --- */
.quest-card {
  background: linear-gradient(135deg, var(--parchment) 0%, #fff 100%);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 20px;
}

.quest-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

.quest-lore {
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 12px;
}

.quest-progress {
  height: 8px;
  background: var(--card-border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.quest-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 4px;
  transition: width 0.5s ease;
}

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

/* --- My Journey Tab --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--navy);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
}

.stat-trend {
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
}

.stat-trend.up { color: var(--green); }
.stat-trend.down { color: var(--red); }

.heat-map {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 12px;
}

.heat-cell {
  aspect-ratio: 1;
  border-radius: 4px;
  background: var(--surface);
}

.heat-cell.level-1 { background: #e6f7f2; }
.heat-cell.level-2 { background: #b3e8d9; }
.heat-cell.level-3 { background: #66d4b8; }
.heat-cell.level-4 { background: var(--accent2); }

/* --- Deeds/Badges --- */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.badge-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  transition: transform 0.15s;
}

.badge-card:hover {
  transform: translateY(-2px);
}

.badge-card.locked {
  opacity: 0.4;
  filter: grayscale(1);
}

.badge-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.badge-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

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

/* --- Palantir (Admin) --- */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.health-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #eef2f6;
}

.health-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.health-dot.connected { background: var(--green); }
.health-dot.missing { background: var(--red); }

/* --- Period Selector --- */
.period-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.period-btn {
  padding: 8px 16px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.period-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.period-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* --- Loading --- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 16px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--card-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

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

/* --- Member Management (unified admin table) --- */
.member-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.member-search-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
}
.member-search-input:focus { outline: none; border-color: var(--accent); }
.member-pod-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pod-filter-pill {
  padding: 5px 12px;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: #fff;
  font-family: inherit;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
}
.pod-filter-pill:hover { border-color: var(--accent); color: var(--accent); }
.pod-filter-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.member-summary {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}
.summary-connected { color: var(--green); font-weight: 600; }
.summary-missing { color: var(--red); font-weight: 600; }
.member-table-wrap {
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--card-border);
  border-radius: 8px;
}
.member-table {
  width: 100%;
  border-collapse: collapse;
}
.member-table thead { position: sticky; top: 0; z-index: 1; }
.member-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--card-border);
}
.member-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #eef2f6;
  font-size: 13px;
  vertical-align: middle;
}
.member-table tr:hover { background: #f8f9fb; }
.member-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.member-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}
.member-name { font-weight: 600; color: var(--navy); font-size: 13px; }
.member-email { font-size: 11px; color: var(--text-muted); }
.member-status-text { font-size: 12px; color: var(--text-muted); }
.pod-select-compact {
  padding: 4px 8px;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.3s;
}
.pod-select-compact:focus { outline: none; border-color: var(--accent); }

/* --- Table scroll wrapper --- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .main { padding: 16px; }
  .hero { padding: 20px; }
  .hero-stat { font-size: 32px; }
  .hero-metrics { flex-wrap: wrap; gap: 16px; }
  .nav-tabs { padding: 0 12px; }
  .nav-tab { padding: 12px 14px; font-size: 13px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .pod-bar-rank { min-width: 28px; font-size: 16px; }
  .badge-grid { grid-template-columns: repeat(2, 1fr); }
  .leaderboard-table { font-size: 13px; min-width: 600px; }
  .leaderboard-table td, .leaderboard-table th { padding: 8px; }
  .card-header { flex-direction: column; align-items: flex-start; gap: 4px; }
  .member-table { min-width: 500px; }
  .auth-screen h1 { font-size: 24px; padding: 0 16px; text-align: center; }
  .auth-screen .subtitle { font-size: 15px; }
}

@media (max-width: 480px) {
  .hero-stat { font-size: 24px; }
  .hero-label { font-size: 14px; }
  .stats-grid { grid-template-columns: 1fr; }
  .header h1 { font-size: 14px; }
  .header { padding: 12px 16px; }
  .pod-bar-value { font-size: 11px; }
  .pod-bar-name { font-size: 13px; }
  .pod-bar-lore { display: none; }
  .card-title { font-size: 14px; }
}
