/* Reset base e Stili Generali */
body {
    margin: 0;
    padding: 0;
    background-color: #06101A;
    color: #e0e0e0; /* Cambiato default per tema scuro */
    font-family: "Montserrat", "Twemoji Country Flags", sans-serif;
}

* {
    box-sizing: border-box;
}

/* Header Ridisegnato (Contiene anche i Filtri) */
header {
    background-color: #06101A;
    color: #ffffff;
    padding-top: 0.8em;
    text-align: center;
    margin-bottom: 2.5em;
    position: relative;
    border-bottom: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    padding-bottom: calc(0.8em + 5px); /* Spazio per barra sotto i filtri */
}

/* Contenitore per Logo e Titolo */
.header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    height: 100%;
    min-height: 50px;
    padding: 0 1em;
    margin-bottom: 1em;
}

/* Stile Logo */
.header-logo {
    height: 45px;
    width: auto;
    margin-right: 15px;
    vertical-align: middle;
}

/* Stile Titolo */
header h1 {
    margin: 0;
    font-size: 1.8em;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    letter-spacing: 0.5px;
    line-height: 1.2;
}

/* Barra colorata */
header::after {
    content: ''; position: absolute; bottom: 0; left: 0;
    width: 100%; height: 5px;
    background: linear-gradient(to right, #6a0dad, #000000, #e4c600, #d62828 );
}

/* Filtri Integrati nell'Header */
.filters {
    padding: 1.5em 1.5em;
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background-color: transparent; /* Integrato nell'header */
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.2em 1.5em;
    align-items: end;
}

/* Stile elementi singoli dentro la griglia filtri */
.filters > div {
    margin: 0; border: none; background: none; padding: 0; box-shadow: none;
    text-align: left;
    display: flex;
    flex-direction: column;
}

/* Stile Label (Tema Scuro) */
.filters label {
    display: block; font-weight: 600; color: #b0b8c4;
    font-size: 0.8em; margin-bottom: 0.4em; padding: 0;
    border: none; background: transparent; box-shadow: none;
    text-transform: uppercase; letter-spacing: 0.5px;
}

/* Stile Input e Select (Tema Scuro) */
.filters select,
.filters input[type="text"],
.filters input[type="date"] {
    width: 100%; padding: 0.8em; border: 1px solid #555;
    border-radius: 4px; background-color: #3f3f3f;
    color: #e0e0e0; font-size: 0.95em;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Stile freccia select */
.filters select {
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%23cccccc" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat;
    background-position: right 0.7em top 50%;
    background-size: 1.2em auto;
    padding-right: 2.5em;
}

.filters select:focus,
.filters input[type="text"]:focus,
.filters input[type="date"]:focus {
    border-color: #88aaff;
    box-shadow: 0 0 0 2px rgba(100, 150, 255, 0.25);
    outline: none;
    background-color: #4f4f4f;
}

.filters input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.8);
    cursor: pointer;
}

/* Contenitori Toggle/Select Specifici */
.filter-toggle,
.filter-newness-select { /* Ereditano stile da .filters > div */ }

