/* ── Flex Board v1.2.1 ───────────────────────────────────────────────────── */

:root {
  --fb-purple: #a800ff;
  --fb-purple-20: rgba(168,0,255,0.20);
}

.flex-board { width: 100%; position: relative; font-family: inherit; }

/* ── Top bar: 3 equal-width controls ────────────────────────────────────── */
.flex-board__topbar {
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 14px;
}

.flex-board__control,
.flex-board__filter-btn {
  flex: 1 1 0;
  min-width: 0;
}

/* Shared select style — transparent bg for dark mode compatibility */
.flex-board__select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 28px 10px 12px;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 10px;
  background: transparent;
  font-size: 14px;
  line-height: 1.3;
  appearance: auto;
  color: inherit;
  height: 100%;
}
.flex-board__select:focus {
  outline: 2px solid var(--fb-purple);
  outline-offset: 1px;
}

/* Filters button — transparent bg, same border as dropdowns */
.flex-board__filter-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 10px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  color: inherit;
  transition: outline 0.12s, border-color 0.12s;
}
.flex-board__filter-btn:hover,
.flex-board__filter-btn:focus {
  outline: 2px solid var(--fb-purple);
  outline-offset: 1px;
  border-color: var(--fb-purple);
}
/* When filters are active — keep transparent bg, just show badge */
.flex-board__filter-btn.has-filters {
  border-color: var(--fb-purple);
}

/* Override BuddyBoss active/focus color (#00efc8) on click */
.flex-board__filter-btn:active,
.flex-board__filter-btn:focus,
.flex-board__filter-btn:focus-visible {
  background: transparent !important;
  color: inherit !important;
  box-shadow: none !important;
  outline: 2px solid var(--fb-purple) !important;
  outline-offset: 1px !important;
}

.fb-filter-icon { width: 16px; height: 16px; flex-shrink: 0; }

.fb-filter-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: var(--fb-purple); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
}

/* ── Results table ───────────────────────────────────────────────────────── */
.flex-board__table-wrap {
  width: 100%;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 12px;
  overflow: hidden;
}

.flex-board__table { width: 100%; border-collapse: collapse; background: transparent; }

/* Sticky thead via display:block */
.flex-board__thead,
.flex-board__thead tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}
.flex-board__tbody {
  display: block;
  max-height: 520px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.flex-board__tbody tr { display: table; width: 100%; table-layout: fixed; }

.flex-board__thead th {
  text-align: left; padding: 13px 14px;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: #999; background: transparent;
  border-bottom: 2px solid rgba(0,0,0,.1);
}
.flex-board__thead th.flex-board__col--award { text-align: right; }

.flex-board__table tbody td { padding: 11px 14px; border-bottom: 1px solid rgba(0,0,0,.07); vertical-align: middle; }
.flex-board__table tbody tr:last-child td { border-bottom: none; }

.flex-board__col--rank  { width: 46px; }
.flex-board__col--award { width: 110px; text-align: right; }

.flex-board__user { display: flex; align-items: center; gap: 10px; }
.flex-board__avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: 0 0 38px; }
.flex-board__name { color: inherit; text-decoration: none; font-weight: 600; font-size: 14px; }
.flex-board__name:hover { text-decoration: underline; }

.flex-board__award-img { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; display: inline-block; }
.flex-board__score {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 52px; height: 36px; border-radius: 8px;
  border: 1px solid rgba(0,0,0,.12); font-weight: 800; padding: 0 10px; font-size: 14px;
}
.flex-board__loading { text-align: center; padding: 24px 14px; opacity: .6; font-size: 14px; }

/* ── Pagination ──────────────────────────────────────────────────────────── */
.flex-board__pagination { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.fb-page-btn { padding: 7px 16px; border: 1px solid rgba(0,0,0,.18); border-radius: 8px; background: transparent; cursor: pointer; font-size: 13px; font-weight: 600; transition: background 0.15s; }
.fb-page-btn:hover:not([disabled]) { background: rgba(0,0,0,.05); }
.fb-page-btn[disabled] { opacity: .38; cursor: default; }
.fb-page-info { font-size: 13px; opacity: .55; }

/* ── Modal overlay ───────────────────────────────────────────────────────── */
.fb-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99999;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; transition: opacity 0.2s ease;
}
.fb-modal-overlay[hidden] { display: none !important; }
.fb-modal-overlay.is-open { opacity: 1; }

/* Push modal up on mobile to clear app bottom nav (~60px) */
@media (max-width: 599px) {
  .fb-modal-overlay { padding-bottom: 70px; }
  .fb-modal { border-radius: 20px 20px 0 0; }
}

@media (min-width: 600px) {
  .fb-modal-overlay { align-items: center; padding: 20px; }
}

