/* lineup.css */

.builder-container {
  --pitch-width: clamp(280px, 72vw, 760px);
  --slot-size: clamp(42px, 7vw, 100px);
  --pitch-line-width: clamp(2px, 0.45vw, 5px);

  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: flex-start;
  display: none;
  position: relative;

  background-color: var(--background_white);
}



.lineups-error {
  display: flex;
  justify-content: center;
  align-items: center;
  /* background-color: #007acc; */
  margin: 0 auto;
  width: fit-content;
}

.pitch-container {
  flex: 2;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  padding-top: 20px;
  /* margin-top: -200px; */
  perspective: 800px;
  /* background-color: #ffb81c; */
}

.team_name____container {
  position: absolute;
  top: 0px;
  width: 100%;
  margin-bottom: 10px;
  text-align: center;
}

.team_lineup_logo_name {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.team_lineup_logo_name img {
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.team__substitutes___container {
  position: absolute;
  top: 100px;
  width: 100%;
  max-width: var(--pitch-width);
  margin-top: 10px;
  text-align: center;
  background-color: var(--bg_color);
  color: var(--text_white);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
}

.substitutes_header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 2px solid var(--text_white);
  background-color: var(--bg_color);
}

.team__substitutes___container p {
  margin: 0;
  padding: 5px;
}

.team_lineup_logo_name p {
  font-size: large;
  font-weight: bold;
  margin: 0;
}

.substitutes_list {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: small;
  font-weight: bold;
  width: fit-content;
  margin: 0 auto;
  padding: 10px 20px;
  /* display: none; */
}

.pitch {
  background-color: var(--bg_color);

  background-image: repeating-linear-gradient(0deg,
      transparent,
      transparent 50px,
      rgba(0, 0, 0, 0.05) 50px,
      rgba(0, 0, 0, 0.05) 100px);

  width: min(100%, var(--pitch-width));
  aspect-ratio: 9/12;

  border: 3px solid #fff;
  border-radius: 8px;

  position: relative;
  /* OVERFLOW REMOVED: overflow: hidden flattens 3D children! */

  transform: rotateX(55deg);
  transform-origin: center bottom;
  transform-style: preserve-3d;
  /* CRITICAL: Allows children to pop up in 3D */
}

/* Pitch Markings */
.pitch-line,
.pitch-circle,
.pitch-box {
  position: absolute;
  border: var(--pitch-line-width) solid rgb(255, 255, 255);
}

.pitch-center-line {
  width: 100%;
  top: 50%;
  border-top: var(--pitch-line-width) solid rgb(255, 255, 255);
}

.pitch-center-circle {
  width: clamp(90px, 24vw, 250px);
  height: clamp(90px, 24vw, 250px);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
}

.pitch-box-top {
  width: 60%;
  height: 18%;
  top: 0;
  left: 20%;
  border-top: none;
}

.pitch-box-bottom {
  width: 60%;
  height: 18%;
  bottom: 0;
  left: 20%;
  border-bottom: none;
}

.pitch::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom,
      rgba(0, 0, 0, 0.3),
      transparent 40%,
      rgba(0, 0, 0, 0.5));
  pointer-events: none;
  transform: translateZ(-1px);
  /* Keeps the shadow gradient firmly on the floor */
}

/* --- PLAYER SLOTS --- */
.player-slot {
  position: absolute;
  width: var(--slot-size);
  height: var(--slot-size);
  background-color: rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  border: max(1px, calc(var(--slot-size) * 0.02)) dashed rgba(255, 255, 255, 0.5);

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;
  transition: all 0.2s ease;

  /* CRITICAL FIX: translateZ(45px) lifts the slot off the pitch so the bottom half doesn't clip through the floor when rotated upright */
  transform: translate(-50%, -50%) translateZ(calc(var(--slot-size) * 0.9)) rotateX(-55deg);
  transform-style: preserve-3d;

  z-index: 10;

  background-color: #007acc;
}

.player-slot:hover,
.player-slot.active-selection {
  background-color: rgba(255, 184, 28, 0.4);
  /* Bafana Yellow tint */
  border-color: #ffb81c;
  transform: translate(-50%, -50%) translateZ(calc(var(--slot-size) * 0.9)) rotateX(-55deg) scale(1.08);
}

