/* ============================================
   Timeline v2 — scoped under .timeline-container
   ============================================ */

.timeline-container {
    --tl-primary: #076FC6;
    --tl-primary-dark: #055a9f;
    --tl-accent: #F58220;
    --tl-accent-dark: #D96A0A;
    --tl-accent-light: #FFF3E6;
    --tl-success: #079455;
    --tl-success-bg: #DCFAE6;
    --tl-error: #D92D20;
    --tl-error-bg: #FEE4E2;
    --tl-border: #D5D7DA;
    --tl-bg-card: #fff;
    --tl-bg: #F5F7FA;
    --tl-text: #181D27;
    --tl-text-muted: #414651;
    --tl-text-subtle: #717680;
    --tl-axis-idle: #B9C5D1;
    --tl-shadow-sm: 0 1px 2px rgba(10, 13, 18, 0.05);
    --tl-shadow-md: 0 4px 12px rgba(10, 13, 18, 0.08);
    --tl-shadow-accent: 0 4px 14px rgba(245, 130, 32, 0.28);
}

/* ----- Filters accordion ----- */
.filters-accordion {
    background: var(--tl-bg-card);
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: var(--tl-shadow-sm);
    overflow: hidden;
}
.filters-accordion__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    cursor: pointer;
    user-select: none;
    gap: 16px;
    list-style: none;
}
.filters-accordion__trigger::-webkit-details-marker { display: none; }
.filters-accordion__trigger:hover { background: var(--tl-accent-light); }
.filters-accordion__label {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    color: var(--tl-text);
}
.filters-accordion__label svg { color: var(--tl-accent); }
.filters-accordion__hint { color: var(--tl-text-subtle); font-size: 13px; font-weight: 400; }
.filters-accordion__chevron { transition: transform 0.2s; color: var(--tl-text-subtle); }
.filters-accordion[open] .filters-accordion__chevron { transform: rotate(180deg); color: var(--tl-accent); }
.filters-accordion__body {
    padding: 24px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    border-top: 1px solid var(--tl-border);
}
.filter-section__title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--tl-accent);
    letter-spacing: 0.5px;
    margin: 0 0 12px;
}
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; }
.filter-row input[type="email"],
.filter-row select {
    flex: 1 1 180px;
    padding: 10px 14px;
    border: 1px solid var(--tl-border);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}
.filter-row input[type="email"]:focus,
.filter-row select:focus {
    outline: none;
    border-color: var(--tl-accent);
    box-shadow: 0 0 0 3px rgba(245, 130, 32, 0.15);
}

/* ----- Buttons (scoped — does not override global .btn) ----- */
.timeline-container .btn--accent {
    background: var(--tl-accent);
    color: #fff;
    box-shadow: var(--tl-shadow-accent);
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.timeline-container .btn--accent:hover { background: var(--tl-accent-dark); }
.timeline-container .btn--accent:disabled { opacity: 0.5; cursor: not-allowed; }
.timeline-container .btn--sm { padding: 7px 14px; font-size: 13px; }

/* ----- Toolbar ----- */
.timeline-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px 24px;
    background: var(--tl-bg-card);
    border-radius: 12px;
    box-shadow: var(--tl-shadow-sm);
    flex-wrap: wrap;
}
.timeline-counts { display: flex; gap: 28px; font-size: 14px; }
.timeline-count { display: flex; flex-direction: column; }
.timeline-count__value { font-weight: 800; color: var(--tl-text); font-size: 20px; line-height: 1; }
.timeline-count__label { color: var(--tl-text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; font-weight: 600; }
.timeline-count--success .timeline-count__value { color: var(--tl-success); }
.timeline-count--error .timeline-count__value { color: var(--tl-error); }

.toggle-switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle-switch input { display: none; }
.toggle-switch__track {
    width: 42px; height: 24px;
    background: #D5D7DA;
    border-radius: 9999px;
    position: relative;
    transition: background 0.2s;
}
.toggle-switch__track::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 20px; height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.toggle-switch input:checked + .toggle-switch__track { background: var(--tl-accent); }
.toggle-switch input:checked + .toggle-switch__track::after { transform: translateX(18px); }
.toggle-switch__label { font-size: 14px; color: var(--tl-text-muted); font-weight: 500; }

.timeline-toolbar__controls {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.timeline-sort-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--tl-border);
    border-radius: 8px;
    background: #fff;
    color: var(--tl-text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.timeline-sort-toggle:hover {
    border-color: var(--tl-accent);
    color: var(--tl-accent-dark);
    background: var(--tl-accent-light);
}
.timeline-sort-toggle__icon { transition: transform 0.2s; }
.timeline-v2[data-sort="asc"] ~ * .timeline-sort-toggle__icon,
[data-sort="asc"] .timeline-sort-toggle__icon { transform: rotate(180deg); }

/* ----- Zig-zag timeline (desktop) ----- */
.timeline-v2 {
    position: relative;
    padding: 24px 0 40px;
}
.timeline-v2::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, var(--tl-axis-idle) 0%, var(--tl-axis-idle) 18%, var(--tl-primary) 32%, var(--tl-primary) 100%);
    transform: translateX(-50%);
    border-radius: 2px;
    z-index: 0;
}

