/* =====================================================================
   Calendar — friendly skin (FullCalendar v5 + custom calendars)
   Applied globally via layouts/partials/header.blade.php
   ===================================================================== */

:root {
    --cal-primary: #4f7dff;
    --cal-primary-soft: #eaf0ff;
    --cal-today: #fff7e0;
    --cal-today-border: #f5b942;
    --cal-weekend: #f7f9fc;
    --cal-grid: #e9ecf2;
    --cal-text: #2d3142;
    --cal-muted: #8b91a4;
    --cal-shadow: 0 4px 14px rgba(48, 65, 130, 0.08);
    --cal-radius: 12px;
    --cal-radius-sm: 8px;
}

/* --------- Outer wrapper (cards holding the calendar) ---------- */
.fc {
    font-family: inherit;
    color: var(--cal-text);
    --fc-border-color: var(--cal-grid);
    --fc-today-bg-color: var(--cal-today);
    --fc-page-bg-color: #ffffff;
    --fc-neutral-bg-color: var(--cal-weekend);
    --fc-list-event-hover-bg-color: var(--cal-primary-soft);
}

#timetable,
#examCalender,
#calendar,
.fc {
    background: #ffffff;
    border-radius: var(--cal-radius);
    box-shadow: var(--cal-shadow);
    padding: 14px 16px 18px;
}

/* --------- Header toolbar ---------- */
.fc .fc-toolbar.fc-header-toolbar {
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 8px;
}

.fc .fc-toolbar-title {
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: var(--cal-text);
    text-transform: capitalize;
}

.fc .fc-button {
    background: #ffffff;
    color: var(--cal-text);
    border: 1px solid var(--cal-grid);
    border-radius: var(--cal-radius-sm);
    padding: 0.42rem 0.85rem;
    font-weight: 500;
    box-shadow: none;
    transition: all .15s ease;
    text-transform: capitalize;
}

.fc .fc-button:hover {
    background: var(--cal-primary-soft);
    color: var(--cal-primary);
    border-color: var(--cal-primary);
}

.fc .fc-button:focus,
.fc .fc-button:focus-visible {
    box-shadow: 0 0 0 3px rgba(79, 125, 255, 0.18);
    outline: none;
}

.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active {
    background: var(--cal-primary);
    border-color: var(--cal-primary);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(79, 125, 255, 0.35);
}

.fc .fc-button-primary:disabled {
    background: #f1f3f8;
    color: var(--cal-muted);
    border-color: var(--cal-grid);
}

.fc .fc-button-group > .fc-button {
    border-radius: 0;
}
.fc .fc-button-group > .fc-button:first-child { border-top-left-radius: var(--cal-radius-sm); border-bottom-left-radius: var(--cal-radius-sm); }
.fc .fc-button-group > .fc-button:last-child  { border-top-right-radius: var(--cal-radius-sm); border-bottom-right-radius: var(--cal-radius-sm); }

.fc .fc-button .fc-icon { font-size: 1.1em; }

/* --------- Day headers ---------- */
.fc .fc-col-header-cell {
    background: var(--cal-primary-soft);
    border-color: var(--cal-grid);
}

.fc .fc-col-header-cell-cushion {
    padding: 10px 6px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--cal-primary);
    text-decoration: none;
    text-transform: capitalize;
    letter-spacing: 0.3px;
}

/* --------- Day grid (month view) ---------- */
.fc .fc-daygrid-day {
    transition: background-color .15s ease;
}

.fc .fc-daygrid-day:hover {
    background: rgba(79, 125, 255, 0.04);
}

.fc .fc-daygrid-day-number {
    padding: 6px 8px;
    font-weight: 500;
    color: var(--cal-text);
    text-decoration: none;
}

/* Weekend tint */
.fc .fc-day-sat,
.fc .fc-day-sun {
    background-color: var(--cal-weekend);
}

/* Today badge */
.fc .fc-day-today {
    background: var(--cal-today) !important;
    position: relative;
}

.fc .fc-day-today .fc-daygrid-day-number,
.fc .fc-day-today .fc-col-header-cell-cushion {
    color: #b8740b;
    font-weight: 700;
}

.fc .fc-daygrid-day.fc-day-today .fc-daygrid-day-top .fc-daygrid-day-number {
    background: var(--cal-today-border);
    color: #ffffff !important;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    line-height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 4px;
    box-shadow: 0 2px 6px rgba(245, 185, 66, 0.4);
}

/* Other-month days dimmed */
.fc .fc-day-other .fc-daygrid-day-number {
    color: var(--cal-muted);
    opacity: 0.55;
}

/* --------- Events ---------- */
.fc .fc-event {
    border: none;
    border-radius: var(--cal-radius-sm);
    padding: 3px 6px;
    margin: 2px 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
    font-size: 0.78rem;
    line-height: 1.25;
    cursor: pointer;
}

.fc .fc-event:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.14);
    filter: brightness(1.05);
}

.fc .fc-event-main {
    padding: 2px 2px;
    color: inherit;
    overflow: auto;
}

.fc .fc-event-title,
.fc .fc-event-title-container {
    font-weight: 600;
    white-space: normal;
}

.fc .fc-event-time {
    font-weight: 500;
    opacity: 0.92;
}

/* TimeGrid events (week/day view) */
.fc-timegrid-event .fc-event-main {
    padding: 4px 6px;
}

.fc-timegrid-event-harness > .fc-timegrid-event {
    border-left: 4px solid rgba(255, 255, 255, 0.4);
}

