/* Calendario - layout verticale compatto */
.sample-calendar {
    width: 100%;
    max-width: 100%; /* limita la larghezza */
    display: flex;
    flex-direction: column; /* verticale */
    text-align: center;
    position: relative;
    margin: 0 auto;
    overflow: visible; /* serve per tooltip */
    border-radius: 6px;
    box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.13);
}

.wrap-header {
    position: relative;
    width: 100%; /* piena larghezza */
    max-width: 100%;
    min-width: unset;
    background: #20437b;
    padding: 0.6rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: row; /* frecce + data in riga */
    align-items: center;
    justify-content: space-between;
    border-radius: 6px 6px 0 0;
}

#header-cal {
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sample-calendar #header-cal .pre-button,
.sample-calendar #header-cal .next-button {
    cursor: pointer;
    width: 1.4em;
    height: 1.4em;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pre-button {
    left: 0;
    color: #fff;
}

.next-button {
    right: 0;
    color: #fff;
}

.head-info {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    justify-content: center;
}

.head-day {
    font-size: 1.8em;
    line-height: 1;
    color: #fff;
    font-weight: 700;
}

.head-month {
    font-size: 0.72em;
    line-height: 1;
    color: rgba(255,255,255,0.85);
    text-transform: uppercase;
    font-weight: 600;
}

.calendar-wrap {
    flex: 1;
    background: #fff;
    padding: 6px 8px;
    border-radius: 0 0 6px 6px;
    min-width: 0;
}

.sample-calendar #calendar {
    width: 100%;
}

#calendar tr {
    height: 2.2em;
    border: none;
}

#calendar th {
    text-align: center;
    font-weight: 700;
    color: #20437b;
    background: transparent;
    font-size: 0.75rem;
    padding: 5px 0;
    border: none;
}

#calendar thead tr {
    color: #20437b;
    font-weight: 700;
}

#calendar tbody tr {
    border: none;
    background: transparent;
}

#calendar tbody td {
    text-align: center;
    width: 14%;
    cursor: pointer;
    transition: all 0.2s ease-in;
    position: relative;
    z-index: 0;
    isolation: isolate; /* ← AGGIUNGI QUESTO */
    font-size: 0.85rem;
    color: #20437b;
    padding: 1px 0;
}

    #calendar tbody td:after {
        position: absolute;
        top: 50%;
        left: 0;
        right: 0;
        bottom: 0;
        content: '';
        width: 26px;
        height: 26px;
        margin: 0 auto;
        transform: translateY(-50%);
        border-radius: 50%;
        transition: 0.3s;
        z-index: -1; /* ora è -1 dentro il contesto isolato del td, non della pagina */
    }

@media (prefers-reduced-motion: reduce) {
    #calendar tbody td:after {
        transition: none;
    }
}

#calendar tbody td:hover,
.selected {
    color: #fff;
    border: none;
}

    #calendar tbody td:hover:after,
    .selected:after {
        background: #20437b;
    }

#calendar tbody td:active {
    transform: scale(0.7);
}

.activity {
    color: #fff;
/*    border: none;
*/}

    .activity:after {
        background: #20437b;
    }

#today {
    color: #20437b;
}

    #today:after {
        background: #ffc107;
    }

#disabled {
    cursor: default;
    background: #fff;
}

    #disabled:hover {
        background: #fff;
        color: #c9c9c9;
    }

        #disabled:hover:after {
            background: transparent;
        }

#reset {
    display: block;
    position: absolute;
    right: 3.2em;
    top: 0.4em;
    z-index: 999;
    color: #fff;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 4px;
    text-transform: uppercase;
    font-size: 7px;
    padding: 1px 4px;
    font-weight: 600;
    outline-offset: 2px;
    margin: 0;
    line-height: 1.4;
}

    #reset:hover {
        border-color: #fff;
    }

    #reset:focus-visible {
        outline: 2px solid #fff;
    }

#calendar tbody td:focus-visible {
    outline: 2px solid #20437b;
    outline-offset: 2px;
}

/* Mobile: già verticale, solo aggiustiamo max-width */
@media (max-width: 767px) {
    .sample-calendar {
        max-width: 320px; /* era 260px */
    }

    #calendar th,
    #calendar tbody td {
        font-size: 0.82rem;
        isolation: isolate;
    }
}

/* Forza il colore bianco sul numero dentro activity */
#calendar tbody td.activity {
    color: #fff !important;
    isolation: isolate;
}

    #calendar tbody td.activity:after {
        background: #20437b;
        content: '';
        position: absolute;
        top: 50%;
        left: 0;
        right: 0;
        width: 26px;
        height: 26px;
        margin: 0 auto;
        transform: translateY(-50%);
        border-radius: 50%;
        z-index: -1;
    }

/* Mobile: previeni overflow orizzontale */
@media (max-width: 767px) {
    .sample-calendar {
        max-width: 100%;
        width: 100%;
    }

    #calendar {
        table-layout: fixed;
        width: 100%;
    }

        #calendar th,
        #calendar tbody td {
            font-size: 0.75rem;
            padding: 1px 0;
            word-break: break-all;
        }
}