/* ==========================================================================
   1. STILI GENERALI E LAYOUT
   ========================================================================== */

body {
  font-family: Arial, sans-serif;
  padding: 20px;
  background: #f9f9f9;
  user-select: none;         /* Standard */
  -webkit-user-select: none;   /* Chrome/Safari */
  -moz-user-select: none;      /* Firefox */
  -ms-user-select: none;       /* Internet Explorer/Edge */
} 

form {
  max-width: 1100px;
  margin: auto;
}

select {
  font-size: 1.1em;
  padding: 6px 10px;
  margin-bottom: 20px;
}

/* ===== HEADER & FOOTER UNIFICATI ===== */

.main-header {
  text-align: center;
  padding: 30px 20px;
  background-color: #43951e;
  border-bottom-left-radius: 30px;
  border-bottom-right-radius: 30px;
  color: white;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  margin-bottom: 30px;
}

.main-logo {
  max-height: 80px;
  width: auto;
  display: inline-block;
  margin-bottom: 10px;
}

.site-claim {
  font-size: 2.2rem;
  font-weight: 800;
  margin: 5px 0;
  text-transform: uppercase;
  letter-spacing: -1px;
}

.site-subtitle {
  font-size: 1.1rem;
  font-weight: 300;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.4;
}

.main-footer {
  text-align: center;
  padding: 30px 20px;
  background-color: #43951e;
  color: #ffffff;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  margin-top: 50px;
  box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
}

.footer-content p {
  margin: 5px 0;
  font-size: 0.9rem;
  opacity: 0.9;
}

.footer-links {
  margin-top: 15px;
}

.footer-links a {
  color: #ffffff;
  text-decoration: none;
  margin: 0 10px;
  font-weight: bold;
  font-size: 0.85rem;
  transition: opacity 0.3s;
}

.footer-links a:hover {
  opacity: 0.7;
  text-decoration: underline;
}

/* ==========================================================================
   2. BLOCCO PARTITA E SQUADRE (MATCH INFO)
   ========================================================================== */

.info-match {
  border: 2px solid #444;
  padding: 30px;
  margin: 30px auto;
  max-width: 900px;
  background-color: #f9f9f9;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  text-align: center;
  display: block;
}

.competizione-logo {
  max-height: 80px;
  margin-bottom: 20px;
}

.teams {
  display: flex;
  justify-content: center;
  gap: 60px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.team {
  text-align: center;
  flex: 1 1 200px;
  margin-bottom: 20px;
}

.team-logo {
  background: #fff;
  padding: 5px;
  border-radius: 8px;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 10px;
  display: inline-block;
  position: relative;
  max-height: 80px;
}

.team-logo img {
  max-height: 100px;
  max-width: 100%;
  display: block;
  margin: 0 auto;
}

.team-name {
  font-size: 1.4rem;
  font-weight: bold;
  color: #111;
}

.match-details {
  font-size: 1.2rem;
  line-height: 1.5;
  color: #555;
}

.league-container {
  position: relative;
  display: inline-block;
  margin-bottom: 25px;
  width: 100%;
  max-width: 500px;
}

.input-titolo {
  font-size: 1.8rem !important;
  color: #2c3e50;
  border: none !important;
  border-bottom: 3px solid #3498db !important;
  background: transparent !important;
  padding: 10px 40px !important;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
  width: 100%;
  box-sizing: border-box;
}

.input-titolo:focus {
  border-bottom-color: #e74c3c !important;
  outline: none;
}

.league-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.5rem;
  color: #3498db;
}

