/* Palette Colori e Variabili (Tema Verde Menta Soft) */
:root {
  --primary-color: #4bb39f; /* Nuovo Verde Menta Soft (meno acceso) */
  --primary-hover: #3a8e7e; /* Hover Verde più scuro */
  --text-dark: #333;
  --text-medium: #6c757d;
  --bg-light: #f0f2f5; /* Sfondo Grigio Caldo Chiaro */
  --white: #ffffff;
  --border-color: #e9ecef;
  --shadow-light: 0 4px 12px rgba(0, 0, 0, 0.08);
  /* Colori per la sottoscrizione (Verde Menta) - USATO COME COLORE PRIMARIO */
  --subscribe-color: var(--primary-color);
  --subscribe-hover: var(--primary-hover);
}

html {
    height: 100%;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: 'Inter', sans-serif;
  background: var(--bg-light);
  flex-direction: column;
  align-items: center;
  color: var(--text-dark);
}

.container-wrapper {
    max-width: 700px;
    width: 90%;
    margin-left: auto;
    margin-right: auto;
    margin-top: 0;
    margin-bottom: 10px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding-bottom: 60px;
    align-items: center;
}

.container {
  width: 100%;
  margin-bottom: 0;
  background: var(--white);
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow-light);
  flex-grow: 0;
}

/* -------------------- Intestazione e Titolo -------------------- */
h2 {
  text-align: center;
  color: var(--primary-color);
  font-weight: 700;
  margin-bottom: 2rem;
  font-size: 1.8rem;
}

/* -------------------- Bottoni Comuni (Classe .btn) -------------------- */

.btn {
    padding: 0.7rem 1.1rem;
    /* CORREZIONE ANTI-ZOOM: Aumento font-size a 1.1rem (17.6px) per massima sicurezza su iOS */
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    text-decoration: none;
    flex-grow: 1;
    min-width: 120px;
    line-height: 1.2;
}

.btn:active {
    transform: scale(0.98);
}

/* TUTTI I BOTTONI DI AZIONE (Scarica/Chiudi/Sottoscrivi) ORA SONO VERDE MENTA E FORZATI CON !IMPORTANT */
.btn-download, .btn-subscribe {
  background-color: var(--primary-color) !important;
  color: var(--white);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-download:hover, .btn-subscribe:hover {
  background-color: var(--primary-hover) !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}


/* -------------------- Footer -------------------- */

footer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-medium);
  padding: 1rem;
  background: var(--white);
  border-top: 1px solid var(--border-color);
  width: 100%;
  margin-top: auto;
  flex-shrink: 0;
  position:fixed;
  bottom:0;
}

/* -------------------- Stili Ricerca e Squadre -------------------- */

.top-link-container {
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 1rem 0;
    width: 100%;
}

.top-link-container a {
    display: inline-block;
    background-color: var(--primary-color);
    color: var(--white);
    padding: 10px 18px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    /* CORREZIONE ANTI-ZOOM: Aumento font-size da 0.95rem a 1.05rem (16.8px) */
    font-size: 1.05rem;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.top-link-container a:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
}

.search-box {
    position: relative;
    margin-bottom: 2rem;
}

input[type="text"] {
  width: 100%;
  padding: 1rem 1rem 1rem 3.5rem;
  /* CORREZIONE ANTI-ZOOM: Aumento font-size a 1.15rem per massima sicurezza */
  font-size: 1.15rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all 0.3s ease;
  box-sizing: border-box;
}

input[type="text"]:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(75, 179, 159, 0.25);
  outline: none;
}

.search-icon {
    position: absolute;
    top: 50%;
    left: 1rem;
    transform: translateY(-50%);
    color: var(--text-medium);
    font-size: 1.2rem;
}

.empty-state, .loading-message {
    text-align: center;
    color: var(--text-medium);
    padding: 3rem 0;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    margin-top: 2rem;
}

.loading-message {
    font-weight: 600;
    color: var(--primary-color);
}

#results {
    display: block;
}

/* Aggiornamento CRITICO: Aggiunti i selettori .team e .team-name per garantire che il JS funzioni */
.entity, .team {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap; /* Manteniamo gli elementi sulla stessa riga */
  margin-bottom: 0.8rem;
  padding: 1rem;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: transform 0.2s, box-shadow 0.2s;
}

