/* Custom Lineup Styles — V3 Dark Theme
   Matches pitch_features_mockup.html design system */

/* ========================================
   Player Swap Container
   Positioned inside the .player element
   ======================================== */
.player-swap-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
}

/* Ensure pitch-player is positioned for absolute children (old layout) */
.pitch-player {
  position: relative;
}

/* ========================================
   3-Dot Menu Trigger (matches mockup mk-pl__menu)
   16px circle, positioned top-right of avatar
   ======================================== */
.v3-analysis .player-swap-container .player__menu-trigger {
  position: absolute;
  top: -3px;
  right: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 5;
  padding: 0;
  pointer-events: auto;
}

.v3-analysis .player-swap-container .player__menu-trigger .player__menu-dots {
  display: flex;
  gap: 1.5px;
}

.v3-analysis .player-swap-container .player__menu-trigger .player__menu-dots span {
  width: 2.5px;
  height: 2.5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
}

/* Show on hover */
@media(hover:hover) {
  .v3-analysis .player:hover .player-swap-container .player__menu-trigger {
    opacity: 1;
  }
}

/* Hover dots turn green */
.v3-analysis .player-swap-container .player__menu-trigger:hover .player__menu-dots span {
  background: var(--glow);
}

/* Active state (dropdown open) */
.v3-analysis .player-swap-container .player__menu-trigger.active,
.v3-analysis .player-swap-container .player__menu-trigger.is-active {
  opacity: 1;
  background: rgba(0, 255, 136, 0.1);
  border-color: rgba(0, 255, 136, 0.2);
}
.v3-analysis .player-swap-container .player__menu-trigger.active .player__menu-dots span,
.v3-analysis .player-swap-container .player__menu-trigger.is-active .player__menu-dots span {
  background: var(--glow);
}

/* ========================================
   Old-style 3-dot menu (backward compat)
   ======================================== */
.player-swap-menu {
  width: 16px;
  height: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  opacity: 0;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.5);
}

.player-swap-menu:not(.hidden) {
  opacity: 0;
}

.pitch-player:hover .player-swap-menu:not(.hidden),
.player:hover .player-swap-menu:not(.hidden) {
  opacity: 1;
}

.player-swap-menu.active {
  opacity: 1;
  background: rgba(0, 255, 136, 0.1);
  border-color: rgba(0, 255, 136, 0.2);
  color: var(--glow);
}

/* ========================================
   Player Swap Modal — matches mk-modal design
   from pitch_features_mockup.html
   ======================================== */
.player-swap-dropdown {
  position: fixed;
  width: 380px;
  max-height: 460px;
  overflow: hidden;
  background: rgb(29 29 33 / 98%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}
.player-swap-dropdown * { pointer-events: auto; }

/* Modal header: "Swap Player" + close button */
.swap-modal__hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}
.swap-modal__hdr span {
  font-family: 'Sora', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
}
.swap-modal__close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.3);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}
.swap-modal__close:hover { color: rgba(255, 255, 255, 0.55); }

/* "Replacing: Player Name (POS)" */
.swap-modal__replacing {
  font-family: 'Sora', sans-serif;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.45);
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
}
.swap-modal__replacing strong {
  color: rgba(0, 255, 136, 0.65);
  font-weight: 700;
}

/* Search input */
.swap-modal__search {
  padding: 8px 12px;
  flex-shrink: 0;
}
.swap-modal__search input {
  width: 100%;
  font-family: 'Sora', sans-serif;
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55) !important;
  background: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid rgba(255, 255, 255, 0.07) !important;
  border-radius: 6px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
}
.swap-modal__search input:focus { border-color: rgba(0, 255, 136, 0.2) !important; }
.swap-modal__search input::placeholder { color: rgba(255, 255, 255, 0.3); }

/* Scrollable player list */
.swap-modal__list {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 8px;
}