/* Gruppo checkbox + label affiancati nel toggle */
.filter-toggle div.checkbox-label-group {
    display: flex; align-items: center; gap: 8px;
    background-color: #3f3f3f; padding: 0.7em 0.8em;
    border-radius: 4px; border: 1px solid #555;
    cursor: pointer; transition: background-color 0.2s ease;
    width: fit-content; min-height: 45.1px;
}
.filter-toggle div.checkbox-label-group:hover { background-color: #4f4f4f; }
.filters .filter-toggle input[type="checkbox"] {
    margin: 0; padding: 0; border: none; height: 1.1em; width: 1.1em;
    flex-shrink: 0; accent-color: #e4c600;
    box-shadow: none; background: transparent; cursor: pointer;
}
.filters .filter-toggle div.checkbox-label-group label {
    margin-bottom: 0; font-weight: normal; color: #e0e0e0;
    font-size: 0.95em; cursor: pointer; border: none; padding: 0;
    background: transparent; box-shadow: none;
    text-transform: none; letter-spacing: 0;
}

.filter-newness-select select { width: 100%; }


/* Contatore Risultati */
.results-summary {
    text-align: center; margin: -1.5em 0 1.5em 0; padding: 0 1em;
    font-size: 0.95em; color: #bbb;
}
#resultsCount { font-weight: bold; color:  #eee; }


/* Contenitore Griglia */
.grid-container {
    display: grid; padding: 1em; gap: 1.5em;
    grid-template-columns: repeat(4, 1fr);
}

/* Elemento Singolo nella Griglia (Card) */
.grid-item {
    border: 1px solid #333; /* Bordo più scuro per tema scuro */
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease-in-out, background-color 0.3s ease;
    display: flex; flex-direction: column; align-items: center;
    padding: 1em; text-align: center; position: relative; overflow: hidden;
    color: #333; /* Testo scuro per contrasto su sfondo chiaro card */
}
.grid-item.club-a { background-color: #fffadf; }
.grid-item.club-w { background-color: #f3e5f5; }


/* Immagine Profilo */
.grid-item .profile-pic {
     width: 100%; border-radius: 5%; margin-bottom: 1em;
    border: 3px solid #eee; aspect-ratio: 1 / 1; object-fit: cover;
    display: block; transition: transform 0.2s ease;
    /* cursor gestito da JS */
}
.grid-item .profile-pic:hover { transform: scale(1.03); }
body.hide-profile-pics .profile-pic { display: none; }

/* Contenitore per la riga Nome/Icona/Bandiera + Bottone */
.card-info-line {
    display: flex; flex-direction: row; justify-content: space-between;
    align-items: center; width: 100%; gap: 5px; margin-top: 0.5em;
}
.card-name-group { display: flex; align-items: center; gap: 8px; overflow: hidden; flex-shrink: 1; flex-grow: 1; }
.club-icon {
    width: 52px; height: auto; vertical-align: middle;
    flex-shrink: 0; border-radius: 4px; object-fit: contain;
    padding: 2px; background-color: transparent;
}
.grid-item.club-a .club-icon { background-color: #e4c600; }
.grid-item.club-w .club-icon { background-color: #952c91; }
.name-flag-container { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; flex-shrink: 1; }
.name-flag-container .name { font-weight: bold; font-size: 1.15em; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name-flag-container .flag { font-size: 1.4em; margin: 0; line-height: 1; flex-shrink: 0; }
.card-controls-group { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.status-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: middle; flex-shrink: 0; }
.status-dot.status-green { background-color: #4CAF50; }
.status-dot.status-yellow { background-color: #FFC107; }
.status-dot.status-red { background-color: #F44336; }
.grid-item .calendar-button {
    background-color: #333; color: #fff; border: none; padding: 8px 12px;
    text-align: center; text-decoration: none; display: inline-block;
    font-size: 0.9em; border-radius: 4px; cursor: pointer;
    transition: background-color 0.2s ease; white-space: nowrap;
}
.grid-item .calendar-button:hover { background-color: #555; }


/* === Stili Comuni per TUTTI i Modal === */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0, 0, 0, 0.5); }

/* === Stili Modal Calendario === */
.modal-content { background-color: #fefefe; margin: 10% auto; padding: 25px; border: 1px solid #888; width: 80%; max-width: 500px; border-radius: 10px; position: relative; box-shadow: 0 5px 15px rgba(0,0,0,0.2); }
.close-button { color: #aaa; position: absolute; top: 10px; right: 20px; font-size: 28px; font-weight: bold; cursor: pointer; line-height: 1; }
.close-button:hover, .close-button:focus { color: #333; text-decoration: none; }
.modal-content h2 { margin-top: 0; color: #333; text-align: center; margin-bottom: 20px; font-size: 1.3em; }
#calendarContainer { font-size: 0.9em; }
.calendar { width: 100%; border-collapse: collapse; margin-top: 15px; margin-bottom: 25px; }
.calendar th, .calendar td { border: 1px solid #ddd; padding: 8px; text-align: center; width: 14.28%; color: #333; /* Assicura testo nero su modale chiaro */ }
.calendar th { background-color: #f2f2f2; font-weight: bold; }
.calendar td { height: 40px; vertical-align: middle; }
.calendar .other-month { color: #ccc; background-color: #f9f9f9; }
.calendar .is-present { background-color: #90ee90; color: #006400; font-weight: bold; border-radius: 4px; }
/* NUOVI Stili Calendario per Date Passate */
.calendar .is-past { color: #bbb; background-color: #f7f7f7; }
.calendar .was-present { position: relative; color: #888; }
.calendar .was-present::before {
    content: ''; position: absolute; top: 4px; left: 4px;
    width: 7px; height: 7px; background-color: #4CAF50;
    border-radius: 50%; box-shadow: 0 0 2px rgba(0,0,0,0.4);
}

/* === Stili Modal Galleria === */
.gallery-modal { background-color: rgba(0, 0, 0, 0.85); align-items: center; justify-content: center; overflow: hidden; /* display: flex è messo da JS */}
.gallery-modal .gallery-image-container { position: relative; max-width: 90vw; max-height: 85vh; display: flex; align-items: center; justify-content: center; }
#galleryImage { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: 3px; }
.gallery-nav { position: absolute; top: 50%; transform: translateY(-50%); background-color: rgba(0, 0, 0, 0.4); color: white; border: none; font-size: 2.5em; padding: 10px 15px; cursor: pointer; border-radius: 5px; transition: background-color 0.2s ease; z-index: 1010; user-select: none; }
.gallery-nav:hover { background-color: rgba(0, 0, 0, 0.7); }
.gallery-nav.prev { left: 15px; }
.gallery-nav.next { right: 15px; }
.gallery-nav:disabled { opacity: 0.3; cursor: default; }
.close-gallery-button { position: absolute; top: 15px; right: 25px; color: #f1f1f1; font-size: 40px; font-weight: bold; transition: 0.3s; cursor: pointer; z-index: 1010; user-select: none; line-height: 1; }
.close-gallery-button:hover, .close-gallery-button:focus { color: #bbb; text-decoration: none; }
.gallery-counter { position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%); color: #f1f1f1; background-color: rgba(0, 0, 0, 0.6); padding: 5px 15px; border-radius: 15px; font-size: 0.9em; z-index: 1010; }


/* === Stili Skeleton Loader === */
.skeleton-card {
    border: 1px solid #333; border-radius: 8px; padding: 1em;
    background-color: #2a2a2a; /* Sfondo scheletro più scuro */
    min-height: 200px; /* REGOLA QUESTO VALORE! */
    display: flex; flex-direction: column; align-items: center;
}
.skeleton {
    background-color: #444; border-radius: 4px; margin-bottom: 0.8em;
    animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.skeleton-img {
    width: 100%; aspect-ratio: 1 / 1; height: auto;
    border-radius: 5%; margin-left: auto; margin-right: auto;
    margin-bottom: 1.5em;
}
.skeleton-line { width: 90%; height: 1em; margin-left: auto; margin-right: auto; }
.skeleton-line-medium { width: 70%; }
.skeleton-line-short { width: 50%; height: 0.9em; margin-bottom: 0.6em; }
@keyframes pulse { 0%, 100% { background-color: #444; } 50% { background-color: #555; } }

/* === Responsive === */
@media (max-width: 1200px) {
    .header-content { max-width: 95%; }
    .filters { max-width: none; width: 100%; border-radius: 0;}
}

@media (max-width: 992px) {
    .grid-container { grid-template-columns: repeat(3, 1fr); }
    header h1 { font-size: 1.6em; }
    .header-logo { height: 40px; }
    .filters { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1em 1.2em;}
}

@media (max-width: 768px) {
    .grid-container { grid-template-columns: repeat(2, 1fr); }
    .modal-content { width: 90%; margin: 15% auto; }
    .filters { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1em 1em;}
    header h1 { font-size: 1.5em; }
    .header-logo { height: 35px; margin-right: 10px;}
}

@media (max-width: 600px) {
    header h1 { font-size: 1.4em; }
    .filters { padding: 1em; grid-template-columns: 1fr 1fr; }
    .gallery-nav { font-size: 1.8em; padding: 8px 10px; }
    .gallery-nav.prev { left: 5px; }
    .gallery-nav.next { right: 5px; }
    .close-gallery-button { font-size: 30px; top: 10px; right: 15px; }
    .gallery-counter { font-size: 0.8em; padding: 4px 10px; }
    .gallery-modal .gallery-image-container { max-width: 95vw; max-height: 80vh; }
}

@media (max-width: 480px) {
    header { padding-top: 0.6em; padding-bottom: calc(0.6em + 5px); min-height: 55px; }
    header h1 { font-size: 1.2em; }
    .header-logo { height: 30px;  }
    .grid-container { grid-template-columns: 1fr; }

    /* Filtri su mobile: 1 colonna */
    .filters { grid-template-columns: 1fr; gap: 1.2em; padding: 1.2em; }
    .filters > div { width: 100%; }
    .filters select, .filters input:not([type="checkbox"]) { margin: 0; font-size: 1em; }
     .filters label { width: 100%; margin: 0 0 0.2em 0; padding: 0; font-size: 0.75em; text-align: left; }
     .filters .filter-toggle, .filters .filter-newness-select { width: 100%; margin: 0; padding: 0; text-align: left; border: none; background: none; box-shadow: none; }
     .filters .filter-toggle div.checkbox-label-group { width: auto; min-height: 48px; }
     .filters .filter-toggle div.checkbox-label-group label { font-size: 0.9em; color: #e0e0e0; margin-bottom: 0; }

     /* Card interna su mobile */
     .card-info-line { gap: 8px; }
     .card-name-group { gap: 5px; }
     .name-flag-container .name { font-size: 1em; }
     .name-flag-container .flag { font-size: 1.2em; }
     .club-icon { width: 40px; height: auto; padding: 1px; }
     .grid-item .calendar-button { font-size: 0.75em; padding: 5px 7px; }
     .status-dot { width: 10px; height: 10px; }
     .card-controls-group { gap: 5px; }

     /* Modal Calendario su mobile */
     .modal-content { width: 95%; margin: 15% auto; padding: 15px; }
     .modal-content h2 { font-size: 1.1em; }
     .calendar td { padding: 5px; height: 35px; font-size: 0.9em; }
     .calendar th { padding: 6px 2px; font-size: 0.85em; }
    .calendar .was-present::before { width: 5px; height: 5px; top: 3px; left: 3px; }
}


.calendar td.is-today {
    font-weight: 700; /* Rende il numero del giorno più marcato */
    color: #0d1b2a;   /* Colore scuro per massima leggibilità */
    
    /* Crea un "anello" blu attorno al numero usando box-shadow interno.
       Questo è meglio di 'border' perché non altera le dimensioni della cella. */
    box-shadow: inset 0 0 0 2px deepskyblue;
 
}

/* Se il giorno corrente ha anche una presenza (sfondo verde),
   ci assicuriamo che il numero rimanga ben visibile. */
.calendar td.is-today.is-present {
    color: #002b00; /* Un verde molto scuro per contrastare con lo sfondo verde chiaro */
}