/* =====================================
   PERIOD SLIDER - Apple-Inspired Control
   ===================================== */

/* Period Filter Section */
.period-filter-section {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px 30px;
    margin: 30px auto;
    max-width: 1200px;
    box-shadow: 2px 4px 12px #00000014, 0 1px 3px rgba(0, 0, 0, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.9);
    border: none;
    min-height: 150px;
    position: relative;
    font-family: var(--font-family);
}

/* Event Count Badge */
.event-count-badge {
    position: absolute;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #007aff 0%, #0056b3 100%);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 3px 12px rgba(0, 122, 255, 0.3);
    z-index: 10;
    transition: all 0.2s ease;
    cursor: default;
    letter-spacing: -0.01em;
}

.event-count-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.4);
    background: linear-gradient(135deg, #0056b3 0%, #003d82 100%);
}

/* Sort controls at top center */
.sort-controls-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.sort-controls-top h6 {
    flex: 0 0 auto;
}

.sort-controls-top .buttons-group {
    display: flex;
    gap: 5px;
    margin: 0 auto;
}

.sort-label {
    font-size: 0.875rem;
    font-weight: var(--font-weight-medium);
    color: var(--gray-700);
    margin: 0;
}

.sort-toggle {
    padding: 8px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, white 0%, #f8f9fa 100%);
    font-size: 0.875rem;
    color: var(--gray-800);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-weight: var(--font-weight-medium);
    box-shadow: var(--shadow-sm);
}

.sort-toggle:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    outline: none !important;
}

.sort-toggle:active {
    transform: translateY(0);
}

.sort-toggle:focus {
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.sort-toggle.asc {
    color: var(--primary);
}

.sort-toggle.desc {
    color: var(--primary);
}

@media (max-width: 768px) {
    .period-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .sort-controls {
        align-self: flex-end;
    }
    
    /* Réorganiser les contrôles de tri pour mobile - override par les règles plus spécifiques ci-dessus */
    .sort-controls-top {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 5px;
        margin-bottom: var(--spacing-lg);
    }
    
    .sort-toggle {
        width: auto;
        justify-content: center;
        padding: 8px 12px;
        font-size: 0.85rem;
        display: inline-block;
    }
    
    .sort-label {
        text-align: center;
        font-size: 0.8rem;
        margin-bottom: 4px;
    }
}

.period-filter-section .title-timeline {
    background: linear-gradient(135deg, #007aff 0%, #0056b3 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #007aff;
    font-weight: var(--font-weight-semibold);
    margin-bottom: 0px;
    display: flex;
    align-items: center;
    letter-spacing: -0.01em;
}

.period-filter-section .title-timeline i {
    background: linear-gradient(135deg, #007aff 0%, #0056b3 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #007aff;
}

.period-filter-section .title-timeline h1, .period-filter-section .title-timeline h6 {
    font-size: 1.125rem;
}

/* Style pour les dates dans les titres de thèmes */
.theme-date-range {
    font-weight: normal;
    font-size: 1em;
    text-transform: lowercase;
    letter-spacing: 0;
}

/* Date Slider Wrapper with Reset Button */
.date-slider-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 15px;
    margin: 40px 0 0 0;
}

.date-slider-container {
    flex: 1;
}

/* Boutons en ligne sur desktop par défaut */
.date-slider-buttons {
    display: contents; /* Les boutons restent dans le flex parent */
}

/* Date Slider Container */
.date-slider {
    margin: 0;
    padding: 0 var(--spacing-md);
    padding-bottom: 40px; /* Espace pour les pips */
    position: relative;
}

/* Reset Button */
.date-slider-reset-btn {
    padding: 4px 8px;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 28px;
    margin-left: 12px;
    transition: opacity 0.2s ease, cursor 0.2s ease;
}

.date-slider-reset-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Button disabled state */
.apple-search-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.apple-search-btn:not(.disabled) {
    opacity: 1;
    cursor: pointer;
}

/* Modern Apple-style noUiSlider */
.date-slider .noUi-target {
    background: #e5e5e7;
    border-radius: 6px;
    border: none;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
    height: 6px;
    transition: all 0.2s ease;
}

.date-slider .noUi-target:hover {
    background: #d2d2d7;
}

.date-slider .noUi-connect {
    background: linear-gradient(90deg, #007aff 0%, #0056b3 100%);
    border-radius: 6px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 122, 255, 0.3);
}

.date-slider .noUi-handle {
    background: #ffffff;
    border: 2px solid #007aff;
    border-radius: 50%;
    box-shadow: 0 3px 12px rgba(0, 122, 255, 0.2), 0 1px 4px rgba(0, 0, 0, 0.1);
    cursor: grab;
    width: 60px;
    height: 60px;
    right: -30px;
    top: -28px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: #007aff;
    text-align: center;
    line-height: 1;
}

.date-slider .noUi-handle:active {
    cursor: grabbing;
}


.date-slider .noUi-handle:hover {
    transform: scale(1.1);
    border-color: #0056b3;
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.3), 0 2px 8px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
}

.date-slider .noUi-handle:active {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 122, 255, 0.4), 0 2px 6px rgba(0, 0, 0, 0.2);
}

