/* Concurrency Visual Indicators - Enhanced UX */

/* ============================================= */
/* 1. Modal Dialog Animations */
/* ============================================= */

/* Slide-in animation for modal dialog */
@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal.show .modal-dialog {
    animation: modalSlideIn 0.3s ease-out;
}

/* Backdrop fade-in */
.modal-backdrop.show {
    animation: backdropFadeIn 0.2s ease-in;
}

@keyframes backdropFadeIn {
    from { opacity: 0; }
    to { opacity: 0.5; }
}

/* ============================================= */
/* 2. Field Conflict Highlighting */
/* ============================================= */

/* Highlight fields with conflicts in edit forms */
.field-conflict .form-control,
.field-conflict .form-select,
.field-conflict textarea {
    border: 2px solid #ffc107;
    background-color: #fff3cd;
    animation: pulseWarning 2s infinite;
}

@keyframes pulseWarning {
    0% { 
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.4); 
    }
    50% { 
        box-shadow: 0 0 0 10px rgba(255, 193, 7, 0); 
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0); 
    }
}

/* Conflict indicator below field */
.field-conflict-indicator {
    margin-top: 5px;
    padding: 8px 12px;
    background-color: #fff3cd;
    border-left: 3px solid #ffc107;
    border-radius: 12px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 5px;
}

.field-conflict-indicator .bi {
    font-size: 1rem;
}

/* ============================================= */
/* 3. Diff View (Side-by-Side Comparison) */
/* ============================================= */

.diff-view {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 15px;
    align-items: center;
    margin: 10px 0;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 12px;
}

.diff-old {
    text-decoration: line-through;
    color: #dc3545;
    background-color: #f8d7da;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid #f5c2c7;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.diff-new {
    color: #198754;
    background-color: #d1e7dd;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid #badbcc;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    font-weight: 500;
}

.diff-arrow {
    font-size: 1.5rem;
    color: #6c757d;
}

/* Responsive diff view */
@media (max-width: 768px) {
    .diff-view {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .diff-arrow {
        display: none;
    }
    
    .diff-new::before {
        content: "→ ";
        font-weight: bold;
    }
}

/* ============================================= */
/* 4. Loading Spinner Overlay */
/* ============================================= */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease-in;
}

.loading-spinner {
    width: 3.5rem;
    height: 3.5rem;
    border: 0.5rem solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    margin-top: 20px;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 500;
    text-align: center;
}

/* Small inline spinner for buttons */
.spinner-border-sm {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 0.15rem solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

/* ============================================= */
/* 5. Button Pulse Animation */
/* ============================================= */

/* Pulse animation for Force Overwrite button */
.btn-danger.pulse,
.btn-danger:focus {
    animation: pulseDanger 2s infinite;
}

@keyframes pulseDanger {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(220, 53, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

/* Glow effect on hover */
.btn-danger:hover:not(:disabled) {
    box-shadow: 0 0 20px rgba(220, 53, 69, 0.5);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 0 20px rgba(13, 110, 253, 0.4);
}

/* ============================================= */
/* 6. Toast Notifications */
/* ============================================= */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: toastSlideIn 0.3s ease-out;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.hiding {
    animation: toastSlideOut 0.3s ease-in;
}

@keyframes toastSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Toast color variants */
.toast-success {
    background-color: #198754;
    color: white;
    border-left: 4px solid #146c43;
}

.toast-error {
    background-color: #dc3545;
    color: white;
    border-left: 4px solid #b02a37;
}

.toast-warning {
    background-color: #ffc107;
    color: #000;
    border-left: 4px solid #cc9a06;
}

.toast-info {
    background-color: #0dcaf0;
    color: #000;
    border-left: 4px solid #0aa2c0;
}

/* Toast icon styles */
.toast .bi {
    font-size: 1.2rem;
    margin-right: 8px;
}

/* ============================================= */
/* 7. Icon Animations */
/* ============================================= */

/* Shake animation for warning icon */
.bi-exclamation-triangle.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Bounce animation for success icon */
.bi-check-circle.bounce {
    animation: bounce 0.6s ease-in-out;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

/* Rotate animation for reload icon */
.bi-arrow-clockwise.rotate {
    animation: rotate 0.5s ease-in-out;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================= */
/* 8. Badge Indicators */
/* ============================================= */

/* Conflict count badge */
.conflict-badge {
    position: relative;
    display: inline-block;
}

.conflict-badge::after {
    content: attr(data-count);
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #dc3545;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 12px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ============================================= */
/* 9. Accessibility & Focus States */
/* ============================================= */

/* Enhanced focus states for accessibility */
.btn:focus-visible,
.form-control:focus-visible {
    outline: 3px solid #0d6efd;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.25);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .field-conflict .form-control {
        border-width: 3px;
    }
    
    .field-conflict-indicator {
        border-left-width: 5px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================= */
/* 10. Dark Theme Support */
/* ============================================= */

@media (prefers-color-scheme: dark) {
    .field-conflict .form-control {
        background-color: #3a3011;
        border-color: #ffc107;
    }
    
    .field-conflict-indicator {
        background-color: #3a3011;
        color: #f8f9fa;
    }
    
    .diff-view {
        background-color: #212529;
    }
    
    .diff-old {
        background-color: #5a1a1a;
        border-color: #842029;
        color: #f8d7da;
    }
    
    .diff-new {
        background-color: #0f3d1e;
        border-color: #0a3622;
        color: #d1e7dd;
    }
}

/* ============================================= */
/* 11. Print Styles */
/* ============================================= */

@media print {
    .loading-overlay,
    .toast-container,
    .modal-backdrop {
        display: none !important;
    }
    
    .field-conflict .form-control {
        border: 2px solid #000 !important;
        background-color: #fff !important;
    }
    
    .field-conflict-indicator {
        border-left: 3px solid #000 !important;
        background-color: #f5f5f5 !important;
    }
}

