﻿/**
 * MESSAGING OFF-CANVAS ADVANCED FEATURES CSS
 * Phase 5: Typing indicators, read receipts, reactions, attachments
 */

/* ============================================================================
   TYPING INDICATORS
   ============================================================================ */

.typing-indicator-wrapper {
    padding: var(--oc-spacing-md);
    animation: fadeIn 200ms ease;
}

    .typing-indicator-wrapper .typing-indicator {
        display: flex !important;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        color: var(--oc-gray-600);
        font-size: 0.875rem;
        width: auto !important;
    }

    .typing-indicator-wrapper .typing-text {
        white-space: nowrap;
        display: block;
        width: auto !important;
        height: auto !important;
        border-radius: 0 !important;
        background: transparent !important;
        animation: none !important;
    }

    .typing-indicator-wrapper .typing-dots {
        display: flex;
        gap: 0.25rem;
        align-items: center;
        flex-wrap: nowrap;
        flex-direction: row;
    }

        .typing-indicator-wrapper .typing-dots > span {
            width: 0.25rem !important;
            height: 0.25rem !important;
            border-radius: 50% !important;
            background: var(--oc-gray-400) !important;
            animation: typing 1.4s infinite !important;
            flex-shrink: 0;
            display: block !important;
        }

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   READ RECEIPTS
   ============================================================================ */

.read-receipt {
    color: var(--oc-primary);
    font-size: 0.875rem;
    margin-left: 4px;
}

.message.own .read-receipt {
    color: rgba(255, 255, 255, 0.8);
}

.read-receipt i {
    animation: checkPulse 400ms ease;
}

@keyframes checkPulse {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ============================================================================
   REACTIONS
   ============================================================================ */

.reaction-picker {
    position: fixed;
    background: white;
    border-radius: var(--oc-radius-lg);
    box-shadow: var(--oc-shadow-lg);
    padding: var(--oc-spacing-sm);
    display: flex;
    gap: var(--oc-spacing-xs);
    z-index: calc(var(--offcanvas-z-index) + 10);
    animation: reactionPickerIn 200ms ease;
}

@keyframes reactionPickerIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.reaction-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: var(--oc-radius-md);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 150ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .reaction-btn:hover {
        background: var(--oc-gray-100);
        transform: scale(1.2);
    }

.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--oc-spacing-xs);
    margin-top: var(--oc-spacing-sm);
}

.reaction-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--oc-radius-full);
    border: 1px solid var(--oc-gray-300);
    background: white;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 150ms ease;
}

    .reaction-bubble:hover {
        background: var(--oc-gray-50);
        transform: translateY(-2px);
        box-shadow: var(--oc-shadow-sm);
    }

    .reaction-bubble.own-reaction {
        background: var(--oc-primary-light);
        border-color: var(--oc-primary);
        color: var(--oc-primary);
    }

.reaction-emoji {
    font-size: 1rem;
}

.reaction-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--oc-gray-700);
}

.reaction-bubble.own-reaction .reaction-count {
    color: var(--oc-primary);
}

/* Add reaction button on message hover */
.message-bubble {
    position: relative;
}

.message:hover .add-reaction-btn {
    opacity: 1;
}

.add-reaction-btn {
    position: absolute;
    top: -10px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: var(--oc-radius-full);
    background: white;
    border: 1px solid var(--oc-gray-300);
    box-shadow: var(--oc-shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all 150ms ease;
    z-index: 10;
}

    .add-reaction-btn:hover {
        background: var(--oc-gray-100);
        transform: scale(1.1);
    }

/* ============================================================================
   FILE ATTACHMENTS
   ============================================================================ */

.composer-attach-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--oc-radius-md);
    background: transparent;
    border: none;
    color: var(--oc-gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 150ms ease;
    flex-shrink: 0;
}

    .composer-attach-btn:hover {
        background: var(--oc-gray-100);
        color: var(--oc-primary);
    }

.message-attachment {
    margin-top: var(--oc-spacing-sm);
    padding: var(--oc-spacing-sm);
    background: var(--oc-gray-100);
    border-radius: var(--oc-radius-md);
    display: flex;
    align-items: center;
    gap: var(--oc-spacing-sm);
}

.message.own .message-attachment {
    background: rgba(255, 255, 255, 0.2);
}

.attachment-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--oc-radius-md);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--oc-primary);
    font-size: 1.25rem;
}