.entity:hover, .team:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.entity-name, .team-name {
  flex-grow: 1;
  font-weight: 600;
  font-size: 1.1rem;
  /* MARGINE AUMENTATO: 30px per separare meglio il nome dal pulsante */
  margin-right: 30px;
}

/* Stile per l'immagine del logo della squadra */
.team img {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    object-fit: contain;
    border: 2px solid var(--border-color);
    margin-right: 15px;
    flex-shrink: 0;
}


.entity-actions, .team-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
    min-width: 130px;
}

/* -------------------- STILI MODALE -------------------- */
#modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--white);
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 0 30px rgba(0,0,0,0.4);
  z-index: 1000;
  text-align: center;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* FONT SIZE GIA' SICURA: 1.05rem (16.8px) */
  font-size: 1.05rem;
  line-height: 1.4;
}

#overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}

/* Stili per il contenuto del modale (basati sull'HTML modificato) */
.modal-message-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
}

.team-name-highlight {
    color: var(--primary-color);
}

.copy-success-highlight {
    color: #008000; /* Verde per 'copiato' */
}

.url-label {
    margin: 15px 0 5px 0;
    font-weight: 600;
    color: var(--text-medium);
    text-align: left;
    font-size: 1rem;
}

.subscription-url-code {
    display: block;
    background-color: var(--bg-light);
    padding: 10px;
    border-radius: 6px;
    /* FONT SIZE GIA' SICURA: 1.05rem (16.8px) */
    font-size: 1.05rem;
    overflow-wrap: break-word;
    color: var(--primary-color); /* Usa il verde primario anche qui */
    border: 1px solid var(--border-color);
    cursor: text;
    text-align: left;
    line-height: 1.2; /* Aggiunto per stabilità */
}

.instructions-box {
    margin-top: 20px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: #f7f7f7;
    text-align: left;
}

.instructions-title {
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--primary-hover);
    font-size: 1.1em;
}

.instructions-box ol {
    list-style-type: decimal;
    padding-left: 20px;
    margin: 0;
    line-height: 1.6;
    font-size: 1rem; /* Assicuriamo 16px anche qui */
}

.instructions-box a {
    color: var(--primary-color); /* Ora usa il colore primario */
    text-decoration: underline;
}

.modal-footnote {
    margin-top: 15px;
    font-size: 0.9em;
    color: var(--text-medium);
    text-align: left;
}

#modal button {
  margin-top: 1.5rem;
}

/* -------------------- RESPONSIVITÀ MOBILE OTTIMIZZATA (@media (max-width: 600px)) -------------------- */
@media (max-width: 600px) {

    .container {
        padding: 1.5rem;
    }

    body {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }

    h2 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
    }

    .entity, .team {
        flex-direction: column;
        align-items: center;
        padding: 0.8rem;
        text-align: center;
    }

    .team img {
        margin-right: 0;
        margin-bottom: 10px;
    }

    .entity-name, .team-name {
        width: 100%;
        margin-bottom: 1rem;
        margin-right: 0;
        text-align: center;
    }

    .entity-actions, .team-actions {
        width: 100%;
        flex-direction: row;
        gap: 10px;
        min-width: 100%;
        justify-content: stretch; /* Usiamo stretch per riempire bene */
    }

    .btn {
        padding: 0.6rem;
        font-size: 1.1rem; /* Mantengo la dimensione sicura aggiornata */
        /* CORREZIONE CRITICA: Aggiunto min-height per garantire un touch target adeguato */
        min-height: 44px;
    }

    .top-link-container a {
        width: 100%;
        box-sizing: border-box;
        padding: 12px 10px;
        font-size: 1.05rem; /* Mantengo la dimensione sicura aggiornata */
        /* CORREZIONE CRITICA: Aggiunto min-height per garantire un touch target adeguato */
        min-height: 44px;
    }

    .btn-subscribe {
        width: 100%;
    }

    .download-area {
        padding: 2rem 0.5rem;
    }

    #modal {
        padding: 1rem;
    }

    .instructions-box ol {
        font-size: 1rem;
    }

}
