/**
 * Real-Time Collaboration Styles
 * Styling voor collaboration indicators, cursors en user presence
 */

/* ============================================
   Collaboration Status Indicator
   ============================================ */

.collaboration-ui-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: auto;
}

.collaboration-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-size: 0.85rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6c757d;
    animation: pulse 2s infinite;
}

.status-dot.status-connected {
    background: #ffc107;
    animation: pulse 2s infinite;
}

.status-dot.status-synced {
    background: #28a745;
    animation: none;
}

.status-dot.status-disconnected {
    background: #6c757d;
    animation: pulse-slow 3s infinite;
}

.status-dot.status-error {
    background: #dc3545;
    animation: pulse-fast 1s infinite;
}

.status-dot.status-failed {
    background: #dc3545;
    animation: none;
}

.status-text {
    color: #fff;
    font-weight: 500;
    white-space: nowrap;
}

/* Pulse animations */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes pulse-slow {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

@keyframes pulse-fast {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.2;
    }
}

/* ============================================
   Active Users List
   ============================================ */

.collaboration-users {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 1rem;
}

.users-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.users-header i {
    font-size: 1rem;
    color: #ffc107;
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    transition: all 0.2s;
}

.user-item:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateX(2px);
}

.user-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.user-name {
    font-size: 0.875rem;
    color: #fff;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.no-users {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    text-align: center;
    padding: 0.5rem;
}

/* ============================================
   Yjs Cursor Styling (Enhanced)
   ============================================ */

.yjs-cursor {
    position: relative;
    pointer-events: none;
    z-index: 100;
}

.yjs-cursor-label {
    position: absolute;
    top: -1.4em;
    left: -2px;
    font-size: 0.7em;
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-2px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.yjs-selection {
    background-color: rgba(48, 188, 237, 0.2);
    border-radius: 2px;
}

/* ============================================
   Sidebar Collaboration Section
   ============================================ */

.collaboration-sidebar-section {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================
   Connection Toast Notifications
   ============================================ */

.collaboration-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #fff;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 9999;
    animation: slideIn 0.3s ease-out;
}

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

.collaboration-toast.toast-success {
    border-left: 4px solid #28a745;
}

.collaboration-toast.toast-error {
    border-left: 4px solid #dc3545;
}

.collaboration-toast.toast-warning {
    border-left: 4px solid #ffc107;
}

.collaboration-toast.toast-info {
    border-left: 4px solid #17a2b8;
}

.collaboration-toast-icon {
    font-size: 1.5rem;
}

.collaboration-toast-content {
    flex: 1;
}

.collaboration-toast-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.collaboration-toast-message {
    font-size: 0.9rem;
    color: #6c757d;
}

.collaboration-toast-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.collaboration-toast-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 768px) {
    .collaboration-ui-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .collaboration-status {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }
    
    .collaboration-users {
        width: 100%;
    }
    
    .collaboration-toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: calc(100% - 2rem);
    }
}

/* ============================================
   Dark Mode Support
   ============================================ */

@media (prefers-color-scheme: dark) {
    .collaboration-toast {
        background: #2d3748;
        color: #fff;
    }
    
    .collaboration-toast-message {
        color: #a0aec0;
    }
    
    .collaboration-toast-close {
        color: #a0aec0;
    }
    
    .collaboration-toast-close:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* ============================================
   Loading State
   ============================================ */

.collaboration-loading {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px 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);
    }
}

/* ============================================
   Conflict Indicator
   ============================================ */

.collaboration-conflict {
    background: rgba(255, 193, 7, 0.1);
    border-left: 3px solid #ffc107;
    padding: 0.5rem;
    margin: 0.5rem 0;
    border-radius: 4px;
}

.collaboration-conflict-message {
    font-size: 0.85rem;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.collaboration-conflict-message i {
    font-size: 1.2rem;
}

/* ============================================
   Typing Indicator
   ============================================ */

.collaboration-typing {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(48, 188, 237, 0.1);
    border-radius: 6px;
    font-size: 0.85rem;
    color: #0c5460;
    margin-top: 0.5rem;
}

.collaboration-typing-dots {
    display: flex;
    gap: 3px;
}

.collaboration-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #17a2b8;
    animation: typing 1.4s infinite;
}

.collaboration-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.collaboration-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ============================================
   Editor Header Integration
   ============================================ */

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px 8px 0 0;
    gap: 1rem;
}

.editor-filename {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.editor-filename input {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.editor-filename input:focus {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    outline: none;
}

.editor-filename input:read-only {
    background: rgba(255, 255, 255, 0.1);
    cursor: not-allowed;
}

.editor-filename i {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.2rem;
}
