/**
 * Reply & Edit Feature Styles
 * WhatsApp-inspired UI for message actions
 */

/* ============================================
   Context Menu
   ============================================ */

.message-context-menu {
    position: fixed;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    padding: 6px 0;
    z-index: 99999;
    min-width: 160px;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.message-context-menu.active {
    opacity: 1;
    transform: scale(1);
}

.context-menu-item {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.15s ease;
    user-select: none;
}

.context-menu-item:hover {
    background: #f3f4f6;
}

.context-menu-item:active {
    background: #e5e7eb;
}

.context-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.context-label {
    font-size: 14px;
    color: #1f2937;
    font-weight: 500;
}

/* ============================================
   Reply Preview (Above Input)
   ============================================ */

.reply-preview {
    background: #f8fafc;
    border-left: 4px solid #4f46e5;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    animation: slideDown 0.2s ease;
}

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

.reply-preview-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #4f46e5;
}

.reply-preview-content {
    flex: 1;
    min-width: 0;
}

.reply-to-label {
    font-size: 12px;
    color: #4f46e5;
    font-weight: 600;
    margin-bottom: 4px;
}

.reply-to-message {
    font-size: 13px;
    color: #6b7280;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-preview-close {
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.15s ease;
    flex-shrink: 0;
    padding: 0;
}

.reply-preview-close:hover {
    background: #e5e7eb;
    color: #6b7280;
}

.reply-preview-close:active {
    transform: scale(0.95);
}

/* ============================================
   Edit Preview (Above Input)
   ============================================ */

.edit-preview {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    animation: slideDown 0.2s ease;
}

.edit-preview-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.edit-icon {
    font-size: 18px;
}

.edit-label {
    font-size: 13px;
    color: #92400e;
    font-weight: 600;
}

.edit-preview-close {
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #d97706;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.15s ease;
    flex-shrink: 0;
    padding: 0;
}

.edit-preview-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #92400e;
}

.edit-preview-close:active {
    transform: scale(0.95);
}

/* ============================================
   Reply Context in Message Bubble
   ============================================ */

.reply-context {
    background: rgba(0, 0, 0, 0.05);
    border-left: 3px solid #4f46e5;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.reply-context:hover {
    background: rgba(0, 0, 0, 0.08);
}

/* Styling for reply in sent messages */
.message.sent .reply-context,
.message-item.vendor .reply-context {
    background: rgba(255, 255, 255, 0.25);
    border-left-color: rgba(255, 255, 255, 0.6);
}

.message.sent .reply-context:hover,
.message-item.vendor .reply-context:hover {
    background: rgba(255, 255, 255, 0.35);
}

.reply-sender {
    font-size: 11px;
    font-weight: 600;
    color: #4f46e5;
    margin-bottom: 3px;
    text-transform: capitalize;
}

.message.sent .reply-sender,
.message-item.vendor .reply-sender {
    color: rgba(255, 255, 255, 0.95);
}

.reply-text {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.message.sent .reply-text,
.message-item.vendor .reply-text {
    color: rgba(255, 255, 255, 0.8);
}

/* ============================================
   Edited Label
   ============================================ */

.edited-label {
    font-size: 10px;
    color: #9ca3af;
    font-style: italic;
    margin-left: 4px;
    opacity: 0.8;
}

.message.sent .edited-label,
.message-item.vendor .edited-label {
    color: rgba(255, 255, 255, 0.7);
}

/* ============================================
   Toast Notification
   ============================================ */

.toast-notification {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    z-index: 100000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toast-notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

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

@media (max-width: 480px) {
    .message-context-menu {
        min-width: 140px;
        border-radius: 10px;
    }
    
    .context-menu-item {
        padding: 14px 16px;
    }
    
    .context-icon {
        font-size: 20px;
    }
    
    .context-label {
        font-size: 15px;
    }
    
    .reply-preview,
    .edit-preview {
        padding: 10px 12px;
    }
    
    .reply-to-label,
    .edit-label {
        font-size: 11px;
    }
    
    .reply-to-message {
        font-size: 12px;
    }
    
    .reply-preview-close,
    .edit-preview-close {
        width: 36px;
        height: 36px;
        font-size: 32px;
    }
    
    .reply-context {
        padding: 6px 10px;
        margin-bottom: 6px;
    }
    
    .reply-sender {
        font-size: 10px;
    }
    
    .reply-text {
        font-size: 11px;
    }
    
    .toast-notification {
        bottom: 80px;
        font-size: 13px;
        padding: 10px 20px;
    }
}

/* ============================================
   Tablet Adjustments
   ============================================ */

@media (min-width: 481px) and (max-width: 768px) {
    .message-context-menu {
        min-width: 170px;
    }
    
    .context-menu-item {
        padding: 13px 16px;
    }
}

/* ============================================
   Dark Mode Support (Optional)
   ============================================ */

@media (prefers-color-scheme: dark) {
    .message-context-menu {
        background: #1f2937;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }
    
    .context-menu-item:hover {
        background: #374151;
    }
    
    .context-menu-item:active {
        background: #4b5563;
    }
    
    .context-label {
        color: #f3f4f6;
    }
    
    .reply-preview {
        background: #1f2937;
    }
    
    .reply-to-label {
        color: #818cf8;
    }
    
    .reply-to-message {
        color: #d1d5db;
    }
    
    .edit-preview {
        background: #451a03;
    }
    
    .edit-label {
        color: #fbbf24;
    }
    
    .edit-preview-close {
        color: #fbbf24;
    }
}

/* ============================================
   Animation Performance
   ============================================ */

.message-context-menu,
.reply-preview,
.edit-preview,
.toast-notification {
    will-change: transform, opacity;
}

/* ============================================
   Accessibility
   ============================================ */

.context-menu-item:focus,
.reply-preview-close:focus,
.edit-preview-close:focus {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

.context-menu-item:focus:not(:focus-visible),
.reply-preview-close:focus:not(:focus-visible),
.edit-preview-close:focus:not(:focus-visible) {
    outline: none;
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .message-context-menu,
    .reply-preview,
    .edit-preview,
    .toast-notification,
    .edited-label {
        display: none !important;
    }
    
    .reply-context {
        background: #f3f4f6 !important;
        border-left-color: #6b7280 !important;
    }
}