:root {
  --primary-color: #0080ff;
  --primary-dark: #0056b3;
  --primary-light: #e6f2ff;
  --danger-color: #dc3545;
  --danger-light: #ffe6e6;
  --success-color: #28a745;
  --success-light: #e6ffe6;
  --text-primary: #1a1a1a;
  --text-secondary: #6c757d;
  --text-light: #999999;
  --bg-light: #f8f9fa;
  --bg-white: #ffffff;
  --border-color: #e0e0e0;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: linear-gradient(135deg, var(--bg-light) 0%, #f0f4f8 100%);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

.dashboard-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 0.75rem;
}

/* Header Section */
.header-section {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  border-radius: 16px;
  padding: 3rem 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
  color: white;
  position: relative;
  overflow: hidden;
}

.header-section::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 50%;
  pointer-events: none;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 3rem;
  position: relative;
  z-index: 1;
}

.team-header {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex: 1;
}

.team-logo-wrapper {
  flex-shrink: 0;
}

.team-logo {
  width: 120px;
  height: 120px;
  border-radius: 16px;
  object-fit: contain;
  background: rgba(255, 255, 255, 0.1);
  padding: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transition: var(--transition);
}

.team-logo:hover {
  transform: scale(1.05);
}

.placeholder-logo {
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: rgba(255, 255, 255, 0.8);
}

.team-info h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

.welcome-text {
  font-size: 1rem;
  opacity: 0.95;
  margin-bottom: 1rem;
}

.team-stats {
  display: flex;
  gap: 1rem;
}

.stat-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  backdrop-filter: blur(10px);
}

.header-actions {
  flex-shrink: 0;
}

