/**
 * NMB Manager — calendar grid styles.
 *
 * Lightweight layer on top of FullCalendar's own bundled CSS. Just the bits we
 * need: container sizing so the grid sits nicely inside the admin + portal
 * chrome, and the colour-coded type legend.
 *
 * Type colours mirror NMB_Finance_Calendar_Feed::COLORS:
 *   match = #0a4d8c · training = #16a34a · tournament = #7c3aed · event = #ea580c
 */

.nmb-calendar-wrap {
    background: var(--nmb-surface, #ffffff);
    border: 1px solid var(--nmb-border, #e2e8f0);
    border-radius: var(--nmb-radius, 10px);
    padding: 16px;
    box-shadow: var(--nmb-shadow, 0 1px 3px rgba(15, 23, 42, .06));
}

#nmb-calendar {
    /* FullCalendar reads --fc-* custom props; align them with our tokens. */
    --fc-border-color: var(--nmb-border, #e2e8f0);
    --fc-today-bg-color: color-mix( in srgb, var(--nmb-primary, #0a4d8c) 8%, transparent );
    --fc-button-bg-color: var(--nmb-primary, #0a4d8c);
    --fc-button-border-color: var(--nmb-primary, #0a4d8c);
    --fc-button-hover-bg-color: color-mix( in srgb, var(--nmb-primary, #0a4d8c) 88%, black );
    --fc-button-hover-border-color: color-mix( in srgb, var(--nmb-primary, #0a4d8c) 88%, black );
    --fc-button-active-bg-color: color-mix( in srgb, var(--nmb-primary, #0a4d8c) 78%, black );
    font-size: 14px;
}

#nmb-calendar .fc .fc-toolbar-title {
    font-size: 18px;
    font-weight: 600;
}

#nmb-calendar .fc .fc-button {
    text-transform: none;
    font-weight: 500;
    box-shadow: none;
}

#nmb-calendar .fc-event {
    border: none;
    cursor: pointer;
    font-weight: 500;
}

#nmb-calendar .fc-event[href=""],
#nmb-calendar .fc-event:not([href]) {
    cursor: default;
}

/* -- Type legend ------------------------------------------------------- */
.nmb-cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    margin: 0 0 14px;
    font-size: 13px;
}

.nmb-cal-legend__chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--nmb-text, #0f172a);
}

.nmb-cal-legend__swatch {
    width: 13px;
    height: 13px;
    border-radius: 3px;
    display: inline-block;
    flex: 0 0 auto;
}

.nmb-cal-legend__swatch--match      { background: #0a4d8c; }
.nmb-cal-legend__swatch--training   { background: #16a34a; }
.nmb-cal-legend__swatch--tournament { background: #7c3aed; }
.nmb-cal-legend__swatch--event      { background: #ea580c; }

/* -- List / Calendar toggle -------------------------------------------- */
.nmb-view-toggle {
    display: inline-flex;
    border: 1px solid var(--nmb-border, #cbd5e1);
    border-radius: 8px;
    overflow: hidden;
    margin: 0 0 18px;
}

.nmb-view-toggle a {
    display: inline-block;
    padding: 8px 16px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--nmb-text, #0f172a);
    background: var(--nmb-surface, #ffffff);
}

.nmb-view-toggle a + a {
    border-left: 1px solid var(--nmb-border, #cbd5e1);
}

.nmb-view-toggle a.is-active {
    background: var(--nmb-primary, #0a4d8c);
    color: #fff;
}

/* -- Public calendar: toolbar (legend + "my events" toggle) ------------ */
.nmb-public-calendar { max-width: 1100px; margin: 0 auto; }

.nmb-cal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 18px;
    margin: 0 0 16px;
}
.nmb-cal-toolbar .nmb-cal-legend { margin: 0; }

/* "Show only my events" toggle switch. */
.nmb-cal-scope {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--nmb-text, #0f172a);
    user-select: none;
}
.nmb-cal-scope__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.nmb-cal-scope__track {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background .15s ease;
    flex: 0 0 auto;
}
.nmb-cal-scope__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba( 0, 0, 0, .25 );
    transition: transform .15s ease;
}
.nmb-cal-scope__input:checked + .nmb-cal-scope__track {
    background: var(--nmb-primary, #0a4d8c);
}
.nmb-cal-scope__input:checked + .nmb-cal-scope__track .nmb-cal-scope__thumb {
    transform: translateX( 18px );
}
.nmb-cal-scope__input:focus-visible + .nmb-cal-scope__track {
    outline: 2px solid var(--nmb-primary, #0a4d8c);
    outline-offset: 2px;
}

/* -- Mobile: stack the FullCalendar header so it never overflows -------- */
@media ( max-width: 640px ) {
    #nmb-calendar .fc-toolbar.fc-header-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-bottom: 10px;
    }
    #nmb-calendar .fc-toolbar-chunk {
        display: flex;
        justify-content: center;
    }
    #nmb-calendar .fc .fc-toolbar-title { font-size: 16px; }
    #nmb-calendar .fc .fc-button { padding: 6px 9px; font-size: 13px; }
    .nmb-calendar-wrap { padding: 12px; }
    .nmb-cal-toolbar { justify-content: flex-start; }
}
