/* Custom Lineup Styles - Dark Theme */

/* ========================================
   Player Swap Container (inside pitch-player)
   Position to the right of the player marker
   ======================================== */
.player-swap-container {
  position: absolute;
  top: 50%;
  right: -16px;
  transform: translateY(-50%);
  z-index: 15;
}

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

/* ========================================
   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;
}

/* Lineup-specific toggle styles */
.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;
}

/* Predicted - Orange/Amber */
.filter-toggle__btn--predicted.filter-toggle__btn--active {
  background: rgba(251, 191, 36, 0.15) !important;
  color: #fbbf24 !important;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.3);
}

/* Custom - Teal/Cyan */
.filter-toggle__btn--custom.filter-toggle__btn--active {
  background: rgba(20, 216, 193, 0.15) !important;
  color: #14d8c1 !important;
  box-shadow: 0 0 0 1px rgba(20, 216, 193, 0.3);
}

/* Confirmed - Green */
.filter-toggle__btn--confirmed.filter-toggle__btn--active {
  background: rgba(34, 197, 94, 0.15) !important;
  color: #22c55e !important;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.3);
}

/* Reset button - match dark theme */
.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);
}

/* ========================================
   Player Swap Menu (Three Dots)
   ======================================== */
.player-swap-menu {
  width: 18px;
  height: 18px;
  background: rgba(0, 0, 0, 0.7);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  opacity: 0;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* When not hidden (custom mode active), keep hidden by default - only show on hover */
.player-swap-menu:not(.hidden) {
  opacity: 0;
}

.player-swap-menu:hover {
  background: rgba(0, 0, 0, 0.9);
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Show on hover over the player marker */
.pitch-player:hover .player-swap-menu:not(.hidden) {
  opacity: 1;
}

/* Always show when dropdown is open */
.player-swap-menu.active {
  opacity: 1;
  background: rgba(26, 125, 31, 0.3);
  border-color: #1a7d1f;
  color: #1a7d1f;
}

/* ========================================
   Player Swap Dropdown - Dark Theme
   ======================================== */
.player-swap-dropdown {
  position: fixed;
  min-width: 180px;
  max-width: 240px;
  max-height: 300px;
  overflow-y: auto;
  background: rgb(43, 43, 43);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 9999;
  padding: 4px;
  /* Position will be set by JS */
}

/* Prevent clicks from going through to elements below */
.player-swap-dropdown * {
  pointer-events: auto;
}

/* Search input - dark theme */
.dropdown-search {
  padding: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: sticky;
  top: 0;
  background: rgb(43, 43, 43);
  z-index: 1;
}

.dropdown-search input {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  font-size: 10px;
  background: rgba(0, 0, 0, 0.3);
  color: rgba(255, 255, 255, 0.9);
}

.dropdown-search input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.dropdown-search input:focus {
  outline: none;
  border-color: #1a7d1f;
}

/* Position groups */
.position-group {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.position-group:last-child {
  border-bottom: none;
}

.position-group-title {
  padding: 4px 8px;
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #1a7d1f;
  background: rgba(26, 125, 31, 0.1);
  position: sticky;
  top: 0;
}

/* Adjust sticky when search present */
.dropdown-search + .player-list .position-group-title {
  top: 0;
}

/* Player list items */
.player-list-item {
  padding: 5px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.75);
  transition: background 0.1s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.player-list-item:last-child {
  border-bottom: none;
}

.player-list-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.player-list-item .player-name {
  flex: 1;
  font-weight: 500;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 255, 255, 0.9);
}

.player-list-item .player-position {
  font-size: 8px;
  color: rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

/* Best Match section - highlighted at top */
.position-group--best-match {
  border-bottom: 1px solid rgba(20, 216, 193, 0.2);
  margin-bottom: 4px;
}

.position-group-title--best-match {
  color: #14d8c1 !important;
  background: rgba(20, 216, 193, 0.12) !important;
}

.player-list-item--best-match {
  background: rgba(20, 216, 193, 0.05);
}

.player-list-item--best-match:hover {
  background: rgba(20, 216, 193, 0.12) !important;
}

.player-list-item--best-match .player-name {
  color: rgba(255, 255, 255, 0.95);
}

/* Injured/Unavailable section */
.position-group--injured {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: 4px;
}

.position-group-title--injured {
  color: rgba(239, 100, 100, 0.7) !important;
  background: rgba(239, 68, 68, 0.08) !important;
}

/* Sidelined/injured players - muted red */
.player-list-item.sidelined {
  opacity: 0.5;
}

.player-list-item.sidelined .player-name {
  color: rgba(239, 150, 150, 0.8);
}

.player-list-item.sidelined .player-position {
  color: rgba(239, 150, 150, 0.5);
}

.player-list-item.sidelined:hover {
  background: rgba(239, 68, 68, 0.08);
  opacity: 0.7;
}

.injury-icon {
  font-size: 9px;
  flex-shrink: 0;
  opacity: 0.6;
}

/* Loading/empty states */
.player-list-loading,
.player-list-error,
.player-list-empty {
  padding: 12px 8px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
}

.player-list-error {
  color: #ef4444;
}

/* Selecting state */
.player-list-item.selecting {
  opacity: 0.5;
  pointer-events: none;
}

/* ========================================
   Formation Selector - Dark Theme
   ======================================== */
.formation-selector {
  display: inline-flex;
  align-items: center;
}

.formation-selector select {
  padding: 2px 18px 2px 6px;
  border-radius: 4px;
  border: none;
  background: rgba(0, 0, 0, 0.3);
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
}

.formation-selector select:hover:not(:disabled) {
  background-color: rgba(0, 0, 0, 0.4);
  color: rgba(255, 255, 255, 0.8);
}

.formation-selector select:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.formation-selector select:focus {
  outline: none;
}

.formation-selector select option {
  background: #121612;
  color: rgba(255, 255, 255, 0.75);
}

.formation-selector select optgroup {
  background: #121612;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 600;
}

/* Formation selector locked state (player swap detected) */
.formation-selector--locked {
  position: relative;
}

.formation-selector--locked select {
  opacity: 0.3;
  cursor: not-allowed;
}

.formation-selector--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-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 ease;
  z-index: 20;
}

.formation-selector--locked:hover::after {
  opacity: 1;
}

/* ========================================
   Actions Bar (Custom lineup mode)
   ======================================== */
.custom-lineup-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: rgba(20, 216, 193, 0.08);
  border: 1px solid rgba(20, 216, 193, 0.2);
  border-radius: 6px;
  margin-bottom: 8px;
}

.custom-lineup-actions__spacer {
  flex: 1;
}

.swap-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.5);
}

.swap-hint svg {
  width: 12px;
  height: 12px;
  opacity: 0.7;
}

.changes-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: #fbbf24;
}

.changes-indicator svg {
  width: 12px;
  height: 12px;
}

.btn-reset {
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-reset:hover {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-apply {
  padding: 4px 12px;
  border-radius: 4px;
  border: none;
  background: #14d8c1;
  color: #000;
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-apply:hover:not(:disabled) {
  background: #0fc9b3;
}

.btn-apply:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: rgba(20, 216, 193, 0.3);
  color: rgba(255, 255, 255, 0.5);
}

/* ========================================
   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
   ======================================== */
.pitch-player--swapped {
  animation: swapHighlight 2s ease-out;
}

@keyframes swapHighlight {
  0% {
    box-shadow: 0 0 0 3px #1a7d1f;
  }
  100% {
    box-shadow: none;
  }
}

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

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