/* =========================================
   CALENDAR BASE
========================================= */

.calendar-container {
    position: relative;
    min-height: 500px;
}

.calendar {
    position: relative;
    background: #f6f7fb;

    touch-action: pan-x pan-y;
    -webkit-overflow-scrolling: touch;
}

/* remove fundo branco pesado */
.calendar .fc {
    background: transparent;
}

/* =========================================
   TOOLBAR
========================================= */

.calendar .fc-toolbar {
    position: sticky;
    top: 0;
    z-index: 5;

    background: #f6f7fb;

    padding: 14px;

    border-bottom: 1px solid #e7ebf3;

    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* título */
.calendar .fc-toolbar-title {
    font-size: 22px !important;
    font-weight: 600;
    color: #1f2937;
}

/* grupos */
.calendar .fc-toolbar-chunk {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* botões */
.calendar .fc-button {

    display: flex !important;

    align-items: center;
    justify-content: center;

    min-height: 42px;

    border-radius: 10px !important;

    background: #fff !important;

    border: 1px solid #dce3ef !important;

    color: #374151 !important;

    box-shadow: none !important;

    padding: 0 14px !important;

    line-height: 1 !important;

    font-size: 14px !important;

    font-weight: 500 !important;

    transition: all .2s ease;
}

/* hover */
.calendar .fc-button:hover {
    background: #f3f6fb !important;
}

/* ativo */
.calendar .fc-button-active {
    background: #2d6cdf !important;
    border-color: #2d6cdf !important;
    color: #fff !important;
}

/* remove outline */
.calendar .fc-button:focus {
    box-shadow: none !important;
}

/* =========================================
   GRID
========================================= */

/* remove bordas pesadas */
.calendar .fc-scrollgrid {
    border: none !important;
}

/* linhas leves */
.calendar .fc-theme-standard td,
.calendar .fc-theme-standard th {
    border-color: #edf0f5 !important;
}

/* fundo headers */
.calendar .fc-theme-standard th {
    background: #f6f7fb !important;
}

/* linhas de horário */
.calendar .fc-timegrid-slot {
    height: 48px !important;
}

/* coluna de horários */
.calendar .fc-timegrid-axis {
    font-size: 11px;
    color: #6b7280;
}

/* =========================================
   HEADER SEMANA/DIA
========================================= */

.calendar .fc-col-header-cell {
    padding: 8px 0 !important;
    background: #f6f7fb !important;
}

/* remove underline */
.calendar .fc-col-header-cell-cushion {
    text-decoration: none !important;
    padding: 0 !important;
}

/* container */
.fc-custom-day-header {
    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    gap: 4px;

    padding: 6px 0;
}

/* nome do dia */
.fc-custom-weekday {
    font-size: 11px;
    font-weight: 600;

    color: #6b7280;

    text-transform: uppercase;

    letter-spacing: .4px;
}

/* número */
.fc-custom-day-number {
    width: 36px;
    height: 36px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    font-size: 18px;
    font-weight: 500;

    color: #111827;

    transition: all .2s ease;
}

/* hoje */
.calendar .fc-day-today .fc-custom-day-number {
    background: #2d6cdf;
    color: #fff;
}

/* =========================================
   MONTH VIEW
========================================= */

/* header mês */
.calendar .fc-daygrid .fc-col-header-cell {
    background: #f6f7fb !important;

    padding: 10px 0 !important;
}

/* texto dom seg ter */
.fc-month-weekday {
    font-size: 12px;

    font-weight: 600;

    color: #6b7280;

    text-transform: uppercase;

    text-align: center;

    padding: 8px 0;
}

/* células */
.calendar .fc-daygrid-day {
    background: #fff;

    transition: background .2s ease;
}

/* hover */
.calendar .fc-daygrid-day:hover {
    background: #f9fafb;
}

/* número do dia */
.calendar .fc-daygrid-day-number {
    width: 32px;
    height: 32px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    margin: 6px;

    font-size: 14px;
    font-weight: 500;

    color: #111827;

    text-decoration: none !important;

    transition: all .2s ease;
}

/* hoje */
.calendar .fc-day-today .fc-daygrid-day-number {
    background: #2d6cdf;
    color: #fff;
}

/* remove fundo feio */
.calendar .fc-day-today {
    background: rgba(45,108,223,0.04) !important;
}

/* =========================================
   EVENTOS
========================================= */

.calendar .fc-event {
    border: none !important;

    border-radius: 10px !important;

    font-weight: 500 !important;

    box-shadow: none !important;

    overflow: hidden;

    transition: .15s ease;
}

/* hover */
.calendar .fc-event:hover {
    opacity: .94;

    transform: scale(1.01);
}

/* semana/dia */
.calendar .fc-timegrid-event {
    min-height: 38px;

    border-radius: 10px !important;

    padding: 2px !important;
}

/* mês */
.calendar .fc-daygrid-event {
    min-height: 24px;

    display: flex;
    align-items: center;

    border-radius: 8px !important;

    padding: 2px 6px !important;

    margin: 1px 4px !important;
}

/* remove bordas */
.calendar .fc-timegrid-event,
.calendar .fc-daygrid-event {
    border: none !important;
}

/* =========================================
   EVENT CONTENT
========================================= */

.fc-modern-event {
    display: flex;

    flex-direction: column;

    gap: 2px;

    padding: 2px 4px;

    overflow: hidden;

    color: inherit;
}

/* título */
.fc-modern-event-title {
    font-size: 12px;

    font-weight: 600;

    line-height: 1.2;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;

    color: inherit;
}

/* horário */
.fc-modern-event-time {
    font-size: 10px;

    opacity: .92;

    white-space: nowrap;

    color: inherit;
}

/* mais eventos */
.calendar .fc-daygrid-more-link {
    color: #2d6cdf !important;

    font-size: 11px;

    font-weight: 600;

    margin-left: 6px;
}

/* =========================================
   TODAY
========================================= */

.calendar .fc-day-today {
    background: rgba(45,108,223,0.04) !important;
}

/* =========================================
   MENU
========================================= */

.calendar-menu {
    position: fixed !important;

    top: 60px !important;
    right: 15px !important;

    background: #fff;

    border-radius: 12px;

    box-shadow: 0 8px 24px rgba(0,0,0,0.12);

    display: none;

    z-index: 9999 !important;

    padding: 8px;

    min-width: 160px;
}

.calendar-menu button {
    display: block;

    width: 100%;

    padding: 12px;

    border: none;

    background: none;

    text-align: left;

    font-size: 14px;

    cursor: pointer;

    border-radius: 8px;

    transition: background .2s;
}

.calendar-menu button:hover {
    background: #f3f6fb;
}

/* =========================================
   LOADING
========================================= */

.calendar-loading {
    position: absolute;

    inset: 0;

    background: rgba(255,255,255,0.92);

    display: none;

    justify-content: center;
    align-items: center;

    z-index: 999;
}

.calendar-loading.active {
    display: flex !important;
}

.calendar-loading-spinner {
    width: 42px;
    height: 42px;

    border: 4px solid #e5e7eb;
    border-top: 4px solid #2d6cdf;

    border-radius: 50%;

    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* =========================================
   MOBILE
========================================= */

@media (max-width: 768px) {

    .calendar .fc-toolbar {
        flex-direction: column;

        align-items: stretch;

        padding: 10px;
    }

    .calendar .fc-toolbar-chunk {
        width: 100%;

        justify-content: center;

        flex-wrap: wrap;
    }

    .calendar .fc-button {
        flex: 1;
        min-height: 40px;
        padding: 0 8px !important;
        font-size: 12px !important;
    }

    /* garante que os botões Dia/Semana/Mês fiquem lado a lado no mobile */
    .calendar .fc-toolbar-chunk:last-child {
        display: flex;
        flex-direction: row;
        justify-content: center;
        gap: 4px;
    }

    .calendar .fc-toolbar-chunk:last-child .fc-button {
        flex: 1;
        max-width: 100px;
    }

    .calendar .fc-toolbar-title {
        text-align: center;

        font-size: 18px !important;
    }

    /* semana/dia */
    .fc-custom-weekday {
        font-size: 10px;
    }

    .fc-custom-day-number {
        width: 30px;
        height: 30px;

        font-size: 15px;
    }

    /* horários */
    .calendar .fc-timegrid-slot {
        height: 42px !important;
    }

    .calendar .fc-timegrid-axis {
        font-size: 10px;
    }

    /* mês */
    .calendar .fc-daygrid-day {
        min-height: 70px !important;
    }

    .calendar .fc-daygrid-day-number {
        width: 28px;
        height: 28px;

        font-size: 13px;

        margin: 4px;
    }

    .calendar .fc-daygrid-event {
        font-size: 10px !important;

        padding: 1px 4px !important;
    }

    .fc-month-weekday {
        font-size: 10px;
    }

    /* eventos */
    .fc-modern-event-title {
        font-size: 11px;
    }

    .fc-modern-event-time {
        font-size: 9px;
    }

    .calendar .fc-timegrid-event {
        min-height: 34px;
    }

    /* garante que card-body não corte o calendário com scroll interno */
    .calendar-container {
        min-height: 0 !important;
        overflow: visible;
    }

    /* remove padding lateral excessivo no card do calendário em mobile */
    .card-body .calendar-container {
        margin: -8px;
    }

    /* permite que o calendário com altura fixa expanda corretamente */
    .card.h-100 {
        height: auto !important;
    }
}

/* header dos dias */
.calendar .fc-scrollgrid-section-sticky > * {
    z-index: 4 !important;
}

/* scrollgrid sticky */
.calendar .fc-scrollgrid-section-header {
    z-index: 4 !important;
}

/* evita ficar acima de sidebar/modal */
.calendar .fc-sticky {
    z-index: 4 !important;
}

/* =========================================
   SIDEBAR OVERLAY — garante sidebar acima do calendário
========================================= */

/* Quando o sidebar mobile estiver aberto, eleva o sidebar acima de todos os elementos do calendário */
body.overlay-active .sidebar {
    z-index: 10000 !important;
}

/* Rebaixa os elementos sticky/fixed do calendário para não bloquearem o sidebar */
body.overlay-active .calendar .fc-toolbar,
body.overlay-active .calendar .fc-scrollgrid-section-sticky > *,
body.overlay-active .calendar .fc-scrollgrid-section-header,
body.overlay-active .calendar .fc-sticky {
    z-index: 1 !important;
}