/* ========================================
   DIRTY FIELD TRACKING
   Orange dot indicators + floating save bar
   for "update" forms. Activated per-form via
   the data-dirty-guard attribute (see
   js/dirty-tracking.js).
   ======================================== */

.dirty-track-anchor {
    position: relative;
}

/* Checkbox/switch wrappers are unstyled block divs that stretch to
   the full row width even though the control only occupies the left
   edge — shrink them to their content so the dot lands next to the
   actual checkbox instead of far off to the right. */
.dirty-track-anchor.form-check,
.dirty-track-anchor.bs4.checkbox {
    width: -moz-fit-content;
    width: fit-content;
}

.dirty-field-dot {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #f5941f;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
    opacity: 0;
    transform: scale(0.4);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(.34, 1.56, .64, 1);
}

.dirty-field-dot::after {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: rgba(245, 148, 31, 0.45);
    animation: dirty-dot-pulse 1.8s ease-out infinite;
}

.dirty-field-dot.is-visible {
    opacity: 1;
    transform: scale(1);
}

.form-check .dirty-field-dot,
.bs4.checkbox .dirty-field-dot {
    right: -16px;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%) scale(0.4);
}

.form-check .dirty-field-dot.is-visible,
.bs4.checkbox .dirty-field-dot.is-visible {
    transform: translateY(-50%) scale(1);
}

@keyframes dirty-dot-pulse {
    0% { opacity: 0.55; transform: scale(0.6); }
    100% { opacity: 0; transform: scale(1.9); }
}

@media (prefers-reduced-motion: reduce) {
    .dirty-field-dot,
    .dirty-field-dot::after {
        animation: none;
        transition: opacity 0.15s ease;
    }
}

/* ========================================
   FLOATING SAVE BAR
   ======================================== */
.dirty-save-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    justify-content: center;
    padding: 0 16px calc(16px + env(safe-area-inset-bottom, 0px));
    pointer-events: none;
    transform: translateY(120%);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(.16, 1, .3, 1), opacity 0.3s ease;
}

.dirty-save-bar.is-visible {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.dirty-save-bar__inner {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    width: 100%;
    max-width: 640px;
    padding: 12px 14px 12px 20px;
    border-radius: 16px;
    background: linear-gradient(135deg, #3d5750 0%, #2d4238 100%);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.2);
    color: #fff;
}

.dirty-save-bar__message {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    white-space: nowrap;
}

.dirty-save-bar__dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #f5941f;
    box-shadow: 0 0 0 4px rgba(245, 148, 31, 0.25);
    flex: none;
}

.dirty-save-bar__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.dirty-save-bar__undo,
.dirty-save-bar__save {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 10px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.dirty-save-bar__undo {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.dirty-save-bar__undo:hover {
    background: rgba(255, 255, 255, 0.18);
}

.dirty-save-bar__save {
    background: linear-gradient(135deg, #68d391 0%, #48b57e 100%);
    color: #1a3226;
}

.dirty-save-bar__save:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(104, 211, 145, 0.4);
}

.dirty-save-bar__save:active,
.dirty-save-bar__undo:active {
    transform: translateY(0);
}

@media (min-width: 991.98px) {
    .dirty-save-bar {
        left: 280px;
    }
}

@media (max-width: 480px) {
    .dirty-save-bar__inner {
        gap: 12px;
        padding: 12px 12px 12px 16px;
    }

    .dirty-save-bar__message {
        flex-basis: 100%;
    }

    .dirty-save-bar__actions {
        margin-left: 0;
        flex: 1;
    }

    .dirty-save-bar__undo,
    .dirty-save-bar__save {
        flex: 1;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dirty-save-bar {
        transition: opacity 0.2s ease;
        transform: none;
    }
}
