/* ════════════════════════════════════════
   SIDEBAR — Bench list, filters, panel
   All values inherit from theme.css tokens.
════════════════════════════════════════ */


/* ── SIDEBAR SHELL ────────────────────── */

.sidebar {
  width: 400px;
  flex-shrink: 0;
  background: var(--white);
  color: var(--bark);
  font-size: var(--text-base);
  border-right: var(--border-divider);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: var(--z-sidebar);
  position: relative;
}

#sidebarResizeHandle {
  width: 5px;
  cursor: col-resize;
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 10;
  background: transparent;
  transition: background var(--transition-base);
}
#sidebarResizeHandle:hover { background: var(--moss-t20); }


/* ── SEARCH ───────────────────────────── */

.search-wrap {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-divider);
}

.search-box    { position: relative; }

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-base);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 40px 9px 34px;
  border: var(--ui-surface-border);
  border-radius: var(--radius-full);
  font-size: var(--text-base);
  background: var(--cream);
  color: var(--bark);
  outline: none;
  transition: border-color var(--transition-base);
}
.search-input:focus {
  border-color: var(--bark-light);
  background: var(--white);
}
.search-input::placeholder { color: var(--stone); }

.search-input-no-toggle {
  padding-right: 12px;
}

.search-seg-toggle {
  margin-top: var(--space-2);
  border-radius: var(--radius-full);
  border: var(--ui-surface-border);
  background: var(--cream);
}

.search-seg-btn {
  padding: 6px 0;
  border: none;
  background: transparent;
  color: var(--stone-dark);
  font-family: var(--font-primary);
  transition: background var(--transition-base), color var(--transition-base);
  border-radius: 0;
}
.search-seg-btn:first-child { border-radius: var(--radius-full) 0 0 var(--radius-full); }
.search-seg-btn:last-child  { border-radius: 0 var(--radius-full) var(--radius-full) 0; }
.search-seg-btn.is-active {
  background: var(--moss);
  color: var(--white);
  font-weight: var(--weight-semibold);
}
.search-seg-btn:not(.is-active):hover {
  background: var(--moss-t20, rgba(80,120,70,0.12));
  color: var(--bark);
}

.user-search-results {
  padding: var(--space-2) 0;
  flex: 1;
  overflow-y: auto;
  min-height: 0; /* required for flex children to actually shrink and scroll */
}
.user-search-row {
  padding: 9px var(--space-4);
  transition: background var(--transition-base);
}
.user-search-row:hover { background: var(--cream); }
.user-search-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.user-search-avatar-placeholder {
  font-size: 18px;
}
.user-search-name {
  font-weight: var(--weight-semibold);
}
.user-search-empty {
  padding: var(--space-5) var(--space-4);
  color: var(--stone);
}


/* ── STATS BAR ────────────────────────── */

.stats-bar {
  display: flex;
  border-bottom: var(--border-divider);
  background: var(--cream);
}

.stat-item {
  flex: 1;
  padding: var(--space-2) 0;
  text-align: center;
}
.stat-label {
  letter-spacing: 0.4px;
}


/* ── TABS ─────────────────────────────── */

/* User-search "top users" leaderboard */
.user-top-list {
  padding: var(--space-2) 0;
}
.user-top-row {
  padding: 10px var(--space-4);
  transition: background var(--transition-base);
  border-bottom: var(--border-divider);
}
.user-top-row:last-child { border-bottom: none; }
.user-top-row:hover { background: var(--cream); }
.user-top-rank {
  font-family: var(--font-display);
  width: 28px;
}
.user-top-rank.gold,
.user-top-rank.silver,
.user-top-rank.bronze { color: var(--text-color-1); }
.user-top-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 18px;
}
.user-top-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.user-top-score {
  font-family: var(--font-display);
}

.sidebar-tabs {
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3) var(--space-1);
}

.tab {
  flex: 1;
  border: var(--btn-style-border-width) solid var(--btn-color-neutral-border);
  background: var(--btn-color-neutral-bg);
  color: var(--btn-color-neutral-ink);
  cursor: pointer;
  padding: var(--btn-size-sm-py) var(--btn-size-sm-px);
  font-size: var(--btn-size-sm-font);
  font-weight: var(--btn-style-font-weight);
  border-radius: var(--btn-style-radius);
  transition: max-width 0.28s cubic-bezier(0.4,0,0.2,1),
              opacity 0.22s ease,
              padding 0.28s ease,
              color var(--transition-base),
              border-color var(--transition-base),
              background var(--transition-base);
}

