/* =========================================================
   VisionTactica — Estilos custom (complementa Tailwind CDN)
   Tema: oscuro + cancha de fútbol
   ========================================================= */

:root {
  --pitch-dark: #0a1f14;
  --pitch-stripe-a: #14532d;
  --pitch-stripe-b: #166534;
  --pitch-line: rgba(200, 230, 201, 0.55);
  --slot-empty: rgba(0, 0, 0, 0.35);
  --slot-hover: rgba(74, 222, 128, 0.35);
  --gold: #eab308;
  --accent: #4ade80;
}

/* ---------- Nav ---------- */
.nav-link {
  padding: 0.4rem 0.75rem;
  border-radius: 0.5rem;
  color: #9ca3af;
  transition: color 0.15s, background 0.15s;
  font-weight: 500;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
  color: var(--accent);
  background: rgba(74, 222, 128, 0.12);
}

/* ---------- Buttons ---------- */
.btn-primary {
  background: linear-gradient(135deg, #16a34a, #4ade80);
  color: #052e16;
  font-weight: 700;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #e5e7eb;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 0.9rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-gold {
  background: linear-gradient(135deg, #a16207, #eab308);
  color: #1c1400;
  font-weight: 700;
  font-size: 0.875rem;
  padding: 0.5rem 0.9rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: filter 0.15s, transform 0.15s;
}

.btn-gold:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(160deg, rgba(15, 46, 28, 0.85), rgba(10, 31, 20, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

/* ---------- Pitch ---------- */
.pitch-wrapper {
  background: #0c2818;
}

.pitch {
  position: relative;
  width: 100%;
  /* Aspect ratio cancha ~ 2:3 vertical (vista táctica clásica) */
  aspect-ratio: 2 / 3;
  max-height: min(78vh, 720px);
  margin: 0 auto;
  background: repeating-linear-gradient(
    0deg,
    var(--pitch-stripe-a) 0,
    var(--pitch-stripe-a) 12.5%,
    var(--pitch-stripe-b) 12.5%,
    var(--pitch-stripe-b) 25%
  );
  overflow: hidden;
}

@media (min-width: 768px) {
  .pitch {
    aspect-ratio: 3 / 4;
  }
}

/* Marcadores de cancha */
.pitch-markings {
  position: absolute;
  inset: 4%;
  border: 2px solid var(--pitch-line);
  border-radius: 4px;
  pointer-events: none;
  z-index: 1;
}

.pitch-markings .halfway {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: var(--pitch-line);
  transform: translateY(-50%);
}

.pitch-markings .center-circle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22%;
  aspect-ratio: 1;
  border: 2px solid var(--pitch-line);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.pitch-markings .center-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  background: var(--pitch-line);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.pitch-markings .penalty-box {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 56%;
  height: 16%;
  border: 2px solid var(--pitch-line);
}

.pitch-markings .penalty-box.top {
  top: 0;
  border-top: none;
}

.pitch-markings .penalty-box.bottom {
  bottom: 0;
  border-bottom: none;
}

.pitch-markings .goal-box {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 28%;
  height: 7%;
  border: 2px solid var(--pitch-line);
}

.pitch-markings .goal-box.top {
  top: 0;
  border-top: none;
}

.pitch-markings .goal-box.bottom {
  bottom: 0;
  border-bottom: none;
}

/* Slots de jugadores */
.pitch-slots {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.slot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 4.25rem;
  min-height: 3.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  border-radius: 0.75rem;
  border: 1.5px dashed rgba(255, 255, 255, 0.25);
  background: var(--slot-empty);
  backdrop-filter: blur(2px);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

@media (min-width: 640px) {
  .slot {
    width: 5.25rem;
    min-height: 4.25rem;
  }
}

.slot:hover,
.slot.drag-over {
  border-color: var(--accent);
  background: var(--slot-hover);
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.35);
}

.slot.filled {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.55);
  cursor: grab;
}

.slot.filled:active {
  cursor: grabbing;
}

.slot .slot-role {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1;
}

.slot.filled .slot-role {
  color: var(--accent);
}

.slot .slot-number {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  background: #1a5c2e;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.slot .slot-name {
  font-size: 0.58rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.15;
  max-width: 100%;
  padding: 0 0.2rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #f3f4f6;
}

@media (min-width: 640px) {
  .slot .slot-name {
    font-size: 0.68rem;
  }
  .slot .slot-role {
    font-size: 0.62rem;
  }
  .slot .slot-number {
    width: 1.85rem;
    height: 1.85rem;
    font-size: 0.78rem;
  }
}

.slot.misfit {
  border-color: #f87171;
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.35);
}

.slot.star {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(234, 179, 8, 0.4);
}

/* ---------- Player cards (plantel) ---------- */
.player-card {
  background: linear-gradient(165deg, rgba(22, 60, 38, 0.9), rgba(10, 28, 18, 0.95));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.85rem;
  padding: 0.75rem;
  cursor: grab;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
}

.player-card:hover {
  transform: translateY(-2px);
  border-color: rgba(74, 222, 128, 0.4);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.player-card:active {
  cursor: grabbing;
}

.player-card.in-xi {
  opacity: 0.45;
  border-style: dashed;
}

.player-card .pc-num {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.9;
}

.player-card .pc-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  color: #fff;
  margin-bottom: 0.5rem;
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.player-card .pc-name {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.15rem;
}

.player-card .pc-meta {
  font-size: 0.65rem;
  color: #9ca3af;
}

.player-card .pc-rating {
  margin-top: 0.4rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fde68a;
  background: rgba(234, 179, 8, 0.12);
  padding: 0.1rem 0.4rem;
  border-radius: 9999px;
}

/* Bench chips */
.bench-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.55rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.7rem;
  cursor: grab;
  transition: background 0.15s;
}

.bench-chip:hover {
  background: rgba(74, 222, 128, 0.15);
}

/* Metric rows */
.metric-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.metric-row .label {
  width: 5.5rem;
  flex-shrink: 0;
  color: #9ca3af;
}

.metric-row .track {
  flex: 1;
  height: 0.4rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.metric-row .fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.6s ease;
}

.metric-row .val {
  width: 1.75rem;
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Analysis text blocks */
.prose-analysis .insight {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--accent);
}

.prose-analysis .insight.warn {
  border-left-color: #fbbf24;
}

.prose-analysis .insight.danger {
  border-left-color: #f87171;
}

.prose-analysis .insight.gold {
  border-left-color: var(--gold);
}

.prose-analysis strong {
  color: #fff;
  font-weight: 700;
}

/* Continent / team chips */
.continent-chip,
.team-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #d1d5db;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.continent-chip:hover,
.team-chip:hover {
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.35);
}

.continent-chip.active,
.team-chip.active {
  background: rgba(74, 222, 128, 0.18);
  border-color: rgba(74, 222, 128, 0.55);
  color: #4ade80;
}

/* Simulator */
.sim-stat {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #d1d5db;
}

.sim-stat span:last-child {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.sim-event {
  display: flex;
  gap: 0.65rem;
  padding: 0.4rem 0.5rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
}

.sim-event .min {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #4ade80;
  min-width: 2.2rem;
}

.sim-event.goal {
  background: rgba(74, 222, 128, 0.1);
  border-left: 3px solid #4ade80;
}

.sim-event.card {
  border-left: 3px solid #eab308;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: #14532d;
  color: #ecfdf5;
  border: 1px solid rgba(74, 222, 128, 0.4);
  padding: 0.65rem 1.15rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s ease;
  max-width: min(92vw, 28rem);
  text-align: center;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: #7f1d1d;
  border-color: rgba(248, 113, 113, 0.5);
}

/* Drag ghost polish */
.dragging {
  opacity: 0.55;
}

/* Scrollbar sutil */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