.date-slider .noUi-handle::after {
    display: none !important;
}

.date-slider .noUi-handle::before {
    display: none !important;
}

/* S'assurer que les handles sont visibles */
.date-slider .noUi-origin .noUi-handle {
    background: #ffffff !important;
    border: 2px solid #007aff !important;
    border-radius: 50% !important;
    width: 60px !important;
    height: 60px !important;
    right: -30px !important;
    top: -28px !important;
    cursor: grab !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #007aff !important;
    position: absolute !important;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
    white-space: pre-line !important;
    text-align: center !important;
}

.date-slider .noUi-origin .noUi-handle:active {
    cursor: grabbing !important;
}

/* Tooltip styling */
.date-slider .noUi-tooltip {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 500;
    border: none;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

/* Remove default handle styling */
.date-slider .noUi-handle-lower,
.date-slider .noUi-handle-upper {
    background: var(--white);
    border-color: var(--primary);
}

/* Modern Date Display - Hidden since dates are in handles */
.date-slider .d-flex {
    display: none;
}

.date-slider .d-flex span {
    background: #ffffff;
    color: #1d1d1f;
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e5e7;
    transition: all 0.2s ease;
    min-width: 130px;
    text-align: center;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    letter-spacing: -0.3px;
    position: relative;
}

.date-slider .d-flex span[data-double-slider-target="fromDisplay"] {
    background: linear-gradient(135deg, #f9f9f9 0%, #ffffff 100%);
    border-color: #007aff;
    color: #007aff;
}

.date-slider .d-flex span[data-double-slider-target="toDisplay"] {
    background: linear-gradient(135deg, #f9f9f9 0%, #ffffff 100%);
    border-color: #007aff;
    color: #007aff;
}

.date-slider .d-flex span::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.05) 0%, rgba(0, 86, 179, 0.05) 100%);
    border-radius: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.date-slider .d-flex span:hover::before {
    opacity: 1;
}

/* Interactive Effects */
.date-slider .d-flex span:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.08);
    border-color: #0056b3;
}