/* Sort dropdown trigger */
.tab-sort-wrap {
  position: relative;
  margin-left: auto;
  flex-shrink: 0;
}
.tab-sort-btn {
  border: var(--btn-style-border-width) solid var(--btn-color-neutral-border);
  background: var(--btn-color-neutral-bg);
  border-radius: var(--btn-style-radius);
  padding: var(--btn-size-sm-py) var(--btn-size-sm-px);
  font-size: var(--btn-size-sm-font);
  cursor: pointer;
  color: var(--btn-color-neutral-ink);
  margin: 0 var(--space-2);
  transition: var(--btn-style-transition);
  line-height: 1;
}
.tab-sort-btn:hover,
.tab-sort-btn.has-filter {
  background: var(--btn-color-neutral-bg-hover);
  color: var(--btn-color-neutral-ink);
  border-color: var(--btn-color-neutral-border);
}
.tab-sort-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--white);
  border: var(--border-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 1200;
  min-width: 170px;
  flex-direction: column;
  overflow: hidden;
}
.tab-sort-dropdown.is-open {
  display: flex;
}
.tab-sort-dropdown button {
  border: none;
  background: none;
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  cursor: pointer;
  color: var(--bark-dark);
  transition: background var(--transition-base);
}
.tab-sort-dropdown button:hover,
.tab-sort-dropdown button.is-active {
  background: var(--moss-t04);
  color: var(--moss);
}
.tab.active {
  color: var(--btn-color-primary-ink);
  border-color: var(--btn-color-primary-border);
  background: var(--btn-color-primary-bg);
}
.tab:hover:not(.active) {
  color: var(--btn-color-neutral-ink);
  background: var(--btn-color-neutral-bg-hover);
}
.tab-refresh {
  border: var(--btn-style-border-width) solid var(--btn-color-neutral-border);
  background: var(--btn-color-neutral-bg);
  cursor: pointer;
  padding: var(--btn-size-sm-py) var(--btn-size-sm-px);
  line-height: 1;
  color: var(--btn-color-neutral-ink);
  border-radius: var(--btn-style-radius);
  transition: var(--btn-style-transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.sidebar-tabs .tab-refresh {
  margin: 0;
}
.tab-refresh-icon {
  width: 16px;
  height: 16px;
}
.tab-refresh:hover {
  background: var(--btn-color-neutral-bg-hover);
  color: var(--btn-color-neutral-ink);
  transform: translateY(var(--btn-style-lift-hover));
  box-shadow: var(--btn-style-shadow-hover);
}
.tab-refresh:disabled,
.tab-refresh.is-cooldown {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  background: none;
}
.tab-refresh.is-loading .tab-refresh-icon {
  animation: tabRefreshSpin 0.9s linear infinite;
}
@keyframes tabRefreshSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}


/* ── FILTER BAR ───────────────────────── */

.filter-chip {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: var(--border-card);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  cursor: pointer;
  background: var(--white);
  color: var(--stone-dark);
  transition: all 0.18s;
  flex-shrink: 0;
}
.filter-chip.active {
  background: var(--moss);
  color: white;
  border-color: var(--moss);
}


/* ── SIDEBAR CONTENT ──────────────────── */

.sidebar-content {
  padding: var(--space-3) var(--space-3);
}

.sidebar-content::-webkit-scrollbar { width: 4px; }
.sidebar-content::-webkit-scrollbar-thumb {
  background: var(--stone);
  border-radius: 4px;
}


/* ── SIDEBAR DETAIL (bench panel) ─────── */

.sidebar-detail {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  position: absolute;
  inset: 0;
  background: var(--white);
  transform: translateX(100%);
  transition: transform var(--transition-slow);
  z-index: 2;
}
.sidebar-detail.open { transform: translateX(0); }

.sidebar-detail-shell {
  min-height: 100%;
}
.sidebar-detail-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-detail-scroll::-webkit-scrollbar-thumb {
  background: var(--stone);
  border-radius: 4px;
}

.sidebar-detail-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-divider);
}

.sidebar-detail-actions {
  margin-left: auto;
}
.panel-share-btn {
  height: 32px;
  padding: 0 var(--space-3);
}


/* ── BENCH CARD HELPERS ───────────────── */

/* Stars */
.stars      { display: flex; gap: 1px; }
.star       { font-size: var(--text-base); color: var(--stone); }
.star.filled { color: var(--gold); }

/* Tags */
.tags-row {
 margin-top: 7px;
}