.upload-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(255,255,255,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.upload-instruction {
  font-size: 0.75rem;
  color: #888;
  margin: 8px 0;
  font-style: italic;
  font-weight: 400;
  text-transform: lowercase;
}

.btn-rotate {
  background: #f1f1f1;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  margin-top: 5px;
  color: #555;
}
.btn-rotate:hover { background: #e0e0e0; }

/* Responsive per Match Info */
@media (max-width: 768px) {
  .info-match {
    padding: 15px;
  }
  .teams {
    gap: 30px;
  }
  .team {
    flex: 1 1 150px;
  }
  .team-logo {
    padding: 4px;
  }
  .team-logo img {
    max-height: 80px;
  }
  .team-name {
    font-size: 1.2rem;
  }
}

/* ==========================================================================
   3. SELEZIONE E POPUP MAGLIE (JERSEY CONTROLS)
   ========================================================================== */

/* Box per i pulsanti maglie */
.jersey-control-box {
  background: #ffffff;
  border: 2px solid #ddd;
  border-radius: 8px;
  padding: 15px;
  margin: 20px auto 10px auto;
  max-width: 900px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 40px;
  flex-wrap: wrap;
}

/* Box separato per la checkbox */
.photo-option-box {
  background: #f8f9fa;
  border: 1px dashed #bbb;
  border-radius: 8px;
  padding: 12px 20px;
  margin: 0 auto 20px auto;
  max-width: 900px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn-custom-jersey {
  background: #43951e;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

.btn-custom-jersey:hover {
  background: #367817;
}

.jersey-preview-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

/* POPUP / MODAL MAGLIE */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99999;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  padding: 25px;
  border-radius: 12px;
  max-width: 520px;
  width: 90%;
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.modal-header {
  font-size: 1.3rem;
  font-weight: bold;
  margin-bottom: 15px;
  color: #2c3e50;
  text-align: center;
}

.pattern-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.pattern-card {
  border: 2px solid #eee;
  border-radius: 8px;
  padding: 6px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.pattern-card:hover {
  border-color: #a0d490;
  background: #f8fcf7;
}

.pattern-card.selected {
  border-color: #43951e !important;
  background: #eef7ed !important;
  box-shadow: 0 0 6px rgba(67, 149, 30, 0.4);
}

.pattern-card img {
  width: 100%;
  height: 45px;
  object-fit: contain;
}

.pattern-card span {
  display: block;
  font-size: 0.7rem;
  margin-top: 4px;
  font-weight: bold;
  color: #555;
}

.modal-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-field label {
  font-weight: 600;
  color: #333;
}

.modal-field input[type="color"] {
  width: 60px;
  height: 35px;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  padding: 2px;
}

.modal-footer {
  margin-top: 20px;
  text-align: center;
}

.btn-close-modal {
  background: #43951e;
  color: white;
  border: none;
  padding: 8px 24px;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
}

/* ==========================================================================
   4. TABELLA MODIFICA GIOCATORI
   ========================================================================== */

table#playersTable {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid #999;
}

#playersTable th,
#playersTable td {
  border: 1px solid #999;
  padding: 8px;
  vertical-align: middle;
  position: relative;
}

/* Inputs generici */
input[type="text"] {
  width: 95%;
  padding: 5px;
  box-sizing: border-box;
  font-size: 1em;
}

.input-numero {
  width: 40px !important;
  padding: 4px 6px;
  text-align: center;
}

.input-nome {
  width: 90px !important;
  padding: 4px 6px;
}

.input-cognome {
  width: 150px !important;
  padding: 4px 6px;
}

#playersTable th:nth-child(1), #playersTable td:nth-child(1) { width: 40px; }
#playersTable th:nth-child(2), #playersTable td:nth-child(2) { width: 90px; }
#playersTable th:nth-child(3), #playersTable td:nth-child(3) { width: 140px; }

/* Clear button 'X' su Cognome */
#playersTable td.position-relative .input-clear-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
}

#playersTable .input-cognome {
  width: 100% !important;
  padding-right: 24px;
  box-sizing: border-box;
  padding-left: 6px;
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: 1em;
  border: 1px solid #ccc;
  border-radius: 4px;
  transition: border-color 0.2s ease;
}

#playersTable .clear-input-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: #ccc;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-weight: bold;
  font-size: 12px;
  width: 18px;
  height: 18px;
  line-height: 16px;
  padding: 0;
  user-select: none;
  transition: background 0.2s ease;
}

#playersTable .clear-input-btn:hover {
  background: #999;
}

.clear-row-btn {
  font-size: 16px;
  cursor: pointer;
  background: transparent;
  border: none;
  color: #999;
  padding: 0 6px;
  user-select: none;
  vertical-align: middle;
}

