:root {
    --blu: #136af6;
    --blu-scuro: #0e4fb8;
    --arancio: #fa834c;
    --viola: #b54dff;
    --navy: #1e2233;
    --navy-chiaro: #2d334d;
    --grigio-bordo: #d0d9e7;
    --grigio-testo: #5a6572;
    --sfondo: #edf1f8;
    --rosso: #fd4e6b;
    --verde-successo: #65c723;
    --ombra: 0 6px 18px rgba(30, 34, 51, 0.1);
    --ombra-hover: 0 10px 26px rgba(30, 34, 51, 0.16);
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background: var(--sfondo);
    color: #1c2226;
}

h1, .logo-login {
    font-family: "Anton", "Inter", sans-serif;
    font-weight: 400;
    text-transform: uppercase;
}

.accento {
    background: linear-gradient(90deg, var(--arancio), #ffb37a);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.logo-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.logo-icona {
    font-size: 1.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blu), var(--viola));
    box-shadow: 0 4px 12px rgba(19, 106, 246, 0.4);
    animation: comparsa 0.6s ease both;
}

.logo-mark-login .logo-icona {
    width: 2.3rem;
    height: 2.3rem;
    font-size: 1.5rem;
}

header {
    background: linear-gradient(135deg, var(--navy), var(--navy-chiaro));
    color: #fff;
    padding: 2rem 1rem 1.75rem;
    text-align: center;
    box-shadow: var(--ombra);
    position: relative;
    overflow: hidden;
}

header h1 {
    margin: 0;
    font-size: 2.2rem;
    letter-spacing: 0.5px;
    animation: comparsa 0.6s ease both;
}

.sottotitolo {
    margin: 0.4rem 0 0;
    opacity: 0.92;
    animation: comparsa 0.6s ease 0.1s both;
}

.logout {
    display: inline-block;
    margin-top: 0.7rem;
    color: #fff;
    opacity: 0.85;
    font-size: 0.85rem;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 20px;
    padding: 0.25rem 0.9rem;
    transition: background 0.2s ease, transform 0.2s ease;
}

.logout:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

@keyframes comparsa {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

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

main {
    max-width: 900px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

.scheda {
    background: #fff;
    border: 1px solid var(--grigio-bordo);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--ombra);
    animation: entrata 0.5s ease both;
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.scheda:hover {
    box-shadow: var(--ombra-hover);
}

main .scheda:nth-of-type(1) { animation-delay: 0.05s; }
main .scheda:nth-of-type(2) { animation-delay: 0.15s; }
main .scheda:nth-of-type(3) { animation-delay: 0.25s; }

.scheda h2 {
    margin-top: 0;
    color: var(--navy);
    font-family: "Anton", "Inter", sans-serif;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.campo {
    margin-bottom: 1rem;
}

.campo label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.campo input[type="text"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--grigio-bordo);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.campo input[type="text"]:focus,
.riga-data input[type="date"]:focus,
#password:focus {
    outline: none;
    border-color: var(--blu);
    box-shadow: 0 0 0 3px rgba(19, 106, 246, 0.18);
}

.aiuto {
    color: var(--grigio-testo);
    font-size: 0.9rem;
    margin: 0.2rem 0 0.6rem;
}

.riga-data {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    animation: entrata 0.3s ease both;
}

.riga-data input[type="date"] {
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--grigio-bordo);
    border-radius: 8px;
    transition: border-color 0.2s ease;
}

.riga-data span {
    color: var(--grigio-testo);
    font-size: 0.85rem;
}

.rimuovi-riga {
    background: none;
    border: none;
    color: var(--rosso);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.2rem 0.4rem;
    border-radius: 50%;
    transition: background 0.2s ease, transform 0.2s ease;
}

.rimuovi-riga:hover {
    background: rgba(224, 56, 77, 0.12);
    transform: scale(1.15);
}

#aggiungi-riga {
    background: none;
    border: 1px dashed var(--blu);
    color: var(--blu-scuro);
    border-radius: 8px;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.15s ease;
}

#aggiungi-riga:hover {
    background: rgba(19, 106, 246, 0.08);
    transform: translateY(-1px);
}