.btn-primary-action {
  background: white;
  color: var(--primary-color);
  border: none;
  padding: 1rem 2rem;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.btn-primary-action:active {
  transform: translateY(0);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  border: 1px solid var(--border-color);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}

.players-icon {
  background: var(--primary-light);
  color: var(--primary-color);
}

.team-icon {
  background: #fff3cd;
  color: #ff9800;
}

.active-icon {
  background: var(--success-light);
  color: var(--success-color);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* Content Wrapper */
.content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* Section Container */
.section-container {
  background: var(--bg-white);
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.transfer-section {
  border-left: 4px solid var(--primary-color);
}

.transfer-section[hidden] {
  display: none !important;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.section-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 300px;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: var(--transition);
  background: var(--bg-light);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  background: var(--bg-white);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

/* Players Table */
.players-table-container {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrapper {
  width: 100%;
  max-width: 100%;
  margin-left: 0;
}

.players-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
}

.players-table thead {
  background: var(--bg-light);
  border-top: 1px solid var(--border-color);
  border-bottom: 2px solid var(--border-color);
}

.players-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: rgb(255, 255, 255);
  background-color: #0056b3;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.col-photo { width: 80px; }
.col-camiseta { width: 84px; }
.col-name { flex: 1; }
.col-status { width: 120px; }
.col-actions { width: 150px; }

.players-table th.col-camiseta,
.players-table td.col-camiseta {
  text-align: center;
}

.players-table th.col-status,
.players-table td.col-status {
  text-align: center;
}

.player-row {
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
}

.player-row:hover {
  background: var(--bg-light);
}

.players-table td {
  padding: 1rem;
  vertical-align: middle;
}

.player-camiseta {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.98rem;
  letter-spacing: 0.2px;
  color: #0d2a4a;
  background: linear-gradient(135deg, #ffffff 0%, #e6f2ff 100%);
  border: 1px solid #b9d8ff;
  box-shadow: 0 6px 14px rgba(0, 128, 255, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.player-row:hover .player-camiseta {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(0, 128, 255, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.player-photo-container {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden; /* ensure image is clipped to circle */
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-color);
  background: rgba(255,255,255,0.03);
}

.player-photo {
  width: 100%;
  height: 100%;
  object-fit: contain; /* show the cropped image exactly without extra zoom */
  display: block;
  transition: var(--transition);
}
.player-photo:hover {
  border-color: var(--primary-color);
}

/* Background-based thumbnail to exactly mirror cropper preview (no extra scaling) */
.player-photo-bg {
  width: 100%;
  height: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center center;
  display: block;
}

.placeholder-photo {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--bg-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-size: 1.3rem;
  border: 2px solid var(--border-color);
}

.player-name {
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}

.player-name-link {
  text-decoration: none;
}

.player-name-link:hover {
  color: var(--primary-color);
  text-decoration: underline;
}

.status-badge {
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-block;
  text-transform: capitalize;
}

.status-badge.active {
  background: var(--success-color);
  color: #fff;
}

.status-badge.inactive {
  background: var(--danger-color);
  color: #fff;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
}

.btn-action {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
  text-decoration: none;
  color: var(--text-secondary);
  background: var(--bg-white);
}

.btn-action:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn-edit:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: var(--primary-light);
}

.btn-delete:hover {
  border-color: var(--danger-color);
  color: var(--danger-color);
  background: var(--danger-light);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
}

.empty-icon {
  font-size: 4rem;
  color: var(--text-light);
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.empty-message {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.btn-empty-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--primary-color);
  color: white;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-empty-action:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.transfer-action-btn {
  border: 0;
  padding: 0.75rem 1rem;
  white-space: nowrap;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-white);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 90%;
  animation: slideUp 0.3s ease;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
}

/* Asegurar que el modal de foto del representante se centre verticalmente
   (evita que reglas genéricas de .modal-content afecten el posicionamiento) */
#fotoModalRepresentante .modal-dialog {
  display: flex !important;
  align-items: center !important;
  min-height: calc(100vh - 3.5rem) !important;
  justify-content: center !important;
}
#fotoModalRepresentante .modal-content {
  margin: 0 auto !important;
}

.modal-message {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 1rem;
}

.modal-warning {
  font-size: 0.9rem;
  color: var(--danger-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--danger-light);
  border-radius: 6px;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.btn-cancel, .btn-confirm-delete {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.95rem;
}

.btn-cancel {
  background: var(--bg-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-cancel:hover {
  background: var(--border-color);
}

.btn-confirm-delete {
  background: var(--danger-color);
  color: white;
}

.btn-confirm-delete:hover {
  background: #c82333;
  transform: translateY(-2px);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 2000;
}

.toast {
  background: var(--text-primary);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  display: none;
  animation: slideInRight 0.3s ease;
}

.toast.show {
  display: block;
}

.toast-message {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Responsive Design */
@media (max-width: 768px) {
  .dashboard-container {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(-50vw + 50%);
    margin-right: 0;
    padding: 0rem;
  }

  .players-table-container {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(-50vw + 50%);
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .header-section {
    padding: 2rem 1.5rem;
  }

  .header-content {
    flex-direction: column;
    gap: 1.5rem;
  }

  .team-header {
    width: 100%;
    flex-direction: column;
    text-align: center;
  }

  .team-info h1 {
    font-size: 1.8rem;
  }

  .header-actions {
    width: 100%;
  }

  .btn-primary-action {
    width: 100%;
    justify-content: center;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-wrapper {
    width: 100%;
    max-width: 100%;
  }

  .players-table th,
  .players-table td {
    padding: 0.75rem 0.5rem;
    font-size: 0.9rem;
  }

  .action-buttons {
    gap: 0.25rem;
  }

  .btn-action {
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }

  .col-photo { width: 50px; }
  .col-camiseta { width: 70px; }

  .modal-content {
    width: 95%;
  }

  .toast-container {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
  }

  .toast {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .team-logo {
    width: auto;
    height: 120px;
  }

  .placeholder-logo {
    width: 80px;
    height: 80px;
    font-size: 5rem;
    padding: 0;
  }

  .stat-icon {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .player-photo-container {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--border-color);
    background: rgba(255,255,255,0.03);
  }

  .player-photo {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .placeholder-photo {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  /* Mobile tweaks: smaller text and prevent name wrapping */
  .players-table th {
    font-size: 0.72rem;
    padding: 0.5rem 0.4rem;
  }

  .players-table td {
    font-size: 0.65rem;
    padding: 0.15rem;
  }

  .player-camiseta {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 0.8rem;
  }
  .player-photo {
    width: 50px;
    height: 50px;
  }

  .player-name, .player-apellido {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    max-width: 120px;
  }

  .col-actions { width: 110px; }
  .col-fecha-nac { width: 90px; }

  /* Keep 'Fecha Nac.' header on a single line on small screens */
  .players-table th.col-fecha-nac {
    white-space: nowrap !important;
    font-size: 0.72rem !important;
    padding-right: 0.1rem !important;
    max-width: 86px !important;
    width: 86px !important;
  }
}