.tag {
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.2px;
}
.tag-sunny    { background: #fff3cc; color: #9a7400; }
.tag-shady    { background: #d4e8d4; color: #2d5a2d; }
.tag-view     { background: #cce0f0; color: #1a4a6e; }
.tag-quiet    { background: #f0d4e8; color: #6e1a4a; }
.tag-comfy    { background: #e8d4cc; color: #6e2a1a; }
.tag-other    { background: #e8e4dc; color: #5a4a3a; }
.tag-reported { background: #fde8e6; color: var(--red); }

/* ── EMPTY STATE ──────────────────────── */

.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--stone-dark);
}
.empty-state .big-icon  { font-size: 45px; margin-bottom: var(--space-2); }
.empty-state p          { font-size: var(--text-base); line-height: 1.6; margin-bottom: var(--space-4); }
.empty-state .btn {
  display: block;
  margin: 0 auto var(--space-2);
  max-width: 240px;
}
.empty-state .btn:last-of-type {
  margin-bottom: 0;
}


/* ── LEADERBOARD ROWS ─────────────────── */

.lb-row {
  padding: var(--space-2) 0;
  border-bottom: var(--border-divider);
}
.lb-row:last-child { border-bottom: none; }

.lb-rank {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  width: 28px;   /* intentional: tight rank column */
  text-align: center;
  flex-shrink: 0;
}
.lb-rank.gold   { color: #ffd700; }
.lb-rank.silver { color: #c0c0c0; }
.lb-rank.bronze { color: #cd7f32; }

/* Shared avatar used in leaderboard, bench list, comments */
.lb-avatar {
  background: var(--ui-avatar-fallback-bg);
  color: var(--ui-avatar-fallback-ink);
  width: var(--avatar-md);
  height: var(--avatar-md);
}
.lb-name:hover { color: var(--moss); }
.lb-score {
 font-family: var(--font-display);
}


/* ── GLOBAL STATS MODAL ───────────────── */

.global-stats-overlay { max-width: 400px !important; }

.global-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  padding: var(--space-5);
}

.gs-card {
  background: var(--cream);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-align: center;
}
.gs-num   { font-family: var(--font-display); }
.gs-label {
  font-size: var(--text-xs);
  color: var(--stone-dark);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: var(--space-1);
}

/* Top 5 most visited block */
.gs-top5 { text-align: left; padding: var(--space-3) var(--space-4); }
.gs-top5-row {
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border-light);
}
.gs-top5-row:last-child { border-bottom: none; }
.gs-top5-rank { min-width: 22px; }


/* ── ACHIEVEMENTS ─────────────────────── */

/* Shared achievement component — used in both
   special profile grid and normal profile list.
   Themed via .achievement-theme-blue/orange. */

.achievements-section {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.achievements-title {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-2);
  opacity: 0.5;
}
.achievements-title-blue   { color: rgba(71, 206, 255, 0.5); }
.achievements-title-orange { color: rgba(204, 120, 92, 0.5); }

.achievements-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  max-height: 120px;
  overflow-y: auto;
  padding-right: var(--space-1);
  padding-bottom: 2px;
}
.achievements-grid::-webkit-scrollbar       { width: 4px; }
.achievements-grid::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

/* Base achievement chip */
.achievement {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 5px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  border: 1px solid;
  transition: all var(--transition-base);
}

/* Earned/locked states */
.achievement.earned   { opacity: 1; }
.achievement.locked,
.profile-achievement.locked {
  opacity: 0.3;
  filter: grayscale(1);
}

/* Themed achievement grids — earned within themed context */
.achievements-grid .achievement.earned.achievement-theme-blue {
  background: rgba(71, 206, 255, 0.10);
  border-color: rgba(71, 206, 255, 0.40);
  color: rgba(71, 206, 255, 0.90);
}
.achievements-grid .achievement.earned.achievement-theme-orange {
  background: rgba(204, 120, 92, 0.10);
  border-color: rgba(204, 120, 92, 0.40);
  color: rgba(204, 120, 92, 0.90);
}
.achievements-grid .achievement.locked.achievement-theme-blue {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  color: rgba(255, 255, 255, 0.60);
  opacity: 1;   /* override the .locked rule — themed lock has own style */
  filter: none;
}
.achievements-grid .achievement.locked.achievement-theme-orange {
  background: transparent;
  border-color: rgba(196, 180, 154, 0.30);
  color: rgba(196, 180, 154, 0.50);
  opacity: 1;
  filter: none;
}

.achievement-clickable { cursor: pointer; }

/* Difficulty badge on achievement grid chips */
.ach-diff-badge {
  display: block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-top: 3px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  width: fit-content;
}
.ach-diff-badge.ach-diff-easy      { background: #d4f4dd; color: #1a7a38; }
.ach-diff-badge.ach-diff-medium    { background: #dde8ff; color: #2451b7; }
.ach-diff-badge.ach-diff-hard      { background: #ffe8d0; color: #b74c10; }
.ach-diff-badge.ach-diff-legendary { background: linear-gradient(90deg,#fff1c2,#fcd8ff); color: #7a3a9a; }

/* Normal profile achievements (non-themed) */
.profile-achievements {
  margin: var(--space-3) 0 var(--space-1);
  max-height: 120px;
  overflow-y: auto;
  padding-right: var(--space-1);
}
.profile-achievements::-webkit-scrollbar       { width: 4px; }
.profile-achievements::-webkit-scrollbar-thumb { background: var(--stone); border-radius: 4px; }

.profile-achievement {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  margin: var(--space-1) 3px;   /* 3px is intentional tight chip gap */
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  background: var(--cream);
  border: var(--border-card);
  color: var(--bark);
}


/* ── COMMENTS SECTION ─────────────────── */

.comments-section {
  margin-top: var(--space-4);
  border-top: var(--border-divider);
  padding-top: var(--space-4);
}

.comments-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--bark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--space-2);
}
