/* ========================================
   AUTO-REFRESH COMPONENTS
   Enterprise-grade safe auto-refresh UI styles
   ======================================== */

/* ── Refresh Banner ─────────────────────────────────
   Non-intrusive banner that appears BELOW the header
   when new data is available but guards are active.
   MUST NOT shift header buttons or resize layout. */

.auto-refresh-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    margin-bottom: var(--space-3);
    background: var(--color-info-light);
    border: 1px solid var(--color-info-border);
    border-radius: var(--radius-md);
    animation: slideDownBanner 0.2s ease-out;
    /* Fixed height so it doesn't cause content reflow */
    min-height: 44px;
    max-height: 44px;
    overflow: hidden;
}

@keyframes slideDownBanner {
    from {
        opacity: 0;
        transform: translateY(-8px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 44px;
    }
}

.auto-refresh-banner__content {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
}

.auto-refresh-banner__icon {
    color: var(--color-info);
    flex-shrink: 0;
}

.auto-refresh-banner__text {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    color: var(--color-info);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.auto-refresh-banner__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.auto-refresh-banner__btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    height: 30px;
}

.auto-refresh-banner__btn:focus-visible {
    outline: 2px solid var(--color-info);
    outline-offset: 2px;
}

.auto-refresh-banner__btn--primary {
    background: var(--color-info);
    color: var(--color-text-inverse);
}

.auto-refresh-banner__btn--primary:hover {
    background: var(--color-accent-hover);
}

.auto-refresh-banner__btn--dismiss {
    background: transparent;
    color: var(--color-text-secondary);
    padding: var(--space-1);
    height: 30px;
    width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auto-refresh-banner__btn--dismiss:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--color-text-primary);
}


/* ── Conflict Warning ────────────────────────────────
   Warning alert for edit conflict (record changed by another user).
   Appears inside modals/edit forms. */

.auto-refresh-conflict {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
    background: var(--color-warning-light);
    border: 1px solid var(--color-warning-border);
    border-radius: var(--radius-md);
    animation: fadeInConflict 0.2s ease-out;
}

@keyframes fadeInConflict {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.auto-refresh-conflict__icon {
    flex-shrink: 0;
    color: var(--color-warning);
    margin-top: 1px;
}

.auto-refresh-conflict__body {
    flex: 1;
    min-width: 0;
}

.auto-refresh-conflict__title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-warning-dark);
    margin-bottom: 2px;
}

.auto-refresh-conflict__message {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    line-height: var(--line-height-normal);
}

.auto-refresh-conflict__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.auto-refresh-conflict__btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    height: 30px;
}

.auto-refresh-conflict__btn:focus-visible {
    outline: 2px solid var(--color-warning);
    outline-offset: 2px;
}

.auto-refresh-conflict__btn--reload {
    background: var(--color-warning);
    color: var(--color-text-inverse);
}

.auto-refresh-conflict__btn--reload:hover {
    background: var(--color-warning-dark);
}

.auto-refresh-conflict__btn--keep {
    background: transparent;
    color: var(--color-warning-dark);
    border: 1px solid var(--color-warning-border);
}

.auto-refresh-conflict__btn--keep:hover {
    background: rgba(217, 119, 6, 0.08);
}


/* ── Last Updated Indicator ──────────────────────────
   Small, subtle timestamp display in the header area. */

.auto-refresh-last-updated {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    white-space: nowrap;
    user-select: none;
}

.auto-refresh-last-updated__icon {
    opacity: 0.6;
    flex-shrink: 0;
}

.auto-refresh-last-updated__time {
    font-family: var(--font-family-mono);
    font-size: 0.625rem; /* 10px */
}


/* ── Refreshing Overlay (subtle) ─────────────────────
   Optional: thin progress bar at top of table during background refresh */

.auto-refresh-progress {
    position: relative;
    overflow: hidden;
    height: 2px;
    background: var(--color-border-light);
    border-radius: 1px;
    margin-bottom: var(--space-1);
}

.auto-refresh-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 30%;
    background: var(--color-info);
    border-radius: 1px;
    animation: refreshProgressSlide 1.2s ease-in-out infinite;
}

@keyframes refreshProgressSlide {
    0% { left: -30%; }
    100% { left: 100%; }
}


/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 767.98px) {
    .auto-refresh-banner {
        flex-wrap: wrap;
        max-height: none;
        min-height: auto;
        padding: var(--space-2) var(--space-3);
    }

    .auto-refresh-banner__content {
        flex: 1 1 100%;
    }

    .auto-refresh-banner__actions {
        flex: 1 1 100%;
        justify-content: flex-end;
    }

    .auto-refresh-conflict {
        flex-direction: column;
    }

    .auto-refresh-conflict__actions {
        width: 100%;
        justify-content: flex-end;
    }
}
