/* ---------------------------------------------------------
   BARRA DI SELEZIONE VISTE
--------------------------------------------------------- */
#agenda-view-switcher {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 12px 0;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 100;
}

.view-icon {
    font-size: 28px;
    cursor: pointer;
    color: #9ca3af;
    transition: 0.2s;
}

.view-icon.active {
    color: #2563eb;
    transform: scale(1.15);
}

@media (max-width: 1024px) {
    #agenda-view-switcher {
        position: fixed;
        bottom: 0;
        top: auto;
        width: 100%;
        border-top: 1px solid #e5e7eb;
        border-bottom: none;
        padding: 10px 0;
        z-index: 9999;
    }
}

/* ---------------------------------------------------------
   CONTENITORE PRINCIPALE
--------------------------------------------------------- */
#agenda-container {
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100%;
    overflow-x: hidden;
}

#agenda-back-home {
    display: block;
    margin: 0 0 15px 0 !important;
    padding: 0 !important;
    font-size: 18px;
    color: #2563eb;
    text-decoration: none;
}

/* ---------------------------------------------------------
   POPUP GENERALE
--------------------------------------------------------- */
.popup {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    touch-action: none;
    overscroll-behavior: none;
    z-index: 10000;
}

.popup.hidden {
    display: none !important;
}

.popup-content {
    background: white;
    margin: 0 auto;
    width: 95%;
    max-width: 520px;
    max-height: 100vh;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    padding: 0;
    overflow: hidden;
    pointer-events: auto;
    box-sizing: border-box;
}

.popup-scroll {
    padding: 25px;
    padding-bottom: 140px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

.popup-bottom-spacer {
    height: 160px;
    flex-shrink: 0;
}

.popup-content input,
.popup-content select,
.popup-content textarea {
    font-size: 16px;
    width: 100%;
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-sizing: border-box;
}

.popup-content input[type="date"],
.popup-content input[type="time"] {
    text-align: center;
}

.popup-content label {
    font-weight: 600;
    margin-top: 12px;
    margin-bottom: 4px;
    display: block;
}

button {
    padding: 10px 15px;
    border: none;
    background: #2563eb;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    margin-right: 10px;
}

button.close-popup {
    background: #9ca3af;
}

@media (max-width: 768px) {
    .popup-scroll {
        padding: 20px;
        padding-bottom: 120px;
        max-height: 90vh;
    }
}

body.popup-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
}

/* ---------------------------------------------------------
   VISTA MENSILE
--------------------------------------------------------- */
#monthly-header {
    position: relative;
    margin-bottom: 50px;
    height: 40px;
}

#prev-month,
#next-month {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

#prev-month { left: 0; }
#next-month { right: 0; }

#monthly-header h2 {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    color: #2563eb;
    font-size: 22px;
    font-weight: 600;
}

#monthly-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: bold;
    margin-bottom: 10px;
    color: #374151;
}

#monthly-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
}

.day-cell {
    background: white;
    border-radius: 8px;
    padding: 3px 4px;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    min-height: 95px;
}

.day-cell.other-month {
    color: #9ca3af;
}

.day-number {
    font-weight: bold;
    margin-bottom: 6px;
}

.events-list {
    margin-top: 2px;
    max-height: 70px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.event-item {
    font-size: 12px;
    padding: 4px 6px;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-item.more-events {
    pointer-events: auto;
    background: #6b7280 !important;
    font-weight: 600;
}

/* ---------------------------------------------------------
   VISTA SETTIMANALE
--------------------------------------------------------- */
.weekly-title {
    text-align: center;
    width: 100%;
    margin: 0 auto 20px auto;
}

#weekly-calendar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
    width: 100%;
    margin: 0 auto;
}

.week-day-column {
    flex: 0 1 380px;
    background: white;
    border-radius: 10px;
    padding: 10px;
    border: 1px solid #e5e7eb;
    margin: 0 auto;
}

.week-day-column h3 {
    text-align: center;
    font-size: 1.05rem;
    margin-bottom: 10px;
}

.week-day-column .event-item {
    color: white;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
}

.no-events {
    color: #6b7280;
    font-size: 13px;
    padding: 6px;
    text-align: center;
}

/* ---------------------------------------------------------
   VISTA GIORNALIERA
--------------------------------------------------------- */
#view-daily {
    padding: 20px;
}

#daily-title {
    font-size: 22px;
    font-weight: 600;
    color: #2563eb;
    margin-bottom: 20px;
}

#daily-events .event-item {
    color: white;
    padding: 28px;
    font-size: 18px;
    border-radius: 10px;
    margin-bottom: 12px;
    cursor: pointer;
}

#daily-events .event-item .time {
    font-weight: bold;
    margin-bottom: 4px;
}