.invia {
    display: block;
    margin-top: 1.25rem;
    background: linear-gradient(120deg, var(--blu), var(--viola));
    background-size: 160% 160%;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.2rem;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background-position 0.4s ease;
    box-shadow: 0 4px 14px rgba(19, 106, 246, 0.35);
}

.invia:hover {
    background-position: 100% 0;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(19, 106, 246, 0.4);
}

.invia:active {
    transform: translateY(0);
}

.messaggio {
    padding: 0.85rem 1.1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    font-weight: 600;
    animation: entrata 0.35s ease both;
}

.messaggio.successo {
    background: #eaf9e3;
    color: #3f8a14;
    border: 1px solid #c3ecac;
}

.messaggio.errore {
    background: #fbe6e6;
    color: var(--rosso);
    border: 1px solid #f0bcbc;
}

.scuoti {
    animation: scuotimento 0.4s ease;
}

@keyframes scuotimento {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

.legenda {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.badge {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 20px;
    margin-top: 0.15rem;
    line-height: 1.2;
    white-space: normal;
    font-weight: 600;
    transition: transform 0.15s ease;
}

.badge:hover {
    transform: scale(1.05);
}

.badge-giornata {
    background: #e2ecfb;
    color: var(--blu);
}

.badge-mercato {
    background: #fbeadc;
    color: var(--arancio);
}

.badge-sosta {
    background: #eee2fb;
    color: var(--viola);
}

.badge-assenza {
    background: #fbe2e2;
    color: var(--rosso);
    font-weight: 700;
}

.nav-mese {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.nav-mese a {
    color: var(--blu-scuro);
    text-decoration: none;
    font-weight: 700;
    padding: 0.3rem 0.7rem;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.nav-mese a:hover {
    background: rgba(19, 106, 246, 0.1);
}

.nav-mese a.disabilitato {
    pointer-events: none;
    color: var(--grigio-bordo);
}

table.calendario {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

table.calendario th {
    background: var(--sfondo);
    padding: 0.4rem;
    font-size: 0.85rem;
    border: 1px solid var(--grigio-bordo);
}

table.calendario td {
    border: 1px solid var(--grigio-bordo);
    vertical-align: top;
    height: 5.5rem;
    padding: 0.3rem;
    font-size: 0.85rem;
    transition: background 0.2s ease;
}

table.calendario td:not(.vuoto):hover {
    background: #f2f7ff;
}

table.calendario td.vuoto {
    background: #fafbfc;
}

.numero-giorno {
    font-weight: 700;
    margin-bottom: 0.2rem;
}

.banner-info {
    background: #eaf1ff;
    border: 1px solid #c6dcfd;
    color: var(--navy);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.testo-verde {
    color: #3f8a14;
}

.badge-libero {
    background: #e2f8d4;
    color: #3f8a14;
    font-weight: 700;
}

td.giorno-libero {
    background: #eafce0;
    cursor: pointer;
    position: relative;
    transition: background 0.2s ease, transform 0.15s ease;
}

td.giorno-libero:hover {
    background: #d7f7c2;
    transform: scale(1.03);
    z-index: 1;
    box-shadow: 0 4px 14px rgba(101, 199, 35, 0.35);
}

td.passato {
    background: #f7f8fa;
    color: var(--grigio-testo);
    opacity: 0.55;
}

td.fuori-periodo {
    background: #f7f8fa;
    color: var(--grigio-testo);
    opacity: 0.45;
}

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

table.elenco th,
table.elenco td {
    border: 1px solid var(--grigio-bordo);
    padding: 0.5rem 0.6rem;
    text-align: left;
    font-size: 0.9rem;
}

table.elenco th {
    background: var(--sfondo);
}

table.elenco tbody tr {
    transition: background 0.15s ease;
}

table.elenco tbody tr:hover {
    background: #f4f7fd;
}

footer {
    text-align: center;
    color: var(--grigio-testo);
    font-size: 0.8rem;
    padding: 1.5rem 1rem;
}

/* --- Bonus/malus del fantacalcio che cadono quando si segna una data --- */
#bonus-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 999;
    overflow: hidden;
}

.bonus-caduto {
    position: absolute;
    top: -3rem;
    font-weight: 800;
    font-size: 1.6rem;
    color: var(--rosso);
    background: #fff;
    border: 2px solid var(--rosso);
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(224, 56, 77, 0.35);
    animation-name: caduta;
    animation-timing-function: ease-in;
    animation-fill-mode: forwards;
}

.bonus-caduto.positivo {
    color: #3f8a14;
    border-color: #65c723;
    box-shadow: 0 6px 16px rgba(101, 199, 35, 0.35);
}

@keyframes caduta {
    0% {
        top: -3rem;
        opacity: 1;
        transform: rotate(0deg);
    }
    85% {
        opacity: 1;
    }
    100% {
        top: 105vh;
        opacity: 0;
        transform: rotate(var(--rotazione, 20deg));
    }
}

/* --- Pagina di login --- */
body.pagina-login {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, var(--navy), var(--navy-chiaro) 45%, var(--blu-scuro) 100%);
    background-size: 220% 220%;
    animation: mareaNavy 14s ease infinite;
    position: relative;
    overflow: hidden;
}

@keyframes mareaNavy {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.sfondo-login {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.sfondo-login .pallone {
    position: absolute;
    font-size: 2.5rem;
    opacity: 0.18;
    animation: fluttua 9s ease-in-out infinite;
}

.sfondo-login .pallone:nth-child(1) { left: 8%;  top: 15%; animation-duration: 8s; }
.sfondo-login .pallone:nth-child(2) { left: 80%; top: 25%; animation-duration: 10s; animation-delay: 1s; }
.sfondo-login .pallone:nth-child(3) { left: 20%; top: 70%; animation-duration: 11s; animation-delay: 2s; }
.sfondo-login .pallone:nth-child(4) { left: 68%; top: 75%; animation-duration: 7.5s; animation-delay: 0.5s; }

@keyframes fluttua {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-30px) rotate(180deg); }
}

.contenitore-login {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    z-index: 1;
}

.login-scheda {
    max-width: 360px;
    width: 100%;
    text-align: center;
    animation: comparsaCarta 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes comparsaCarta {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.logo-login {
    margin: 0;
    font-size: 2rem;
    color: var(--navy);
}

.sottotitolo-login {
    color: var(--grigio-testo);
    margin: 0 0 1.25rem;
}

body.pagina-login footer {
    position: relative;
    z-index: 1;
    color: rgba(255, 255, 255, 0.85);
}

/* --- Tabelle scrollabili in orizzontale su schermi stretti --- */
.tabella-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
}

.tabella-scroll table.calendario {
    min-width: 640px;
}

.tabella-scroll table.elenco {
    min-width: 480px;
}

/* --- Azioni area admin --- */
.azioni-admin {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.azioni-admin form {
    display: inline;
    margin: 0;
}

.link-azione {
    display: inline-block;
    color: var(--blu-scuro);
    background: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.35rem 0.7rem;
    border-radius: 6px;
    border: 1px solid var(--grigio-bordo);
    cursor: pointer;
    transition: background 0.2s ease;
}

.link-azione:hover {
    background: #eef3ff;
}

.link-azione-rossa {
    color: var(--rosso);
    border-color: #f6c6cf;
}

.link-azione-rossa:hover {
    background: #fdeced;
}

@media (max-width: 640px) {
    header {
        padding: 1.5rem 1rem 1.25rem;
    }

    header h1 {
        font-size: 1.7rem;
    }

    .logo-icona {
        width: 2.2rem;
        height: 2.2rem;
        font-size: 1.4rem;
    }

    main {
        margin: 1rem auto;
    }

    .scheda {
        padding: 1rem;
    }

    .banner-info {
        font-size: 0.85rem;
    }

    table.calendario td {
        height: auto;
        min-height: 3.5rem;
        font-size: 0.75rem;
    }

    .badge {
        font-size: 0.62rem;
        padding: 0.15rem 0.4rem;
    }

    .riga-data {
        flex-wrap: wrap;
    }

    .riga-data input[type="date"] {
        flex: 1 1 45%;
        min-width: 0;
    }

    .riga-data span {
        flex-basis: 100%;
        order: 3;
    }

    .invia,
    #aggiungi-riga {
        width: 100%;
        text-align: center;
    }

    .nav-mese {
        font-size: 0.9rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