/* Animation for value changes */
@keyframes valueChange {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.date-slider .d-flex span.updating {
    animation: valueChange 0.3s ease;
}

/* Active slider styling */
.date-slider .noUi-target.noUi-state-tap .noUi-connect,
.date-slider .noUi-target.noUi-state-tap .noUi-origin {
    transition: transform 0.3s, top 0.3s, right 0.3s, bottom 0.3s, left 0.3s;
}

/* Responsive Design */
@media (max-width: 768px) {
    .period-filter-section {
        padding: 1rem;
        min-height: auto;
        margin: 15px !important;
        border-radius: 12px;
    }
    
    /* Badge d'événements repositionné */
    .event-count-badge {
        position: static;
        display: inline-block;
        margin: 0 0 15px auto;
        padding: 6px 12px;
        font-size: 0.75rem;
        border-radius: 6px;
        width: fit-content;
    }
    
    /* Header avec badge */
    .period-filter-section h6 {
        font-size: 0.9rem;
        margin-bottom: 10px;
        line-height: 1.2;
    }
    
    /* Contrôles de tri réorganisés */
    .sort-controls-top {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 15px;
    }
    
    .sort-controls-top h6 {
        order: 1;
        margin-bottom: 5px;
        text-align: center;
    }
    
    .event-count-badge {
        order: 2;
        align-self: center;
        margin-bottom: 10px;
    }
    
    .buttons-group {
        order: 3;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }
    
    .sort-toggle {
        padding: 6px 10px;
        font-size: 0.75rem;
        min-width: auto;
        white-space: nowrap;
    }
    
    .chronos-launch-btn {
        flex-basis: 100%;
        margin-top: 5px;
        padding: 8px 12px;
    }
    
    /* Disposition verticale pour mobile */
    .date-slider-wrapper {
        flex-direction: column;
        gap: 10px;
    }
    
    .date-slider-container {
        flex: none;
        width: 100%;
    }
    
    /* Override: boutons sur leur propre ligne en mobile */
    .date-slider-buttons {
        display: flex !important;
    }
    
    .date-slider {
        padding: 0;
        margin: 15px 0 0 0;
        padding-bottom: 20px;
        position: relative;
        z-index: 1;
    }
    
    /* Boutons groupés sur une ligne */
    .date-slider-buttons {
        display: flex;
        justify-content: center;
        gap: 15px;
        margin-top: 15px;
        padding: 10px 0;
        position: relative;
        z-index: 10;
    }
    
    .date-slider-reset-btn {
        margin: 0;
        width: 40px;
        height: 40px;
        min-width: 40px;
        padding: 10px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        z-index: 11;
        cursor: pointer;
        pointer-events: auto;
    }
    
    .date-slider-reset-btn i {
        font-size: 1rem;
        margin: 0;
        pointer-events: none;
    }
    
    .date-slider .noUi-handle {
        width: 50px;
        height: 50px;
        right: -25px;
        top: -23px;
        font-size: 11px;
    }
    
    .date-slider .d-flex span {
        font-size: 0.8rem;
        padding: 0.625rem 1rem;
        min-width: 100px;
    }
}

@media (max-width: 480px) {

    .period-filter-section {
        margin: 10px !important;
        padding: 0.75rem;
        border-radius: 10px;
    }
    
    /* Header encore plus compact */
    .period-filter-section h6 {
        font-size: 0.8rem;
        text-align: center;
        margin-bottom: 8px;
        line-height: 1.1;
    }
    
    /* Badge d'événements plus petit */
    .event-count-badge {
        font-size: 0.7rem;
        padding: 4px 8px;
        margin-bottom: 8px;
    }
    
    /* Boutons plus compacts */
    .sort-toggle {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
    
    .chronos-launch-btn {
        padding: 6px 10px;
        font-size: 0.7rem;
    }
    
    .chronos-launch-btn i {
        margin-right: 4px;
    }
    
    /* Slider wrapper avec disposition verticale */
    .date-slider-wrapper {
        margin-top: 10px;
        flex-direction: column;
        gap: 8px;
        margin-left: 30px;
        margin-right: 30px;
        margin-top: 35px;
    }
    
    .date-slider-container {
        flex: none;
        width: 100%;
    }
    
    /* Override: boutons sur leur propre ligne en mobile très petit */
    .date-slider-buttons {
        display: flex !important;
    }
    
    .date-slider {
        margin: 0;
        padding-bottom: 15px;
        position: relative;
        z-index: 1;
    }
    
    /* Handles plus petits */
    .date-slider .noUi-handle {
        width: 45px;
        height: 45px;
        right: -22.5px;
        top: -20.5px;
        font-size: 10px;
    }
    
    /* Boutons de contrôle du slider sur une ligne séparée */
    .date-slider-buttons {
        display: flex;
        justify-content: center;
        gap: 12px;
        margin-top: 12px;
        padding: 12px 0;
        position: relative;
        z-index: 15;
        background: transparent;
    }
    
    .date-slider-reset-btn {
        margin: 0;
        width: 42px;
        height: 42px;
        min-width: 42px;
        padding: 10px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        z-index: 16;
        cursor: pointer;
        pointer-events: auto;
        touch-action: manipulation;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    .date-slider-reset-btn i {
        font-size: 1rem;
        margin: 0;
        pointer-events: none;
    }
    
    /* Form plus compact */
    #dateFilterForm {
        margin-left: 0;
    }
    
    /* Pips plus petits et z-index ajusté */
    .date-slider .noUi-pips {
        z-index: 0;
    }
    
    .date-slider .noUi-value {
        font-size: 7px;
        z-index: 0;
    }
    
    .date-slider .noUi-value-large {
        font-size: 8px;
        z-index: 0;
    }
    
    /* Slider track plus fin */
    .date-slider .noUi-target {
        height: 3px;
    }
    .tutorial-tooltip.position-bottom::before{
        display:none;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .date-slider .noUi-handle {
        transition: none;
    }
    
    .date-slider .d-flex span {
        transition: none;
        animation: none;
    }
}

/* Disable animations during AJAX reload */
.period-filter-section.ajax-loading * {
    animation: none !important;
    transition: none !important;
}

.period-filter-section.ajax-loading .date-slider .noUi-handle {
    transition: none !important;
}

.period-filter-section.ajax-loading .date-slider .d-flex span {
    animation: none !important;
    transition: none !important;
}

/* Focus states for accessibility */
.date-slider .noUi-handle:focus {
    outline: none;
    border-color: #0056b3;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.25), 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Active state */
.date-slider .noUi-state-tap .noUi-connect {
    background: linear-gradient(90deg, #0056b3 0%, #003d82 100%);
}

/* Discrete Pips for Reference */
.date-slider .noUi-pips {
    height: 40px;
    top: 100%;
    padding-top: 25px;
    opacity: 0.6;
}

.date-slider .noUi-marker {
    background: #a1a1a6;
    width: 1px;
    height: 4px;
    border-radius: 0.5px;
    opacity: 0.4;
}

.date-slider .noUi-marker-large {
    background: #86868b;
    width: 1px;
    height: 6px;
    border-radius: 0.5px;
    opacity: 0.6;
}

.date-slider .noUi-value {
    transform: translate(-50%, 0);
    background: transparent;
    border: none;
    color: #86868b;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 8px;
    font-weight: 500;
    text-align: center;
    margin-top: 8px;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.date-slider .noUi-value:hover {
    color: #007aff;
    opacity: 1;
    font-weight: 600;
}

.date-slider .noUi-value-large {
    color: #6e6e73;
    font-size: 9px;
    font-weight: 600;
    opacity: 0.8;
}

.date-slider .noUi-value-large:hover {
    color: #007aff;
    opacity: 1;
    font-weight: 700;
}

/* Responsive pips */
@media (max-width: 768px) {
    .date-slider .noUi-value {
        width: 38px;
        height: 38px;
        font-size: 9px;
    }
    
    .date-slider .noUi-value-large {
        width: 42px;
        height: 42px;
        font-size: 10px;
    }
}