/* ==========================================================
   SizePicker – two-step "fit → size" chooser
   Desktop: popover anchored to the row. Mobile (<768px): bottom sheet.
   ========================================================== */
:root { --sp-accent: #f60; --sp-accent-soft: #fff1e6; --sp-line: #ddd; --sp-text: #222; --sp-muted: #777; }

/* The original readonly input stays in the form (name, value, validation)
   but is visually replaced by .sp-btn. Not display:none so .focus() still works. */
.sp-native { position: absolute !important; opacity: 0; width: 1px !important; height: 1px !important;
  padding: 0 !important; border: 0 !important; pointer-events: none; }

/* Trigger shown in each table row */
/* .sp-btn also carries Bootstrap's .form-control, so height, padding, border,
   radius and font size match the Player Name / Number inputs in the same row. */
.sp-btn.form-control { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  cursor: pointer; background-color: #fff; color: var(--sp-text); line-height: 1.2; font-family: inherit;
  padding-top: 0; padding-bottom: 0; }
.sp-btn:hover { border-color: #999; }
.sp-btn:focus-visible, .sp-btn.sp-active { outline: none; border-color: var(--sp-accent); box-shadow: 0 0 0 3px rgba(255,102,0,.2); }
.sp-btn-fit { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9em; color: #555; }
.sp-btn-size { flex: none; min-width: 36px; padding: 2px 8px; font-size: .95em; border-radius: 4px; background: var(--sp-accent);
  color: #fff; font-weight: bold; text-align: center; }
.sp-btn-placeholder { flex: 1; color: #999; }
.sp-btn-caret { flex: none; width: 0; height: 0; border: 5px solid transparent; border-top-color: #888; margin-top: 5px; }
.sp-native.error + .sp-btn { border-color: #d9534f; box-shadow: 0 0 0 3px rgba(217,83,79,.15); }

/* Panel */
.sp-panel { position: absolute; z-index: 1050; width: 380px; max-width: calc(100vw - 16px); background: #fff;
  border: 1px solid var(--sp-line); border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.18);
  padding: 0 14px 14px; display: none; color: var(--sp-text); }
.sp-panel.sp-open { display: block; }
.sp-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 0 4px; }
.sp-title { font-weight: bold; font-size: 1.05em; }
.sp-head-actions { display: flex; align-items: center; gap: 6px; }
.sp-done { border: 0; background: none; color: var(--sp-accent); font-weight: bold; padding: 8px; cursor: pointer; font: inherit; font-weight: bold; }
.sp-close { border: 0; background: none; font-size: 26px; line-height: 1; color: #888; padding: 4px 6px; cursor: pointer; }
.sp-label { font-size: .78em; text-transform: uppercase; letter-spacing: .06em; color: var(--sp-muted); margin: 10px 0 6px; }

.sp-fits { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.sp-fit { display: flex; flex-direction: column; justify-content: center; min-height: 48px; padding: 6px 8px;
  border: 1px solid var(--sp-line); border-radius: 6px; background: #fff; cursor: pointer; text-align: left;
  font: inherit; color: var(--sp-text); line-height: 1.15; }
.sp-fit b { font-size: .95em; }
.sp-fit small { font-size: .8em; color: var(--sp-accent); font-weight: bold; }
.sp-fit[aria-checked="true"] { border-color: var(--sp-accent); background: var(--sp-accent-soft); box-shadow: inset 0 0 0 1px var(--sp-accent); }

.sp-sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px; }
.sp-size { min-height: 44px; border: 1px solid var(--sp-line); border-radius: 6px; background: #fff; cursor: pointer;
  font: inherit; font-weight: bold; color: var(--sp-text); }
.sp-size:hover, .sp-fit:hover { border-color: #aaa; }
.sp-size[aria-pressed="true"] { background: var(--sp-accent); border-color: var(--sp-accent); color: #fff; }
.sp-fit:focus-visible, .sp-size:focus-visible, .sp-done:focus-visible, .sp-close:focus-visible { outline: 2px solid var(--sp-accent); outline-offset: 2px; }

.sp-foot { margin-top: 10px; font-size: .8em; color: var(--sp-muted); }
.sp-foot label { cursor: pointer; font-weight: normal; }

/* Mobile bottom sheet */
.sp-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1049; opacity: 0; transition: opacity .2s; display: none; }
.sp-backdrop.sp-open { display: block; opacity: 1; }
.sp-panel.sp-sheet { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-width: none;
  max-height: 85vh; overflow-y: auto; border-radius: 16px 16px 0 0; border: 0;
  padding-bottom: calc(16px + env(safe-area-inset-bottom)); animation: sp-up .22s ease-out; }
.sp-panel.sp-sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: #ccc; margin: 8px auto 0; }
.sp-panel.sp-sheet .sp-fits { grid-template-columns: repeat(3, 1fr); }
.sp-panel.sp-sheet .sp-sizes { grid-template-columns: repeat(5, 1fr); }
@keyframes sp-up { from { transform: translateY(100%); } to { transform: none; } }
html.sp-lock, html.sp-lock body { overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .sp-panel.sp-sheet { animation: none; } }