/* Now indicator (red line) */
.fc .fc-timegrid-now-indicator-line {
    border-color: #ff5b5b;
    border-width: 2px;
}
.fc .fc-timegrid-now-indicator-arrow {
    border-color: #ff5b5b;
    border-width: 6px 0 6px 6px;
}

/* --------- Time slots ---------- */
.fc .fc-timegrid-slot {
    height: 2.5rem;
    border-color: var(--cal-grid);
}

.fc .fc-timegrid-slot-label-cushion,
.fc .fc-timegrid-axis-cushion {
    font-size: 0.78rem;
    color: var(--cal-muted);
    font-weight: 500;
    padding: 2px 6px;
}

/* Alternating slot tint */
.fc .fc-timegrid-slot-lane {
    background: transparent;
}
.fc .fc-timegrid-slot-minor {
    border-top-style: dotted;
}

/* Business hours highlight (inverse) */
.fc .fc-non-business {
    background: rgba(0, 0, 0, 0.025);
}

/* --------- More-link popover ---------- */
.fc .fc-more-link {
    color: var(--cal-primary);
    font-weight: 600;
    text-decoration: none;
    padding: 2px 6px;
    border-radius: 6px;
}
.fc .fc-more-link:hover {
    background: var(--cal-primary-soft);
}

.fc .fc-popover {
    border-radius: var(--cal-radius);
    border: 1px solid var(--cal-grid);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}
.fc .fc-popover-header {
    background: var(--cal-primary-soft);
    color: var(--cal-primary);
    padding: 8px 10px;
    font-weight: 600;
}

/* --------- List view ---------- */
.fc .fc-list {
    border-radius: var(--cal-radius);
    overflow: hidden;
}
.fc .fc-list-day-cushion {
    background: var(--cal-primary-soft);
    color: var(--cal-primary);
    font-weight: 600;
}
.fc .fc-list-event:hover td {
    background: var(--cal-primary-soft);
}
.fc .fc-list-event-dot {
    border-width: 6px;
}

/* --------- External events (drag source — exam calendar) ---------- */
.external-event,
.fc-event.external-event {
    border-radius: var(--cal-radius-sm);
    padding: 6px 10px;
    margin: 4px 0;
    cursor: grab;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform .12s ease, box-shadow .12s ease;
}
.external-event:hover,
.fc-event.external-event:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.16);
}
.external-event:active,
.fc-event.external-event:active {
    cursor: grabbing;
}

#external-events,
#groupes {
    overflow: auto;
    max-height: 260px;
    padding: 4px;
    background: #fafbfd;
    border-radius: var(--cal-radius-sm);
}

/* --------- Scrollbars inside calendar areas ---------- */
.fc ::-webkit-scrollbar,
#external-events::-webkit-scrollbar,
#groupes::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.fc ::-webkit-scrollbar-track,
#external-events::-webkit-scrollbar-track,
#groupes::-webkit-scrollbar-track {
    background: #f3f5f9;
    border-radius: 8px;
}
.fc ::-webkit-scrollbar-thumb,
#external-events::-webkit-scrollbar-thumb,
#groupes::-webkit-scrollbar-thumb {
    background: #c5cbdb;
    border-radius: 8px;
}
.fc ::-webkit-scrollbar-thumb:hover,
#external-events::-webkit-scrollbar-thumb:hover,
#groupes::-webkit-scrollbar-thumb:hover {
    background: var(--cal-primary);
}

/* --------- Responsive ---------- */
@media (max-width: 768px) {
    #timetable,
    #examCalender,
    #calendar,
    .fc {
        padding: 8px 6px 12px;
        border-radius: var(--cal-radius-sm);
    }

    .fc .fc-toolbar.fc-header-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        margin-bottom: 10px;
    }
    .fc .fc-toolbar-title {
        font-size: 0.95rem;
        text-align: center;
    }
    .fc .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
    }
    .fc .fc-button {
        padding: 0.32rem 0.6rem;
        font-size: 0.8rem;
    }
    .fc .fc-event {
        font-size: 0.7rem;
        padding: 2px 4px;
    }
    .fc .fc-col-header-cell-cushion {
        padding: 6px 2px;
        font-size: 0.72rem;
    }
    .fc .fc-timegrid-slot {
        height: 2rem;
    }
    .fc .fc-daygrid-day-number {
        padding: 3px 5px;
        font-size: 0.78rem;
    }
}

@media (max-width: 480px) {
    .fc .fc-toolbar-title {
        font-size: 0.85rem;
    }
    .fc .fc-event-main {
        font-size: 0.68rem;
    }
}

/* --------- Print ---------- */
@media print {
    #timetable,
    #examCalender,
    #calendar,
    .fc {
        box-shadow: none;
        padding: 0;
    }
    .fc .fc-button-group { display: none !important; }
}

/* --------- Dark sidebar / dark theme variant ---------- */
body[data-bs-theme="dark"] {
    --cal-primary-soft: #1f2940;
    --cal-today: #3a2d10;
    --cal-weekend: #1b2032;
    --cal-grid: #2c3349;
    --cal-text: #e5e8f0;
    --cal-muted: #99a0b7;
}

body[data-bs-theme="dark"] #timetable,
body[data-bs-theme="dark"] #examCalender,
body[data-bs-theme="dark"] #calendar,
body[data-bs-theme="dark"] .fc {
    background: #232a3d;
}

body[data-bs-theme="dark"] .fc .fc-button {
    background: #2a3149;
    color: var(--cal-text);
    border-color: var(--cal-grid);
}

body[data-bs-theme="dark"] .fc .fc-col-header-cell {
    background: #2a3149;
}