.player-slot.filled {
  border: none;
  background-color: transparent;
  overflow: visible;
  /* To show name below */
}

.slot-label {
  font-weight: bold;
  color: #fff;
  font-size: clamp(0.7rem, 2.1vw, 1.5rem);
}

/* Filled Slot Styling */
.slot-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: top;
}

.slot-name {
  position: absolute;
  bottom: -0px;
  background-color: #15346d;
  color: #fff;
  padding: 0;
  padding-right: clamp(4px, 1vw, 10px);
  border-radius: 5px;
  box-shadow: 5px 10px 5px rgba(0, 0, 0, 0.329);
  white-space: nowrap;
  text-align: center;
  font-size: clamp(0.55rem, 1.5vw, 1.125rem);
  font-weight: lighter;
  text-transform: uppercase;
  margin: 0;
  /* overflow: hidden; */
}

.slot-name p {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  padding: 0;
}

.slot-name span {
  border-right: 3px solid #fff;
  font-weight: bold;
  padding: 0 clamp(4px, 1vw, 10px);
  background-color: #43c0e6;
  /* width: 50px; */
}

/* --- SIDEBAR --- */
/* .sidebar {
  flex: 1;
  min-width: 300px;
  background: #399fffa6;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  height: 800px;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid #eee;
  background: var(--background_gray_trans);
  border-radius: 12px 12px 0 0;
}

.sidebar-header h3 {
  margin: 0;
  color: #fff;
  font-size: 1.5rem;
} */

.team_select_container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px 0;
}

.team_select_container select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  font-size: 1rem;
  color: #333;
  cursor: pointer;
  outline: none;
  border: none;
}

.team_select_container label {
  margin-right: 10px;
  color: #fff;
  font-size: 1.2rem;
}


.filter-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  font-size: 0.8rem;
  padding: 4px 20px;
  background: var(--background_black_trans);
  border-radius: 15px;
  cursor: pointer;
  color: white;
  transition: 0.2s;
}

.tag:hover,
.tag.active {
  background: #007749;
  color: white;
}

.players-list {
  flex-grow: 1;
  overflow-y: auto;
  padding: 10px;
}

.pick_sides {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 20px 0;
}

.pick_sides button {
  padding: 10px 20px;
  border: none;
  outline: none;
  border-radius: 20px;
  font-size: 0.7rem;
  box-shadow: var(--shadow);
  background-color: var(--background_white);

  color: var(--text_color);
  border: var(--border);
  cursor: pointer;
  transition: 0.5s ease-in-out;
}

.pick_sides button:hover {
  background-color: var(--surface_alt);
}

.team_globa_name {
  color: #007acc;
}

@media (max-width: 768px) {
  .builder-container {
    --pitch-width: 430px;
    --slot-size: clamp(38px, 12vw, 64px);
    --pitch-line-width: 2px;

    flex-direction: column;
    padding: 12px;
    gap: 14px;
  }

  .pitch-container {
    padding-top: 12px;
  }

  .pitch {
    transform: rotateX(48deg);
  }

  .player-slot {
    transform: translate(-50%, -50%) translateZ(calc(var(--slot-size) * 0.75)) rotateX(-48deg);
  }

  .player-slot:hover,
  .player-slot.active-selection {
    transform: translate(-50%, -50%) translateZ(calc(var(--slot-size) * 0.75)) rotateX(-48deg) scale(1.06);
  }

  .pitch-center-circle {
    width: clamp(76px, 28vw, 120px);
    height: clamp(76px, 28vw, 120px);
  }

  .team_lineup_logo_name img {
    width: 36px;
    height: 36px;
  }

  .team_lineup_logo_name p {
    font-size: 0.9rem;
  }

  .team__substitutes___container {
    top: -50px;
    border-radius: 8px;
  }

  .substitutes_header {
    padding: 8px 10px;
  }

  .substitutes_list {
    gap: 8px;
    padding: 8px 10px;
    font-size: 0.6rem;
  }

  .sidebar {
    height: 400px;
    width: 100%;
  }
}

@media (max-width: 420px) {
  .builder-container {
    --slot-size: clamp(34px, 11vw, 48px);
  }

  .pitch {
    width: min(100%, 340px);
  }

  .slot-name {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}