/* Global collaboration styles - add this to your main CSS file */

/* Enhanced input field styles for collaboration */
input[data-collaboration-id],
textarea[data-collaboration-id],
[contenteditable][data-collaboration-id] {
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/* Input focus styles with collaboration awareness */
input[data-collaboration-id]:focus,
textarea[data-collaboration-id]:focus,
[contenteditable][data-collaboration-id]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Collaboration-aware input containers */
.collaboration-input-container {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* Enhanced cursor styles */
.user-cursor {
    position: fixed !important;
    pointer-events: none !important;
    z-index: 10000 !important;
    transition: all 0.08s ease-out !important;
    will-change: transform;
}

.user-cursor .cursor-pointer {
    display: inline-block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.user-cursor .cursor-label {
    position: absolute;
    top: 20px;
    left: 0;
    color: white;
    padding: 3px 7px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(-5px);
    animation: cursor-label-appear 0.2s ease-out 0.5s forwards;
}

@keyframes cursor-label-appear {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Smooth cursor movement */
.user-cursor.moving {
    transition: all 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

/* Selection highlights */
.user-selection-highlight {
    position: absolute !important;
    pointer-events: none !important;
    z-index: 9999 !important;
    border-radius: 2px;
    mix-blend-mode: multiply;
    animation: selection-appear 0.2s ease-out;
}

@keyframes selection-appear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Text selection highlights for contenteditable */
.user-text-selection {
    background-color: rgba(59, 130, 246, 0.3) !important;
    border-radius: 2px;
    position: relative;
}

.user-text-selection::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 1px solid var(--selection-color, #3b82f6);
    border-radius: 3px;
    pointer-events: none;
}

/* Enhanced typing indicators */
.user-typing-indicator {
    position: absolute !important;
    display: flex;
    align-items: center;
    gap: 6px;
    background: white;
    padding: 6px 10px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 11px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    pointer-events: none !important;
    z-index: 9999 !important;
    border: 1px solid rgba(0, 0, 0, 0.08);
    animation: typing-indicator-appear 0.3s ease-out;
    max-width: 200px;
}

@keyframes typing-indicator-appear {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.user-typing-indicator::before {
    content: '';
    position: absolute;
    top: -5px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid white;
}

.typing-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1.5px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    flex-shrink: 0;
}

.typing-dots {
    font-size: 6px;
    line-height: 1;
    display: flex;
    gap: 1px;
}

.typing-dots span {
    display: inline-block;
    width: 2px;
    height: 2px;
    background: currentColor;
    border-radius: 50%;
    opacity: 0.4;
    animation: typing-dots 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typing-dots {
    0%, 80%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    40% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.typing-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Input field collaboration states */
.collaboration-input-container.has-collaborators input,
.collaboration-input-container.has-collaborators textarea,
.collaboration-input-container.has-collaborators [contenteditable] {
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.1);
}

/* Active collaboration indicator for inputs */
.collaboration-input-container::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    background: #10b981;
    border: 2px solid white;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
    transition: all 0.2s ease-out;
}

.collaboration-input-container.active::after {
    opacity: 1;
    transform: scale(1);
}

/* Minimap styles for page overview */
.collaboration-minimap {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 200px;
    height: 300px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.08);
    overflow: hidden;
    z-index: 9997;
    animation: minimap-appear 0.3s ease-out;
}

@keyframes minimap-appear {
    from {
        opacity: 0;
        transform: translateX(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.minimap-content {
    position: relative;
    width: 100%;
    height: 100%;
    background: #f8fafc;
    overflow: hidden;
}

.minimap-viewport {
    position: absolute;
    border: 2px solid #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    pointer-events: none;
    transition: all 0.1s ease-out;
}

.minimap-user-indicator {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    border: 1px solid white;
    transition: all 0.1s ease-out;
    animation: minimap-user-pulse 2s infinite;
}

@keyframes minimap-user-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Enhanced presence panel animations */
.presence-fade-in {
    animation: presence-fade-in 0.3s ease-out;
}

@keyframes presence-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-avatar-bounce {
    animation: user-avatar-bounce 0.4s ease-out;
}

@keyframes user-avatar-bounce {
    0% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(90deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Collaborative text editor styles */
.collaborative-editor {
    position: relative;
    min-height: 200px;
}

.collaborative-editor .user-selection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

.collaborative-editor .editor-content {
    position: relative;
    z-index: 2;
}

/* User mention styles */
.user-mention {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid rgba(59, 130, 246, 0.2);
    transition: all 0.2s;
}

.user-mention:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.4);
}

/* Notification styles for collaboration events */
.collaboration-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #10b981;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    z-index: 10001;
    animation: notification-slide-down 0.3s ease-out;
    max-width: 400px;
}

@keyframes notification-slide-down {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.collaboration-notification.leaving {
    animation: notification-slide-up 0.3s ease-out forwards;
}

@keyframes notification-slide-up {
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .user-cursor .cursor-label {
        display: none;
    }

    .user-typing-indicator {
        max-width: 150px;
        padding: 4px 8px;
        font-size: 10px;
    }

    .collaboration-minimap {
        width: 150px;
        height: 200px;
        top: 70px;
    }

    .collaboration-notification {
        max-width: calc(100vw - 40px);
        font-size: 13px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .user-typing-indicator {
        background: #1f2937;
        border-color: rgba(255, 255, 255, 0.1);
        color: #f9fafb;
    }

    .user-typing-indicator::before {
        border-bottom-color: #1f2937;
    }

    .collaboration-minimap {
        background: #1f2937;
        border-color: rgba(255, 255, 255, 0.1);
    }

    .minimap-content {
        background: #111827;
    }

    .collaboration-notification {
        background: #1f2937;
        color: #f9fafb;
        border-color: rgba(255, 255, 255, 0.1);
    }

    .user-mention {
        background: rgba(59, 130, 246, 0.2);
        color: #93c5fd;
        border-color: rgba(59, 130, 246, 0.3);
    }

    .user-mention:hover {
        background: rgba(59, 130, 246, 0.3);
        border-color: rgba(59, 130, 246, 0.5);
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .user-cursor,
    .user-selection-highlight,
    .user-typing-indicator {
        transition: none !important;
        animation: none !important;
    }

    .typing-dots span {
        animation: none !important;
        opacity: 1 !important;
    }

    .minimap-user-indicator {
        animation: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .user-cursor .cursor-label {
        border: 1px solid currentColor;
    }

    .user-typing-indicator {
        border: 2px solid currentColor;
    }

    .user-selection-highlight {
        border-width: 2px;
    }
}

/* Print styles - hide collaboration elements */
@media print {
    .user-cursor,
    .user-selection-highlight,
    .user-typing-indicator,
    .collaboration-panel,
    .collaboration-minimap,
    .collaboration-notification {
        display: none !important;
    }
}