.message.own .attachment-icon {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

.attachment-info {
    flex: 1;
    min-width: 0;
}

.attachment-name {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-size {
    font-size: 0.75rem;
    color: var(--oc-gray-600);
}

.message.own .attachment-size {
    color: rgba(255, 255, 255, 0.8);
}

.attachment-download {
    width: 32px;
    height: 32px;
    border-radius: var(--oc-radius-md);
    background: white;
    border: none;
    color: var(--oc-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 150ms ease;
    flex-shrink: 0;
}

    .attachment-download:hover {
        transform: scale(1.1);
        box-shadow: var(--oc-shadow-sm);
    }

.message.own .attachment-download {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

/* Drag and drop overlay */
.conversation-messages.drag-over::after {
    content: 'Drop files here to upload';
    position: absolute;
    inset: 0;
    background: rgba(0, 122, 255, 0.1);
    border: 2px dashed var(--oc-primary);
    border-radius: var(--oc-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--oc-primary);
    z-index: 1000;
    pointer-events: none;
}

/* Upload progress */
.upload-progress {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 300px;
    background: white;
    border-radius: var(--oc-radius-lg);
    box-shadow: var(--oc-shadow-lg);
    padding: var(--oc-spacing-md);
    z-index: calc(var(--offcanvas-z-index) + 20);
    animation: slideUp 200ms ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.upload-item {
    display: flex;
    align-items: center;
    gap: var(--oc-spacing-sm);
    margin-bottom: var(--oc-spacing-sm);
}

.upload-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--oc-radius-md);
    background: var(--oc-primary-light);
    color: var(--oc-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.upload-info {
    flex: 1;
    min-width: 0;
}

.upload-name {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-bar {
    height: 4px;
    background: var(--oc-gray-200);
    border-radius: var(--oc-radius-full);
    margin-top: 4px;
    overflow: hidden;
}

.upload-bar-fill {
    height: 100%;
    background: var(--oc-primary);
    transition: width 300ms ease;
}

/* ============================================================================
   @MENTIONS
   ============================================================================ */

.mention {
    background: var(--oc-primary-light);
    color: var(--oc-primary);
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: all 150ms ease;
}

    .mention:hover {
        background: var(--oc-primary);
        color: white;
    }

.mention-autocomplete {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--oc-gray-300);
    border-radius: var(--oc-radius-md);
    box-shadow: var(--oc-shadow-md);
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 8px;
    z-index: 10;
}

.mention-item {
    padding: var(--oc-spacing-sm) var(--oc-spacing-md);
    display: flex;
    align-items: center;
    gap: var(--oc-spacing-sm);
    cursor: pointer;
    transition: background 150ms ease;
}

    .mention-item:hover,
    .mention-item.selected {
        background: var(--oc-gray-100);
    }

.mention-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--oc-radius-full);
    background: var(--oc-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.mention-name {
    flex: 1;
    font-size: 0.9375rem;
    font-weight: 500;
}

.mention-role {
    font-size: 0.8125rem;
    color: var(--oc-gray-600);
}

/* ============================================================================
   MESSAGE ACTIONS
   ============================================================================ */

.message-actions {
    position: absolute;
    top: -12px;
    right: 8px;
    background: white;
    border: 1px solid var(--oc-gray-300);
    border-radius: var(--oc-radius-md);
    box-shadow: var(--oc-shadow-sm);
    display: none;
    gap: 2px;
    padding: 2px;
    z-index: 10;
}

.message:hover .message-actions {
    display: flex;
}

.message-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: var(--oc-radius-sm);
    color: var(--oc-gray-600);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 150ms ease;
}

    .message-action-btn:hover {
        background: var(--oc-gray-100);
        color: var(--oc-primary);
    }

/* ============================================================================
   LINK PREVIEWS
   ============================================================================ */

.link-preview {
    margin-top: var(--oc-spacing-sm);
    border: 1px solid var(--oc-gray-300);
    border-radius: var(--oc-radius-md);
    overflow: hidden;
    transition: all 150ms ease;
}

    .link-preview:hover {
        box-shadow: var(--oc-shadow-sm);
    }

.link-preview-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.link-preview-content {
    padding: var(--oc-spacing-sm);
}

.link-preview-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-preview-description {
    font-size: 0.8125rem;
    color: var(--oc-gray-600);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.link-preview-url {
    font-size: 0.75rem;
    color: var(--oc-gray-500);
    margin-top: 4px;
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 768px) {
    .reaction-picker {
        left: 50% !important;
        transform: translateX(-50%);
    }

    .upload-progress {
        right: 10px;
        left: 10px;
        width: auto;
    }

    .message-actions {
        position: static;
        display: flex;
        margin-top: var(--oc-spacing-sm);
    }
}
