/**
 * SOP Collaboration UI Styles
 * Visual indicators for edit locks, presence, and conflicts
 */

/* Presence Indicator */
.sop-presence-indicator {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.presence-avatar {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
}

.presence-pulse {
    width: 10px;
    height: 10px;
    background-color: #fff;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* Edit Lock Badge in Table */
.sop-edit-lock-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.sop-edit-lock-badge.locked {
    background-color: #ffc107;
    color: #000;
}

.sop-edit-lock-badge.editing {
    background-color: #28a745;
    color: #fff;
}

.sop-edit-lock-badge i {
    font-size: 0.7rem;
}

/* Auto-save Indicator */
.auto-save-indicator {
    padding: 0.5rem;
    border-radius: 0.375rem;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    margin-bottom: 1rem;
}

.auto-save-status {
    margin-top: 0.5rem;
}

.auto-save-status.saving {
    color: #0d6efd;
}

.auto-save-status.saved {
    color: #198754;
}

.auto-save-status.error {
    color: #dc3545;
}

.auto-save-status.conflict {
    color: #ffc107;
}

/* Conflict Warning in Editor */
.conflict-warning-banner {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    max-width: 600px;
    width: 90%;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Edit Lock Warning Modal Enhancements */
#editLockWarningModal .modal-content {
    box-shadow: 0 0.5rem 1rem rgba(255, 193, 7, 0.5);
}

#editLockWarningModal .modal-header {
    border-bottom: 2px solid #f59f00;
}

/* Conflict Modal Enhancements */
#conflictWarningModal .modal-content {
    box-shadow: 0 0.5rem 1rem rgba(220, 53, 69, 0.5);
}

#conflictWarningModal .modal-header {
    border-bottom: 2px solid #c92a2a;
}

/* Table Row Hover for Locked SOPs */
tr.sop-row-locked {
    background-color: rgba(255, 193, 7, 0.1) !important;
}

tr.sop-row-locked:hover {
    background-color: rgba(255, 193, 7, 0.2) !important;
}

tr.sop-row-editing {
    background-color: rgba(40, 167, 69, 0.1) !important;
}

tr.sop-row-editing:hover {
    background-color: rgba(40, 167, 69, 0.2) !important;
}

/* Lock Icon Animation */
.lock-icon-animated {
    animation: lockShake 0.5s ease-in-out;
}

@keyframes lockShake {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-10deg);
    }
    75% {
        transform: rotate(10deg);
    }
}

/* Editor Lock Indicator */
.editor-lock-indicator {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
    margin-bottom: 1rem;
    border-radius: 0.5rem;
}

.editor-lock-indicator .lock-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.editor-lock-indicator .lock-icon {
    font-size: 1.25rem;
}

.editor-lock-indicator .lock-details {
    display: flex;
    flex-direction: column;
}

.editor-lock-indicator .lock-time {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* Read-only Mode Indicator */
.readonly-mode-banner {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    color: white;
    padding: 1rem;
    text-align: center;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

.readonly-mode-banner i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

/* Collaborative Edit Tooltip */
.collab-tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    z-index: 1060;
    pointer-events: none;
    white-space: nowrap;
}

/* Active Editors List */
.active-editors-list {
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    margin-top: 0.5rem;
}

.active-editor-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid #dee2e6;
}

.active-editor-item:last-child {
    border-bottom: none;
}

.active-editor-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #28a745;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.active-editor-info {
    flex: 1;
}

.active-editor-name {
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.active-editor-sop {
    font-size: 0.875rem;
    color: #6c757d;
}

.active-editor-time {
    font-size: 0.75rem;
    color: #adb5bd;
}

/* Loading Spinner for Lock Check */
.lock-check-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: #0d6efd;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Dark Mode Support */
[data-bs-theme="dark"] .sop-presence-indicator {
    background-color: #343a40 !important;
    border: 1px solid #495057;
}

[data-bs-theme="dark"] .auto-save-indicator {
    background-color: #212529;
    border-color: #495057;
}

[data-bs-theme="dark"] .active-editors-list {
    background-color: #212529;
}

[data-bs-theme="dark"] .active-editor-item {
    border-bottom-color: #495057;
}

[data-bs-theme="dark"] tr.sop-row-locked {
    background-color: rgba(255, 193, 7, 0.15) !important;
}

[data-bs-theme="dark"] tr.sop-row-editing {
    background-color: rgba(40, 167, 69, 0.15) !important;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .sop-presence-indicator {
        top: 70px;
        right: 10px;
        font-size: 0.875rem;
    }
    
    .presence-info small {
        font-size: 0.75rem;
    }
    
    .editor-lock-indicator {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .conflict-warning-banner {
        width: 95%;
        font-size: 0.875rem;
    }
}

/* Accessibility */
.sop-edit-lock-badge:focus,
.presence-indicator:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .sop-presence-indicator,
    .editor-lock-indicator,
    .auto-save-indicator,
    .conflict-warning-banner {
        display: none;
    }
}