/* Group headers */
.swap-sq__hdr {
  font-family: 'Sora', sans-serif;
  font-size: 8px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 14px 4px;
}
.swap-sq__hdr--best { color: rgba(0, 255, 136, 0.4); }
.swap-sq__hdr--side { color: rgba(239, 68, 68, 0.4); }

/* Player rows */
.swap-sq__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.1s;
  border-radius: 4px;
  margin: 0 4px;
}
.swap-sq__row:hover { background: rgba(255, 255, 255, 0.04); }

/* Player avatar circle */
.swap-sq__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Sora', sans-serif;
  font-size: 9px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
  overflow: hidden;
}
.swap-sq__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Player info (name + position) */
.swap-sq__info { flex: 1; min-width: 0; }
.swap-sq__name {
  font-family: 'Sora', sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.swap-sq__pos {
  font-family: 'Sora', sans-serif;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.3);
}
.swap-sq__injury {
  font-size: 8px;
  color: rgba(239, 68, 68, 0.55);
  margin-left: 6px;
  font-weight: 500;
}

/* 1+ / 2+ rate stat boxes */
.swap-sq__rates {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}
.swap-sq__stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 32px;
}
.swap-sq__stat-label {
  font-family: 'Sora', sans-serif;
  font-size: 7px;
  font-weight: 600;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.3px;
  line-height: 1;
}
.swap-sq__stat-val {
  font-family: 'Sora', sans-serif;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.3;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* pb-* pitch badge colors for swap dropdown (unscoped — dropdown is moved to body) */
.swap-sq__stat-val.pb-1{background:#1c1f1e;color:#3d6b55}
.swap-sq__stat-val.pb-2{background:#1d2622;color:#4a8566}
.swap-sq__stat-val.pb-3{background:#1e2d27;color:#57a077}
.swap-sq__stat-val.pb-4{background:#1f3a2e;color:#64ba88}
.swap-sq__stat-val.pb-5{background:#1f4733;color:#72d49a}
.swap-sq__stat-val.pb-6{background:#1c5637;color:#80ebaa}
.swap-sq__stat-val.pb-7{background:#18663b;color:#8dfcb8}
.swap-sq__stat-val.pb-8{background:#147a40;color:#a0ffc8}
.swap-sq__stat-val.pb-9{background:#0f9145;color:#fff}
.swap-sq__stat-val.pb-10{background:#0aaa4c;color:#fff;text-shadow:0 0 8px rgba(0,255,136,0.5)}

/* Sidelined rows — red tint on name, still clickable */
.swap-sq__row--injured .swap-sq__name { color: rgba(239, 68, 68, 0.45); }
.swap-sq__row--injured .swap-sq__pos { color: rgba(239, 68, 68, 0.3); }

/* Loading/empty/error states */
.player-list-loading,
.player-list-error,
.swap-modal__empty {
  padding: 20px 14px;
  text-align: center;
  color: rgba(255, 255, 255, 0.3);
  font-family: 'Sora', sans-serif;
  font-size: 10px;
}
.player-list-error { color: rgba(239, 68, 68, 0.6); }

/* Selecting state */
.swap-sq__row.selecting {
  opacity: 0.5;
  pointer-events: none;
}

/* ========================================
   Lineup Type Toggle
   ======================================== */
.lineup-toggle-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lineup-toggle-label {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.filter-toggle--lineup {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  padding: 2px;
  gap: 1px;
}

.filter-toggle--lineup .filter-toggle__btn {
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.filter-toggle--lineup .filter-toggle__btn:hover:not(:disabled) {
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.05);
}

.filter-toggle--lineup .filter-toggle__btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.filter-toggle__btn--predicted.filter-toggle__btn--active {
  background: rgba(251, 191, 36, 0.25) !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.35);
}

.filter-toggle__btn--custom.filter-toggle__btn--active {
  background: rgba(var(--glow-rgb), 0.25) !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.35);
}

.filter-toggle__btn--confirmed.filter-toggle__btn--active {
  background: rgba(var(--glow-rgb), 0.25) !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.35);
}

.custom-lineup-reset-btn {
  padding: 4px 8px;
  border-radius: 6px;
  border: none;
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.custom-lineup-reset-btn:hover {
  background: rgba(239, 68, 68, 0.3);
}

/* ========================================
   Formation Dropdown — pf-fdd style
   Matches color_schemes.html design
   ======================================== */
.formation-dd {
  position: relative;
  flex-shrink: 0;
}
.formation-dd__trigger {
  font-family: 'Sora', sans-serif;
  font-size: 9px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.35);
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
}
.formation-dd__trigger:hover {
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.5);
}
.formation-dd__chevron {
  font-size: 8px;
  transition: transform 0.2s;
}
.formation-dd.open .formation-dd__chevron {
  transform: rotate(180deg);
}
.formation-dd.open .formation-dd__trigger {
  border-color: rgba(0, 255, 136, 0.3);
  color: rgba(0, 255, 136, 0.6);
}
.formation-dd__menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 120px;
  background: rgba(18, 18, 22, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  z-index: 50;
  backdrop-filter: blur(16px);
  overflow: hidden;
  padding: 4px;
}
.formation-dd.open .formation-dd__menu {
  display: block;
}
.formation-dd__opt {
  font-family: 'Sora', sans-serif;
  font-size: 9px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.4);
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
}
.formation-dd__opt:hover {
  background: rgba(255, 255, 255, 0.04);
}
.formation-dd__opt--sel {
  color: rgba(0, 255, 136, 0.6);
}

/* Locked state (player swap detected — must reset to change formation) */
.formation-dd--locked {
  position: relative;
}
.formation-dd--locked .formation-dd__trigger {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.formation-dd--locked::after {
  content: "Reset lineup to change formation";
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.92);
  color: rgba(255, 255, 255, 0.85);
  font-family: 'Sora', sans-serif;
  font-size: 9px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 20;
}
.formation-dd--locked:hover::after { opacity: 1; }

/* Static (non-custom) — just shows formation, no chevron/dropdown */
.formation-dd--static .formation-dd__trigger {
  cursor: default;
  border-color: transparent;
}
.formation-dd--static .formation-dd__trigger:hover {
  border-color: transparent;
  color: rgba(255, 255, 255, 0.35);
}

/* ========================================
   Pitch Footer — Apply/Reset Actions
   Slides in when changes detected
   ======================================== */
.pitch-footer__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.pitch-footer__actions.visible {
  max-width: 300px;
  opacity: 1;
}

.pitch-footer__btn-ghost {
  font-family: 'Sora', sans-serif;
  font-size: 8px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.3);
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 5px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.pitch-footer__btn-ghost:hover {
  color: rgba(255, 255, 255, 0.55);
  border-color: rgba(255, 255, 255, 0.12);
}

.pitch-footer__btn-apply {
  font-family: 'Sora', sans-serif;
  font-size: 8px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.8);
  background: rgba(0, 255, 136, 0.4);
  border: none;
  border-radius: 5px;
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.pitch-footer__btn-apply:hover {
  background: rgba(0, 255, 136, 0.65);
}

/* ========================================
   Loading Overlay
   ======================================== */
.custom-lineup-loading {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: inherit;
}

.loading-text {
  color: rgba(255, 255, 255, 0.9);
  font-size: 12px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.7);
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ========================================
   Player Visual States
   ======================================== */
.player--swapped,
.pitch-player--swapped {
  animation: swapHighlight 2s ease-out;
}

@keyframes swapHighlight {
  0% { box-shadow: 0 0 0 3px var(--glow); }
  100% { box-shadow: none; }
}

.player--cleared .player__name,
.pitch-player--cleared .pitch-player__name {
  color: rgba(255, 255, 255, 0.4);
  font-style: italic;
}

/* ========================================
   Utility Classes
   ======================================== */
.hidden {
  display: none !important;
}