/* Autocomplete suggestions */
.position-relative {
  position: relative;
}

.autocomplete-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: white;
  border: 1px solid #ccc;
  z-index: 9999;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  display: none;
  min-width: 200px;
  box-sizing: border-box;
}

.autocomplete-suggestion {
  padding: 8px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.autocomplete-suggestion:hover {
  background-color: #f0f0f0;
}

.autocomplete-suggestion img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

/* ==========================================================================
   5. TABELLA VISUALE CAMPO DA GIOCO
   ========================================================================== */

table#visualTable {
  width: 100%;
  border-collapse: collapse;
  background:
    radial-gradient(circle, rgba(23, 151, 23, 0.5), rgba(5, 129, 5, 0.3)),
    url('https://www.creaformazioni.it/aprijson/paste/img/campo-small.jpg') no-repeat center center;
  background-size: contain;
  margin-bottom: 30px;
}

table#visualTable td {
  height: 100px;
  vertical-align: top;
  padding: 5px;
  border: 1px solid #ccc;
}

/* Nomi e cognomi sul campo */
#visualTable div > div:nth-child(2) {
  color: white;
  font-weight: bold;
  font-size: 1em;
}

.cognome-small,
#visualTable div > div.cognome-small {
  font-size: 0.75em;
}

/* Immagine Giocatore / Maglia sul campo (Con cerchio bianco e bordo grigio) */
#visualTable img.player-img,
.player-img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 5px;
  display: block;
  border: 3px solid gray;
  background-color: white;
  box-sizing: border-box;
}

/* Nasconde l'elemento del numero se non è presente il testo */
.player-number:empty {
  display: none !important;
}

/* Fallback immagine vuota */
#visualTable img.player-img[src=""] {
  background-color: white;
  border: 3px solid gray;
}

/* ==========================================================================
   6. SEZIONE ALLENATORE (MANAGER)
   ========================================================================== */

#managerFields {
  margin: 1.2em auto 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: Arial, sans-serif;
  position: relative;
  max-width: 400px;
  text-align: center;
}

#managerFields label {
  white-space: nowrap;
  font-weight: 600;
  font-size: 1em;
  color: #333;
}

.coach-info {
  display: grid;
  grid-auto-flow: column;
  align-items: center;
  justify-content: center;
  column-gap: 8px;
  margin-top: 0.5em;
}

.coach-photo,
#managerPhotoPreview {
  height: 40px;
  width: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #ccc;
  display: block;
  margin-left: 8px;
  vertical-align: middle;
}

.coach-info img {
  width: 70px;
  height: 70px;
  border-radius: 30%;
  object-fit: cover;
  border: 1px solid #ccc;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.coach-info span,
#managerNameDisplay {
  font-weight: 600;
  font-size: 1.1rem;
  color: #333;
}

#managerFields input[type="text"] {
  font-size: 1em;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 220px;
  box-sizing: border-box;
}

.clear-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  padding: 0;
  font-size: 1em;
  background: transparent;
  border: none;
  color: #999;
  cursor: pointer;
  line-height: 1;
  user-select: none;
}

.clear-btn:hover {
  color: #555;
}

#manager_image_url_input {
  display: none;
}

/* ==========================================================================
   7. PULSANTI ED ELEMENTI EXTRA
   ========================================================================== */

#croppedLogoPreview {
  max-width: 150px;
  max-height: 150px;
  object-fit: contain;
  border: 1px solid #ccc;
  margin-top: 10px;
}

.button-link {
  display: inline-block;
  padding: 10px 20px;
  background-color: #007BFF;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.3s ease;
}

.button-link:hover,
.button-link:focus {
  background-color: #0056b3;
  outline: none;
}

.button-link:active {
  background-color: #00408d;
}

.btn-salva {
  background-color: #4CAF50;
  color: white; 
  padding: 12px 25px; 
  border: none; 
  border-radius: 8px;
  font-size: 16px; 
  cursor: pointer;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.btn-salva:hover {
  background-color: #45a049;
  box-shadow: 0 6px 10px rgba(0,0,0,0.15);
}

.btn-salva:active {
  background-color: #3b8e41;
}