/* ── Modal box ───────────────────────────────────────────────────────────── */
.fb-modal {
  background: #fff; border-radius: 20px 20px 0 0;
  width: 100%; max-width: 560px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(30px);
  transition: transform 0.24s cubic-bezier(.22,.61,.36,1);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.fb-modal-overlay.is-open .fb-modal { transform: translateY(0); }

@media (min-width: 600px) { .fb-modal { border-radius: 20px; } }

/* Modal header — title centered, close button pinned right */
.fb-modal__header {
  display: flex; align-items: center; justify-content: center;
  position: relative;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(0,0,0,.08);
  flex-shrink: 0;
}
.fb-modal__title { font-size: 16px; font-weight: 700; text-align: center; }
.fb-modal__close {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: #f0f0f0; cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  color: #444; transition: background 0.15s;
}
.fb-modal__close:hover { background: #e0e0e0; }

/* Modal body */
.fb-modal__body { flex: 1 1 auto; overflow-y: auto; padding: 18px 20px; -webkit-overflow-scrolling: touch; }

.fb-modal__section { margin-bottom: 22px; }
.fb-modal__section:last-child { margin-bottom: 0; }
.fb-modal__section-label { font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #bbb; margin-bottom: 10px; }

.fb-modal__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 380px) { .fb-modal__grid { grid-template-columns: 1fr; } }

.fb-field__label { display: block; font-size: 12px; font-weight: 700; color: #666; margin-bottom: 5px; }
.fb-field--full { grid-column: 1 / -1; }

.fb-select {
  width: 100%; box-sizing: border-box;
  padding: 10px 28px 10px 12px;
  border: 1px solid rgba(0,0,0,.15); border-radius: 10px;
  background: transparent; font-size: 13px; line-height: 1.3;
  appearance: auto; color: inherit;
}
.fb-select:focus {
  outline: 2px solid var(--fb-purple);
  outline-offset: 1px;
}
.fb-select:disabled { opacity: .42; cursor: not-allowed; }

/* Modal footer */
.fb-modal__footer {
  display: flex; gap: 10px; padding: 14px 20px 18px;
  border-top: 1px solid rgba(0,0,0,.08); flex-shrink: 0;
}
.fb-btn {
  flex: 1; padding: 12px; border-radius: 10px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s, color 0.15s;
}

/* Clear All */
.fb-btn--ghost {
  background: #f0f0f0;
  color: #333;
  border: 1px solid rgba(0,0,0,.1);
}
.fb-btn--ghost:hover {
  background: #f0f0f0;
  color: #333;
  border-color: var(--fb-purple);
  box-shadow: 0 0 0 2px var(--fb-purple-20);
}

/* Apply Filters — identical hover treatment to Clear All */
.fb-btn--primary {
  background: #111;
  color: #fff;
  border: 1px solid transparent;
}
.fb-btn--primary:hover {
  background: #111;
  color: #fff;
  border-color: var(--fb-purple);
  box-shadow: 0 0 0 2px var(--fb-purple-20);
}

body.fb-modal-open { overflow: hidden; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .flex-board__topbar { gap: 7px; }
  .flex-board__select { font-size: 13px; padding: 9px 24px 9px 10px; }
  .flex-board__filter-btn { padding: 9px 10px; font-size: 13px; }
  .fb-filter-label { display: none; }
}

/* ── CTA Button ──────────────────────────────────────────────────────────── */
.flex-board-cta {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.flex-board-cta__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 27px;
  background: var(--fb-purple, #a800ff);
  color: #fff !important;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
  border-radius: 19px;
  text-decoration: none !important;
  white-space: nowrap;
  transition: opacity 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 0 0 0 rgba(168,0,255,0);
}

.flex-board-cta__icon {
  height: 22px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.flex-board-cta__btn:hover {
  opacity: 0.88;
  box-shadow: 0 4px 18px rgba(168,0,255,0.35);
}

/* ── METLE modal ──────────────────────────────────────────────────────────── */
.fb-metle-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
.fb-metle-overlay[hidden] { display: none; }
.fb-metle-overlay .fb-modal {
  border-radius: 16px 16px 0 0;
  max-height: 70vh;
  display: flex; flex-direction: column;
}
@media (min-width: 600px) {
  .fb-metle-overlay { align-items: center; }
  .fb-metle-overlay .fb-modal { border-radius: 16px; max-height: 80vh; }
}
.fb-metle-list {
  overflow-y: auto;
  padding: 4px 0 8px;
  display: flex; flex-direction: column; gap: 3px;
}
.fb-metle-loading, .fb-metle-empty {
  padding: 20px; text-align: center;
  font-size: 13px; color: #9ca3af;
}
.fb-metle-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 16px;
  background: none; border: 1px solid #e5e7eb; border-radius: 8px;
  cursor: pointer; font-family: inherit; text-align: left;
  transition: border-color .15s, background .15s;
}
.fb-metle-item:hover { border-color: #a800ff; background: #faf5ff; }
.fb-metle-item--active { border-color: #a800ff; background: #f5f3ff; }
.fb-metle-item--clear { color: #6b7280; font-style: italic; }
.fb-metle-name { font-size: 14px; font-weight: 600; color: #1a1a2e; }
.fb-metle-item--clear .fb-metle-name { font-weight: 400; }
.fb-metle-cat {
  font-size: 11px; font-weight: 700;
  background: #fef3c7; color: #b45309;
  padding: 2px 7px; border-radius: 4px; flex-shrink: 0;
}

/* METLE button active state */
#fb-metle-toggle.has-filters { border-color: #a800ff; color: #a800ff; }
#fb-metle-toggle.has-filters .fb-filter-icon { stroke: #a800ff; }

/* Award name text fallback (no image) */
.flex-board__award-name {
  font-size: 12px; font-weight: 700;
  color: #374151; text-align: center;
  display: block; padding: 4px 2px;
}

/* METLE Top item */
.fb-metle-item--top { border-color: #1a1a2e; }
.fb-metle-item--top:hover,
.fb-metle-item--top.fb-metle-item--active { border-color: #1a1a2e; background: #eef2ff; }
.fb-metle-item--top .fb-metle-name { color: #1a1a2e; font-weight: 700; }
