/* ==========================================================================
   MLBB Meta Analyser - UI Components
   Filter pills, tab controls, hero cards, tier buckets, tables, search
   ========================================================================== */

/* Main Navigation / Tool Tabs */
.tool-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  padding-bottom: 8px;
  margin-bottom: 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

.tool-tab-btn {
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  user-select: none;
}

.tool-tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
  border-color: var(--brand-primary);
}

.tool-tab-btn.active {
  color: var(--text-inverse);
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  box-shadow: var(--tab-active-glow);
}

[data-theme="light"] .tool-tab-btn.active {
  background: #0369a1;
  border-color: #0369a1;
}

.tool-tab-btn .tab-icon {
  font-size: 1.1rem;
}

.tool-tab-btn .tab-badge-new {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--tier-s-plus);
  color: var(--text-inverse);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  margin-left: 2px;
}

/* Universal Context Bar (Persistent Rank & Timeframe across all 7 tools) */
.universal-context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 10px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

/* Control Hub (Filters Bar) */
.control-hub {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-right: 4px;
  white-space: nowrap;
}

/* Segmented Button Groups (Ranks & Timeframes) */
.segmented-control {
  display: inline-flex;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
  overflow-x: auto;
  max-width: 100%;
}

.seg-btn {
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.seg-btn:hover {
  color: var(--text-primary);
}

.seg-btn.active {
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Filter Chips (Roles & Lanes) */
.chip-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.chip-btn:hover {
  color: var(--text-primary);
  border-color: rgba(56, 189, 248, 0.3);
}

.chip-btn.active {
  color: var(--brand-primary);
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--brand-primary);
}

/* Search Bar */
.search-wrapper {
  position: relative;
  min-width: 220px;
  flex: 1;
  max-width: 380px;
}

.search-input {
  width: 100%;
  padding: 8px 36px 8px 36px;
  font-size: 0.85rem;
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.9rem;
}

.search-shortcut {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 5px;
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  pointer-events: none;
}

.search-clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear-btn:hover {
  color: var(--text-primary);
}

/* View Sub-Toggle (Tier Board vs Table) */
.view-mode-toggle {
  display: inline-flex;
  gap: 4px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 2px;
}

.view-mode-btn {
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  transition: var(--transition);
}

.view-mode-btn.active {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

/* Secondary Controls Row & Reset Button */
.secondary-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.control-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* In-Tier Sort Controls (Story 3.1) */
.tier-sort-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tier-sort-control .sort-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  white-space: nowrap;
}

.mini-segmented {
  padding: 2px;
  gap: 2px;
}

.mini-segmented .seg-btn {
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 500;
}

.filter-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--ban-rose);
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.filter-reset-btn:hover {
  background: rgba(244, 63, 94, 0.18);
  border-color: rgba(244, 63, 94, 0.45);
  color: var(--ban-rose);
  transform: translateY(-1px);
}

.filter-reset-btn:active {
  transform: translateY(0);
}

.filter-reset-btn.hidden {
  display: none !important;
}

/* ==========================================================================
   Tier List Hub (S+ to D Buckets)
   ========================================================================== */
.tier-group {
  margin-bottom: 28px;
}

.tier-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tier-badge.s-plus { background: var(--tier-s-plus-bg); color: var(--tier-s-plus); border: 1px solid var(--tier-s-plus); }
.tier-badge.s { background: var(--tier-s-bg); color: var(--tier-s); border: 1px solid var(--tier-s); }
.tier-badge.a { background: var(--tier-a-bg); color: var(--tier-a); border: 1px solid var(--tier-a); }
.tier-badge.b { background: var(--tier-b-bg); color: var(--tier-b); border: 1px solid var(--tier-b); }
.tier-badge.c { background: var(--tier-c-bg); color: var(--tier-c); border: 1px solid var(--tier-c); }
.tier-badge.d { background: var(--tier-d-bg); color: var(--tier-d); border: 1px solid var(--tier-d); }

.tier-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.tier-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

/* Hero Card (Aesthetic, Compact, Informative) */
.hero-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.hero-card:hover {
  transform: translateY(-2px);
  background: var(--bg-surface-elevated);
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: var(--shadow-md);
}

.hero-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.hero-avatar-wrapper {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
}

.hero-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hero-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-meta-tags {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.hero-role-tag {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.hero-lane-pill {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--pick-blue-bg);
  color: var(--brand-primary);
  white-space: nowrap;
}

.hero-stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 0.82rem;
  margin-top: auto;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-item .stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.stat-item .stat-val {
  font-weight: 700;
  font-size: 0.82rem;
}

.stat-val.win { color: var(--win-green); }
.stat-val.ban { color: var(--ban-rose); }
.stat-val.pick { color: var(--pick-blue); }

/* High-Density Meta Table */
.table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
}

.meta-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
  min-width: 780px;
}

.meta-table th {
  padding: 12px 16px;
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
  user-select: none;
  cursor: pointer;
  white-space: nowrap;
}

.meta-table th:hover {
  color: var(--text-primary);
}

.meta-table th.sorted-asc::after {
  content: " ▲";
  color: var(--brand-primary);
}

.meta-table th.sorted-desc::after {
  content: " ▼";
  color: var(--brand-primary);
}

.meta-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.meta-table tbody tr {
  transition: var(--transition);
  cursor: pointer;
}

.meta-table tbody tr:hover {
  background: var(--bg-surface-elevated);
}

/* Sticky # and Hero Columns (Story 3.1) */
.meta-table th:first-child,
.meta-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  width: 44px;
  min-width: 44px;
  background: var(--bg-surface-elevated);
  box-shadow: 1px 0 0 var(--border-subtle);
}

.meta-table td:first-child {
  background: var(--bg-surface);
}

.meta-table tbody tr:hover td:first-child {
  background: var(--bg-surface-elevated);
}

.meta-table th:nth-child(2),
.meta-table td:nth-child(2) {
  position: sticky;
  left: 44px;
  z-index: 3;
  min-width: 150px;
  background: var(--bg-surface-elevated);
  box-shadow: 3px 0 8px -2px rgba(0, 0, 0, 0.18);
}

.meta-table td:nth-child(2) {
  background: var(--bg-surface);
}

.meta-table tbody tr:hover td:nth-child(2) {
  background: var(--bg-surface-elevated);
}

.table-rank-num {
  font-weight: 700;
  color: var(--text-muted);
  width: 32px;
}

.table-hero-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-hero-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-surface-elevated);
}

.table-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 110px;
}

.mini-bar {
  flex: 1;
  height: 5px;
  background: var(--border-subtle);
  border-radius: 999px;
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 999px;
}

.mini-bar-fill.win { background: var(--win-green); }
.mini-bar-fill.ban { background: var(--ban-rose); }
.mini-bar-fill.pick { background: var(--pick-blue); }

/* Accessible Tooltip */
[data-tooltip] {
  position: relative;
  cursor: help;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  /* Always dark bg + white text for readability in BOTH themes */
  background: var(--tooltip-bg);
  border: 1px solid var(--tooltip-border);
  color: var(--tooltip-text);
  font-size: 0.75rem;
  font-weight: 400;
  white-space: normal;
  width: max-content;
  max-width: 220px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
