/* ============================================================
   ADD ATHLETE MODULE — ATLETIKA · The Fantasy of Athletics
   Shared styles for the Maqueta mock and the front-end picker.
   Class prefix: aa-
   Baseline UX: bottom-sheet + slide animation + filterable table.
   Type scale: 16 / 14 / 12 px
   ============================================================ */

/* ---------- Bottom sheet overlay ---------- */
.aa-overlay {
  position: fixed; bottom: 0; left: 0; right: 0; top: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.aa-overlay--open { display: flex; }

.aa-sheet {
  background: #fff;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 600px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  animation: aaSlideUp 0.35s ease-out;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
}
@keyframes aaSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ---------- Handle ---------- */
.aa-handle {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 8px;
  flex-shrink: 0;
  position: relative;
}
.aa-handle__bar {
  width: 36px; height: 4px; border-radius: 2px;
  background: #cbd5e1; margin: 0 auto;
}
.aa-handle__close {
  width: 28px; height: 28px; border-radius: 50%;
  background: #f1f5f9; border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #64748b; font-size: 14px;
}
.aa-handle__close:hover { background: #e2e8f0; color: #1e293b; }

/* ---------- Selected athlete banner (compact) ---------- */
.aa-sub {
  display: none;
  align-items: center; gap: 8px;
  margin: 2px 16px 10px;
  padding: 7px 10px;
  background: rgba(212, 86, 42, 0.06);
  border: 1px solid rgba(212, 86, 42, 0.18);
  border-radius: 8px;
  flex-shrink: 0;
}
.aa-sub--visible { display: flex; }
.aa-sub__flag { width: 18px; height: 12px; border-radius: 2px; object-fit: cover; flex-shrink: 0; }
.aa-sub__info { flex: 1; min-width: 0; line-height: 1.3; }
.aa-sub__given { font-size: 14px; font-weight: 700; color: #1e293b; }
.aa-sub__name { font-size: 13px; font-weight: 500; color: #64748b; }
.aa-sub__event { font-size: 12px; color: #64748b; }
.aa-sub__price { font-size: 12px; font-weight: 700; color: #d4562a; white-space: nowrap; }
.aa-sub__icon { font-size: 12px; color: #d4562a; }

/* ---------- Budget badge ---------- */
.aa-budget {
  margin: 0 16px 10px;
  padding: 7px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px; font-weight: 500; color: #475569;
  flex-shrink: 0;
}
.aa-budget strong { font-weight: 700; color: #1e293b; }
.aa-budget--over { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.aa-budget--over strong { color: #b91c1c; }

/* ---------- Filters ---------- */
.aa-filters {
  padding: 0 16px 10px;
  flex-shrink: 0;
}
.aa-filters__row {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.aa-filters__row + .aa-filters__row { margin-top: 8px; }

.aa-search {
  flex: 1; min-width: 120px;
  padding: 7px 10px; border: 1px solid transparent;
  border-radius: 8px; font-size: 12px; outline: none;
  background: #f1f5f9;
}
.aa-search:focus { background: #fff; border-color: #d4562a; }

.aa-price {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 95px;
}
.aa-price__min,
.aa-price__max { font-size: 11px; color: #94a3b8; font-weight: 600; white-space: nowrap; }
.aa-price__range {
  flex: 1; height: 4px; accent-color: #d4562a; cursor: pointer; min-width: 0;
}
.aa-price__value { font-size: 12px; font-weight: 700; color: #1e293b; min-width: 30px; text-align: right; white-space: nowrap; }

/* Event selector trigger */
.aa-event {
  display: flex; align-items: center;
}
.aa-event__btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid #e2e8f0; background: #f1f5f9;
  border-radius: 8px; font-size: 12px; font-weight: 600; color: #1e293b;
  cursor: pointer; max-width: 180px;
}
.aa-event__btn:hover { border-color: #d4562a; }
.aa-event__emoji { font-size: 14px; flex-shrink: 0; }
.aa-event__label { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aa-event__arrow { font-size: 9px; color: #94a3b8; flex-shrink: 0; }

/* ---------- Table ---------- */
.aa-table-wrap {
  flex: 1; overflow-y: auto;
  padding: 0 16px 16px;
  -webkit-overflow-scrolling: touch;
}
.aa-table {
  width: 100%; border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}
.aa-table thead { position: sticky; top: 0; background: #fff; z-index: 1; }
.aa-table th {
  font-size: 11px; font-weight: 600; color: #64748b;
  padding: 8px 6px; text-align: left;
  border-bottom: 1px solid #e2e8f0;
}
.aa-table td {
  padding: 9px 6px; vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}
.aa-table td:last-child { text-align: right; }
.aa-table tr:last-child td { border-bottom: none; }
.aa-table tbody tr { cursor: pointer; }
.aa-table tbody tr:hover { background: #f8fafc; }

.aa-table__flag-cell { width: 24px; padding: 0 !important; }
.aa-table td:nth-child(2) { padding-left: 4px; }
.aa-table td:nth-child(3) { width: 85px; }
.aa-table td:nth-child(4) { width: 55px; padding-left: 1px; padding-right: 1px; }
.aa-table td:nth-child(5) { width: 55px; padding-left: 1px; padding-right: 1px; }
.aa-table td:nth-child(6) { width: 21px; text-align: center; }
.aa-table td:nth-child(7) { width: 55px; text-align: right; }
.aa-table td:nth-child(8),
.aa-table th:nth-child(8) { width: 28px; text-align: center; padding: 0; }

/* WA arrow column (independent action, no header) */
.aa-table__wa { text-align: center; }
.aa-wa {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 0;
  font-size: 13px;
  color: #94a3b8;
  text-decoration: none;
  cursor: pointer;
  border-radius: 6px;
  transition: color 0.12s;
}
.aa-wa:hover { color: #d4562a; }
.aa-table__tr--selected .aa-wa { pointer-events: auto; }

.aa-table__tr--selected { cursor: default; pointer-events: none; background: rgba(212, 86, 42, 0.06); }
.aa-table__tr--selected td { opacity: 0.7; }

.aa-table__flag { width: 16px; height: 11px; border-radius: 1px; object-fit: cover; display: block; }

.aa-table__name {
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.aa-table__name > div:last-child { min-width: 0; }
.aa-table__avatar {
  width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.aa-table__name-text { font-weight: 600; color: #1e293b; font-size: 12px; max-width: 100%; overflow-wrap: break-word; word-break: normal; }
.aa-name__family { font-size: 16px; font-weight: 700; color: #1e293b; }
.aa-name__given { font-size: 14px; font-weight: 500; color: #64748b; }
.aa-table__event-mobile { display: none; }

.aa-table__sb,
.aa-table__pb {
  font-size: 12px; font-variant-numeric: tabular-nums; font-weight: 400;
}
.aa-table__sb { color: #1e293b; }
.aa-table__pb { color: #475569; }
.aa-table__price { font-weight: 700; font-size: 14px; color: #1e293b; }

.aa-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: 14px; color: #94a3b8;
}

/* Record badges */
.evd-min19 { min-width: 21px; display: inline-block; }
.evd-badge-wrap { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.evd-badge { background: rgba(212, 86, 42, 0.1); color: #d4562a; padding: 2px 4px; border-radius: 4px; font-size: 10px; font-weight: 600; white-space: nowrap; }
.evd-badge-empty { color: transparent; }

/* ---------- Sortable columns ---------- */
.mq-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.mq-sortable:hover { color: #1e293b; }
.mq-sort-arrows { display: inline-flex; flex-direction: column; vertical-align: middle; margin-left: 3px; font-size: 7px; line-height: 1; }
.mq-sort-up, .mq-sort-down { color: #cbd5e1; }
.mq-sort-up.mq-active, .mq-sort-down.mq-active { color: #d4562a; }

/* ---------- Event selector list ---------- */
.aa-list {
  flex: 1; overflow-y: auto;
  padding: 4px 16px 16px;
  -webkit-overflow-scrolling: touch;
}
.aa-group { margin-bottom: 6px; }
.aa-group__title {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 4px 6px;
  font-size: 12px; font-weight: 700; color: #64748b;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.aa-group__emoji { font-size: 14px; }
.aa-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  margin-bottom: 6px;
  font-size: 14px; font-weight: 600; color: #1e293b;
  transition: border-color 0.12s, background 0.12s;
}
.aa-row:hover { border-color: #d4562a; background: #fff7ed; }
.aa-row--active { border-color: #d4562a; background: #fff7ed; color: #d4562a; }
.aa-row__emoji { font-size: 16px; flex-shrink: 0; }
.aa-row__check { margin-left: auto; color: #d4562a; font-size: 14px; }

/* Avatar color variants */
.aa-avatar--blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.aa-avatar--green { background: linear-gradient(135deg, #22c55e, #16a34a); }
.aa-avatar--purple { background: linear-gradient(135deg, #a855f7, #9333ea); }
.aa-avatar--red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.aa-avatar--yellow { background: linear-gradient(135deg, #eab308, #ca8a04); }
.aa-avatar--pink { background: linear-gradient(135deg, #ec4899, #db2777); }
.aa-avatar--orange { background: linear-gradient(135deg, #fb923c, #f97316); }
.aa-avatar--teal { background: linear-gradient(135deg, #14b8a6, #0d9488); }

/* ---------- Responsive ---------- */
@media (min-width: 768px) {
  .aa-handle__bar { display: none; }
  .aa-handle { justify-content: flex-end; }
  .aa-handle__close { display: inline-flex; }
  .aa-overlay--events .aa-sheet { max-width: 480px; }
}

@media (max-width: 767px) {
  .aa-handle__close { display: none; }
}

/* 600px: drop the Event column, show event-mobile in the name cell */
@media (max-width: 599px) {
  .aa-table col:nth-child(3) { display: none; }
  .aa-table thead th:nth-child(2),
  .aa-table tbody td:nth-child(3) { display: none; }
  .aa-table__event-mobile { display: block; font-size: 10px; color: #64748b; }
  .aa-table td { padding: 6px 3px; }
  .aa-table__price { font-size: 12px; }
  .aa-table__sb,
  .aa-table__pb { font-size: 12px; }
  .aa-name__family { font-size: 14px; }
  .aa-name__given { font-size: 13px; }
  .aa-table__avatar { width: 22px; height: 22px; font-size: 8px; }
}

@media (min-width: 600px) {
  .aa-table__event-mobile { display: none; }
}

/* 450px: tighter padding and type */
@media (max-width: 449px) {
  .aa-handle { padding: 10px 12px 6px; }
  .aa-sub { margin: 2px 12px 8px; padding: 6px 8px; }
  .aa-budget { margin: 0 12px 8px; padding: 6px 8px; }
  .aa-filters { padding: 0 12px 8px; }
  .aa-table-wrap { padding: 0 12px 12px; }
  .aa-table th { padding: 6px 4px; font-size: 10px; }
  .aa-table td { padding: 6px 4px; }
  .aa-table__flag { width: 14px; height: 10px; }
  .aa-table__avatar { width: 20px; height: 20px; font-size: 7px; }
  .aa-name__family { font-size: 13px; }
  .aa-name__given { font-size: 12px; }
  .aa-table__event-mobile { font-size: 9px; }
  .aa-table td:nth-child(8),
  .aa-table th:nth-child(8) { width: 24px; }
  .aa-wa { padding: 8px 0; font-size: 12px; }
}

/* 420px: compact further */
@media (max-width: 419px) {
  .aa-handle { padding: 10px 10px 5px; }
  .aa-search { padding: 6px 8px; }
  .aa-price { gap: 5px; }
  .aa-price__range { min-width: 0; }
  .aa-event__btn { padding: 6px 10px; max-width: 140px; }
  .aa-sheet { border-radius: 12px 12px 0 0; }
}

/* 385px: minimum supported width — must also work at 350px */
@media (max-width: 384px) {
  .aa-sub { margin: 2px 10px 6px; padding: 5px 8px; }
  .aa-budget { margin: 0 10px 6px; padding: 5px 8px; }
  .aa-filters { padding: 0 10px 6px; }
  .aa-filters__row { gap: 6px; }
  .aa-search { min-width: 0; }
  .aa-price { min-width: 0; }
  .aa-event__btn { max-width: 130px; padding: 6px 8px; }
  .aa-table-wrap { padding: 0 10px 10px; }
  .aa-table th { padding: 6px 3px; }
  .aa-table td { padding: 6px 3px; }
  .aa-table__name { gap: 6px; }
  .aa-table__avatar { width: 18px; height: 18px; font-size: 6px; }
  .aa-table__price { font-size: 11px; }
  .aa-table__sb,
  .aa-table__pb { font-size: 11px; }
  .aa-name__family { font-size: 12px; }
  .aa-name__given { font-size: 11px; }
  .aa-table td:nth-child(8),
  .aa-table th:nth-child(8) { width: 22px; }
  .aa-wa { padding: 6px 0; font-size: 11px; }
}
