/**
 * Collaboration Styles
 * Real-time collaboration cursor and selection display
 *
 * Phase 3 of SparkSheets Collaboration Implementation
 */

/* ========================================
   Remote User Cursors
   ======================================== */

.collaboration-cursor {
    position: absolute;
    pointer-events: none;
    z-index: 1000;
    transition: all 0.1s ease-out;
}

.collaboration-cursor__caret {
    position: relative;
    width: 2px;
    height: 1.2em;
    background-color: currentColor;
    margin-left: -1px;
    animation: cursor-blink 1s step-end infinite;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.collaboration-cursor__label {
    position: absolute;
    bottom: 100%;
    left: -2px;
    padding: 2px 6px;
    border-radius: 4px 4px 4px 0;
    font-size: 11px;
    font-weight: 500;
    color: white;
    background-color: currentColor;
    white-space: nowrap;
    line-height: 1.2;
    transform: translateY(-2px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Fade in/out animation */
.collaboration-cursor--entering {
    animation: cursor-enter 0.2s ease-out forwards;
}

.collaboration-cursor--leaving {
    animation: cursor-leave 0.2s ease-out forwards;
}

@keyframes cursor-enter {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes cursor-leave {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

/* ========================================
   Remote User Selection Highlight
   ======================================== */

.collaboration-selection {
    position: absolute;
    pointer-events: none;
    z-index: 999;
    opacity: 0.25;
    border-radius: 2px;
}

/* ========================================
   Presence Indicator (Online Users)
   ======================================== */

.collaboration-presence {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.05));
    border-radius: 20px;
}

.collaboration-presence__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.collaboration-presence__avatar:hover {
    transform: scale(1.1);
}

.collaboration-presence__avatar--stacked {
    margin-left: -8px;
    border: 2px solid var(--bg-primary, #1a1a1a);
}

.collaboration-presence__avatar:first-child {
    margin-left: 0;
}

.collaboration-presence__count {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary, #2a2a2a);
    color: var(--text-secondary, #aaa);
    font-size: 11px;
    font-weight: 500;
    margin-left: -8px;
    border: 2px solid var(--bg-primary, #1a1a1a);
}

/* ========================================
   Column Active User Indicator
   ======================================== */

.column-editing-indicator {
    position: absolute;
    top: -24px;
    left: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background-color: var(--user-color, #4ECDC4);
    color: white;
    font-size: 11px;
    font-weight: 500;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 100;
    animation: indicator-fade-in 0.2s ease-out;
}

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

.column-editing-indicator::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 8px;
    width: 8px;
    height: 8px;
    background-color: inherit;
    transform: rotate(45deg);
}

.column-editing-indicator__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: white;
    animation: editing-pulse 1s ease-in-out infinite;
}

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

/* ========================================
   Connection Status Indicator
   ======================================== */

.collaboration-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.05));
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary, #aaa);
}

.collaboration-status__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--status-color, #888);
}

.collaboration-status--connected .collaboration-status__dot {
    background: #4CAF50;
    box-shadow: 0 0 6px rgba(76, 175, 80, 0.5);
}

.collaboration-status--syncing .collaboration-status__dot {
    background: #FFC107;
    animation: status-pulse 0.5s ease-in-out infinite;
}

.collaboration-status--disconnected .collaboration-status__dot {
    background: #f44336;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========================================
   Offline Banner
   ======================================== */

.collaboration-offline-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: rgba(244, 67, 54, 0.95);
    color: white;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    animation: banner-slide-up 0.3s ease-out;
}

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

.collaboration-offline-banner__icon {
    font-size: 18px;
}

.collaboration-offline-banner__retry {
    margin-left: 8px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease;
}

.collaboration-offline-banner__retry:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========================================
   Responsive adjustments
   ======================================== */

@media (max-width: 768px) {
    .collaboration-presence__avatar {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }

    .collaboration-cursor__label {
        font-size: 10px;
        padding: 1px 4px;
    }

    .column-editing-indicator {
        font-size: 10px;
        padding: 2px 6px;
        top: -20px;
    }
}

/* ========================================
   Dark mode adjustments
   ======================================== */

.dark-mode .collaboration-presence {
    background: rgba(255, 255, 255, 0.05);
}

.dark-mode .collaboration-status {
    background: rgba(255, 255, 255, 0.05);
}

/* ========================================
   TipTap Collaboration Cursor (from Y.js)
   ======================================== */

/* Remote user cursor caret */
.ProseMirror .collaboration-cursor__caret {
    position: relative;
    border-left: 2px solid currentColor;
    border-right: none;
    margin-left: -1px;
    margin-right: -1px;
    pointer-events: none;
    word-break: normal;
}

/* Remote user cursor label */
.ProseMirror .collaboration-cursor__label {
    position: absolute;
    top: -1.4em;
    left: -1px;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px 3px 3px 0;
    white-space: nowrap;
    user-select: none;
}