.timeline-v2__month-group {
    /* Transparent grouping wrapper used by the sort-direction JS toggle. */
}

.timeline-v2__month-header {
    position: relative;
    z-index: 2;
    text-align: center;
    margin: 32px 0 24px;
}
.timeline-v2 > .timeline-v2__month-group:first-child .timeline-v2__month-header { margin-top: 0; }
.timeline-v2__month-label {
    display: inline-block;
    background: var(--tl-primary);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 6px 18px;
    border-radius: 9999px;
    box-shadow: var(--tl-shadow-md);
}
.timeline-v2__month-header--current .timeline-v2__month-label {
    background: var(--tl-accent);
    box-shadow: var(--tl-shadow-accent);
}
.timeline-v2__month-header--expired .timeline-v2__month-label {
    background: var(--tl-axis-idle);
    color: #fff;
    box-shadow: none;
}

.timeline-v2__item {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 120px 1fr;
    align-items: center;
    gap: 0;
    margin-bottom: 36px;
    z-index: 1;
}
.timeline-v2__item:last-child { margin-bottom: 0; }

.timeline-v2__date {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
    width: 84px;
    height: 84px;
    background: #fff;
    border: 5px solid var(--tl-primary);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 3;
    box-shadow: var(--tl-shadow-md);
}
.timeline-v2__date--active {
    border-color: var(--tl-accent);
    box-shadow: var(--tl-shadow-accent);
}
.timeline-v2__date--expired {
    border-color: var(--tl-axis-idle);
    background: #F4F5F7;
    box-shadow: none;
}
.timeline-v2__date__day {
    font-size: 22px;
    font-weight: 800;
    color: var(--tl-text);
    line-height: 1;
}
.timeline-v2__date--active .timeline-v2__date__day { color: var(--tl-accent-dark); }
.timeline-v2__date--expired .timeline-v2__date__day { color: var(--tl-text-subtle); }
.timeline-v2__date__month {
    font-size: 12px;
    font-weight: 700;
    color: var(--tl-text-muted);
    text-transform: uppercase;
    margin-top: 4px;
}
.timeline-v2__date__label {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--tl-primary);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.timeline-v2__date--active .timeline-v2__date__label { background: var(--tl-accent); }
.timeline-v2__date--expired .timeline-v2__date__label { background: #8892A0; }

.timeline-v2__card {
    background: var(--tl-bg-card);
    border: 1px solid var(--tl-border);
    border-radius: 12px;
    box-shadow: var(--tl-shadow-sm);
    padding: 20px;
    position: relative;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
}
.timeline-v2__card:hover {
    box-shadow: var(--tl-shadow-md);
    transform: translateY(-2px);
    border-color: var(--tl-accent);
}
.timeline-v2__item--left .timeline-v2__card { grid-column: 1; grid-row: 1; margin-right: 24px; }
.timeline-v2__item--right .timeline-v2__card { grid-column: 3; grid-row: 1; margin-left: 24px; }

.timeline-v2__item--left:not(.timeline-v2__item--expired) .timeline-v2__card {
    border-right: 3px solid var(--tl-accent);
}
.timeline-v2__item--right:not(.timeline-v2__item--expired) .timeline-v2__card {
    border-left: 3px solid var(--tl-accent);
}

.timeline-v2__card::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    background: var(--tl-bg-card);
    border: 1px solid var(--tl-border);
    transform: translateY(-50%) rotate(45deg);
}
.timeline-v2__item--left .timeline-v2__card::after {
    right: -8px;
    border-left: none;
    border-bottom: none;
}
.timeline-v2__item--right .timeline-v2__card::after {
    left: -8px;
    border-right: none;
    border-top: none;
}

