/* ==========================================================================
   POPUP "Vieillissement automatique"
   Ouverte via le sous-menu "..." > "Aging automatique" (voir div-menu.php).
   Réutilise .popup-overlay-rendement / .popup-content-rendement existants.
   ========================================================================== */

.aging-popup-content {
    max-width: 460px;
    text-align: left;
}

.aging-popup-content h3 {
    color: #1b5e20;
    margin: 0 0 18px 0;
    text-align: center;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.aging-field {
    margin-bottom: 18px;
}

.aging-field label {
    display: block;
    font-weight: 600;
    color: #444;
    margin-bottom: 8px;
}

.aging-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.aging-toggle-row label {
    margin-bottom: 0;
}

/* Interrupteur ON/OFF à deux positions */
.aging-form-toggle {
    position: relative;
    width: 60px;
    height: 30px;
    border: none;
    border-radius: 20px;
    background: #bdbdbd;
    cursor: pointer;
    flex-shrink: 0;
    transition: background-color 0.2s ease;
}

.aging-form-toggle-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: left 0.2s ease;
}

.aging-form-toggle.is-on {
    background: #2e7d32;
}

.aging-form-toggle.is-on .aging-form-toggle-knob {
    left: 33px;
}

/* Corps du formulaire : grisé/inactif tant que le toggle est OFF */
.aging-form-body.is-disabled .aging-field:not(.aging-toggle-row) {
    opacity: 0.45;
    pointer-events: none;
}

/* Slider à 5 positions discrètes */
.aging-slider-wrapper {
    padding: 0 4px;
}

#agingTauxSlider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: transparent;
    cursor: pointer;
    --fill: 50%;
}

#agingTauxSlider:disabled {
    /* Contre le style par défaut du navigateur qui grise/estompe les
       champs disabled : le curseur doit rester pleinement visible
       (vert/gris) même verrouillé sur une seule position. */
    opacity: 1;
    cursor: not-allowed;
}

/* ---- Piste : verte jusqu'au bouton rond, grise ensuite ---- */

#agingTauxSlider::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(
        to right,
        #2e7d32 0%, #2e7d32 var(--fill),
        #d9d9d9 var(--fill), #d9d9d9 100%
    );
}

#agingTauxSlider::-moz-range-track {
    height: 8px;
    border-radius: 4px;
    background: #d9d9d9;
}

/* Firefox calcule nativement le remplissage à partir de value/min/max,
   qui restent fixes (0-4) : pas besoin de JS ici. */
#agingTauxSlider::-moz-range-progress {
    height: 8px;
    border-radius: 4px 0 0 4px;
    background: #2e7d32;
}

/* ---- Bouton rond (thumb) : toujours vert, modifiable ou non selon le cas ---- */

#agingTauxSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    margin-top: -6px;
    border-radius: 50%;
    background: #2e7d32;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

#agingTauxSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2e7d32;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

#agingTauxSlider:disabled::-webkit-slider-thumb,
#agingTauxSlider:disabled::-moz-range-thumb {
    cursor: not-allowed;
}

.aging-slider-ticks {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #777;
}

.aging-slider-ticks span.is-active {
    color: #2e7d32;
    font-weight: 800;
}

.aging-slider-ticks span.is-disabled {
    opacity: 0.35;
}

.aging-taux-hint {
    margin: 6px 0 0 0;
    font-size: 0.8rem;
    color: #9F57B2;
    font-style: italic;
}

.aging-hour-select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #9F57B2;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
}

.aging-actions {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.aging-valider-btn {
    padding: 12px 32px;
    font-size: 1.05rem;
}

@media (max-width: 480px) {
    .aging-popup-content {
        max-width: 100%;
    }
}

/* Message inline dans la popup */
.aging-inline-feedback {
    min-height: 1.3em;
    margin: 8px 0 4px 0;
    font-size: 0.92rem;
    font-weight: 600;
    text-align: center;
}
.aging-inline-feedback.is-success { color: #1b5e20; }
.aging-inline-feedback.is-error { color: #c0392b; }

/* Toast feedback après validation (succès / erreur) */
.aging-feedback-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    z-index: 100000;
    max-width: min(92vw, 420px);
    padding: 14px 20px;
    border-radius: 10px;
    font-size: 0.98rem;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.aging-feedback-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.aging-feedback-toast.is-success {
    background: #2ecc71;
    color: #ffffff;
}
.aging-feedback-toast.is-error {
    background: #e74c3c;
    color: #ffffff;
}

/* Sablier à côté du champ Âge — place réservée (ne décale pas les champs) */
.age-with-hourglass {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    position: relative;
    vertical-align: middle;
}
button.aging-hourglass {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    min-width: 24px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: default;
    line-height: 0;
    flex-shrink: 0;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}
button.aging-hourglass.is-active {
    visibility: visible;
    opacity: 1;
}
button.aging-hourglass img,
img.aging-hourglass-img {
    width: 22px !important;
    height: 22px !important;
    max-width: 22px !important;
    max-height: 22px !important;
    object-fit: contain;
    display: block;
    pointer-events: none;
}
button.aging-hourglass.is-active.is-link {
    pointer-events: auto;
    cursor: pointer;
}
button.aging-hourglass.is-active.is-link:hover img {
    transform: translateY(-2px);
    transition: transform 0.15s ease;
}

/* Heure locale + équivalent UTC */
.aging-hour-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.aging-hour-row .aging-hour-select {
    flex: 1 1 140px;
    min-width: 120px;
}
.aging-hour-utc {
    font-size: 0.9rem;
    font-weight: 600;
    color: #6a1b9a;
    white-space: nowrap;
    min-width: 5.5em;
}
.aging-tz-hint {
    font-weight: 500;
    color: #777;
    font-size: 0.85em;
}
.aging-tz-note {
    margin: 4px 0 0 0;
    font-size: 0.78rem;
    color: #888;
    font-style: italic;
    line-height: 1.35;
}