/* ---------------------------------------------------------
   VISTA LISTA EVENTI
--------------------------------------------------------- */
#event-list div {
    display: block;
    background: white;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 10px;
}

/* ---------------------------------------------------------
   POPUP EVENTO
--------------------------------------------------------- */
.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.popup-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: #2563eb;
    color: white;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    border: none;
}

.icon-btn.delete {
    background: #dc2626;
}

#event-details p {
    margin: 8px 0;
    font-size: 15px;
}

.save-btn {
    background: #16a34a;
    color: white;
    padding: 10px;
    border-radius: 8px;
    width: 100%;
    margin-top: 10px;
    cursor: pointer;
}

/* ---------------------------------------------------------
   POPUP LISTA EVENTI DEL GIORNO
--------------------------------------------------------- */
#day-events-container .event-item {
    margin-bottom: 8px;
    font-size: 14px;
    padding: 8px;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    background: inherit;
}

html.popup-open,
body.popup-open {
    overflow: hidden !important;
    height: 100%;
}

/* ---------------------------------------------------------
   RIPRISTINO MARGINI LATERALI
--------------------------------------------------------- */
#view-monthly,
#event-list {
    padding-left: 20px;
    padding-right: 20px;
    box-sizing: border-box;
    max-width: 1200px;
    margin: 0 auto;
}

/* ---------------------------------------------------------
   FIX MOBILE — AGENDA
--------------------------------------------------------- */
@media (max-width: 600px) {

    #monthly-calendar {
        gap: 4px !important;
    }

    .day-cell {
        min-height: 70px !important;
        padding: 6px !important;
    }

    .events-list {
        max-height: 100px !important;
        gap: 3px;
    }

    .event-item {
        font-size: 11px !important;
        padding: 3px 5px !important;
    }

    #monthly-header {
        margin-bottom: 30px !important;
        height: 80px !important;
    }

    #monthly-header h2 {
        font-size: 20px !important;
    }

    #monthly-weekdays span {
        font-size: 16px !important;
    }

    .week-day-column {
        flex: 0 1 100% !important;
        margin: 0 !important;
    }

    #view-daily {
        padding: 24px !important;
    }

    #daily-title {
        font-size: 22px !important;
    }

    input[type="date"],
    input[type="time"] {
        text-align-last: center !important;
    }

    input[type="date"]::-webkit-datetime-edit,
    input[type="time"]::-webkit-datetime-edit {
        text-align: center !important;
    }

    .popup-content {
        width: 100% !important;
        max-width: 95% !important;
        border-radius: 12px !important;
    }

    .popup-scroll {
        padding: 18px !important;
        padding-bottom: 140px !important;
    }

    button,
    .save-btn {
        padding: 12px !important;
        font-size: 16px !important;
    }

    #event-list div {
        padding: 10px !important;
        font-size: 14px !important;
    }

    html, body {
        overflow-y: auto !important;
        height: auto !important;
    }

    #agenda-container {
        overflow: visible !important;
    }

    #agenda-view-switcher {
        padding: 6px 0 !important;
        gap: 20px !important;
    }

    .view-icon {
        font-size: 22px !important;
    }

    .view-icon.rubrica-icon {
        color: #1a3d6f !important; /* blu ACTIS */
    }

    .view-icon.rubrica-icon:hover {
        color: #0d2747 !important; /* blu più scuro */
        transform: scale(1.15);
    }

    .events-list {
        max-height: 80px !important;
    }

    .week-day-column .event-item {
        padding: 14px !important;
        font-size: 15px !important;
        line-height: 1.35 !important;
    }

    #daily-events .event-item {
        padding: 18px !important;
        font-size: 16px !important;
        line-height: 1.4 !important;
    }

    #daily-events .event-item .time {
        font-size: 17px !important;
        font-weight: 600 !important;
    }
}

/* ---------------------------------------------------------
   FIX AGENDA — RIMOZIONE LAYOUT ACTIS
--------------------------------------------------------- */
.alert-bell {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #ffcc00;
    color: #1A4C9A;
    padding: 8px 12px;
    border-radius: 50px;
    font-size: 20px;
    text-decoration: none;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    transition: transform 0.15s ease;
    z-index: 100;
}

.alert-bell:hover {
    transform: scale(1.08);
}

.alert-bell .badge {
    background: #ffffff;
    color: #1A4C9A;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 14px;
    margin-left: 6px;
}

.agenda-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.agenda-link {
    display: inline-block;
    padding: 12px 20px;
    background: #003366;
    color: white;
    border-radius: 10px;
    margin-top: 10px;
    text-decoration: none;
}

.rubrica-icon {
    color: #1a3d6f; /* blu ACTIS */
    cursor: pointer;
}

.rubrica-icon:hover {
    transform: scale(1.15);
    color: #0d2747; /* blu più scuro */
}