.timeline-v2__item--expired .timeline-v2__card {
    opacity: 0.72;
    background: #FAFBFC;
}
.timeline-v2__item--expired .timeline-v2__card-title { color: var(--tl-text-muted); }

.timeline-v2__card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}
.timeline-v2__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.timeline-v2__avatar--success { background: var(--tl-success-bg); color: var(--tl-success); }
.timeline-v2__avatar--error { background: var(--tl-error-bg); color: var(--tl-error); }
.timeline-v2__avatar--accent { background: var(--tl-accent-light); color: var(--tl-accent); }

.timeline-v2__meta { flex: 1; min-width: 0; }
.timeline-v2__group {
    font-size: 14px;
    font-weight: 600;
    color: var(--tl-text);
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.timeline-v2__school {
    font-size: 13px;
    color: var(--tl-text-subtle);
    margin: 0;
}
.timeline-v2__status {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}
.timeline-v2__status--success { background: var(--tl-success-bg); color: var(--tl-success); }
.timeline-v2__status--error { background: var(--tl-error-bg); color: var(--tl-error); }
.timeline-v2__status--accent { background: var(--tl-accent-light); color: var(--tl-accent-dark); }

.timeline-v2__categories {
    font-size: 13px;
    color: var(--tl-accent-dark);
    margin-bottom: 8px;
    font-weight: 600;
}
.timeline-v2__card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--tl-text);
    line-height: 1.4;
    margin: 0 0 12px;
}
.timeline-v2__card-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}

/* ----- Filter / toggle visibility ----- */
.timeline-container.hide-expired .timeline-v2__item--expired,
.timeline-container.hide-expired .timeline-v2__month-header--expired { display: none; }
.timeline-v2__item.is-filtered-out,
.timeline-v2__month-header.is-filtered-out { display: none; }

.timeline-empty {
    text-align: center;
    padding: 32px 24px;
    color: var(--tl-text-muted);
    background: var(--tl-bg-card);
    border-radius: 12px;
    box-shadow: var(--tl-shadow-sm);
    margin-top: 16px;
}

/* ----- CTA ----- */
.timeline-cta-wrap {
    text-align: center;
    margin-top: 48px;
}
.timeline-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 16px 32px;
    background: var(--tl-accent);
    color: #fff;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 700;
    font-size: 15px;
    box-shadow: var(--tl-shadow-accent);
    transition: background 0.15s, transform 0.15s;
}
.timeline-cta:hover {
    background: var(--tl-accent-dark);
    transform: translateY(-1px);
}

/* ----- Date badge — range variant (events with dateDebut → dateFin) ----- */
.timeline-v2__date--range {
    width: 110px;
}
.timeline-v2__date--range .timeline-v2__date__day { font-size: 16px; }
.timeline-v2__date--range .timeline-v2__date__month { font-size: 11px; }

/* ----- Mobile: single column, axis on left ----- */
@media (max-width: 900px) {
    .filters-accordion__body { grid-template-columns: 1fr; }

    .timeline-v2__date--range {
        width: 88px;
    }
    .timeline-v2__date--range .timeline-v2__date__day { font-size: 13px; }

    .timeline-v2::before {
        left: 32px;
        transform: none;
    }
    .timeline-v2__month-header {
        text-align: left;
        padding-left: 76px;
    }
    .timeline-v2__item {
        grid-template-columns: 84px 1fr;
        gap: 20px;
    }
    .timeline-v2__date {
        grid-column: 1;
        justify-self: start;
        width: 68px;
        height: 68px;
        margin-left: -2px;
    }
    .timeline-v2__date__day { font-size: 18px; }
    .timeline-v2__date__month { font-size: 11px; }
    .timeline-v2__item--left .timeline-v2__card,
    .timeline-v2__item--right .timeline-v2__card {
        grid-column: 2;
        margin: 0;
        border-left: 3px solid var(--tl-accent);
        border-right: 1px solid var(--tl-border);
    }
    .timeline-v2__item--expired .timeline-v2__card {
        border-left: 1px solid var(--tl-border) !important;
    }
    .timeline-v2__item--left .timeline-v2__card::after,
    .timeline-v2__item--right .timeline-v2__card::after {
        left: -8px;
        right: auto;
        border-left: 1px solid var(--tl-border);
        border-bottom: 1px solid var(--tl-border);
        border-right: none;
        border-top: none;
    }
}
