/* Chat V15 - Complete Styles (Merged from V11 + V15 additions) */
/* ==========================================
   CHAT V11 - MESSENGER PERFECT + NEW FEATURES
   ========================================== */

.chat-v10-container {
    max-width: 900px;
    background: #fff;
    overflow: hidden;
    /*font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;*/
}

/* ===== HEADER ===== */
.chat-v10-header {
    background: linear-gradient(135deg, #005d32 0%, #35af76 100%);
    padding: 5px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
}

.chat-v10-title {
    display: flex;
    gap: 12px;
    align-items: center;
}

.chat-v10-icon {
    font-size: 32px;
}

.chat-v10-room-name {
    font-size: 18px;
    font-weight: 600;
}

.chat-v10-status {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    opacity: 0.9;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.connecting {
    background: #ffc107;
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    background: #4caf50;
}

.status-indicator.disconnected {
    background: #f44336;
}

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

/* V15: Header actions container (online badge + fullscreen button) */
.chat-v10-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-v10-online {
    background: #0b5030;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.online-count {
    font-weight: 700;
    color: #00e109;
}

/* ===== MESSAGES AREA ===== */
.chat-v10-messages {
    background: linear-gradient(to bottom, #f0f2f5 0%, #e4e6eb 100%);
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    scroll-behavior: smooth;
}

.chat-v10-loading {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #198754;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== V11: SCROLL TO BOTTOM BUTTON ===== */
.scroll-to-bottom {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.75);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 100;
    animation: slideUpButton 0.3s ease;
}

.scroll-to-bottom.show {
    display: flex;
}

.scroll-to-bottom:hover {
    background: rgba(0, 0, 0, 0.85);
    transform: scale(1.1);
}

.scroll-to-bottom:active {
    transform: scale(0.95);
}

@keyframes slideUpButton {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Load more button */
.load-more-btn {
    text-align: center;
    padding: 12px;
    margin-bottom: 16px;
}

.load-more-btn button {
    background: #fff;
    border: 1px solid #ddd;
    padding: 8px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    color: #198754;
    font-weight: 600;
    transition: all 0.2s;
}

.load-more-btn button:hover {
    background: #198754;
    color: #fff;
    border-color: #198754;
}

.load-more-btn button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Message bubble - LAYOUT ĐÚNG: OTHERS LEFT, MY RIGHT */
.message-bubble {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: flex-end;
    animation: slideIn 0.3s ease;
}

/* OTHERS messages - BÊN TRÁI */
.message-bubble.others {
    flex-direction: row;
    justify-content: flex-start;
}

/* MY messages - BÊN PHẢI */
.message-bubble.own {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

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

/* Highlight animation khi click reply */
@keyframes highlightPulse {
    0% {
        transform: scale(1);
        background-color: transparent;
    }
    50% {
        transform: scale(1.05);
        background-color: rgba(102, 126, 234, 0.15);
    }
    100% {
        transform: scale(1);
        background-color: transparent;
    }
}

.message-bubble.highlight {
    animation: highlightPulse 0.6s ease;
}

/* Avatar - BÊN CẠNH bubble như Messenger */
.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.message-avatar-fallback {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #198754 0%, #764ba2 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

/* OTHERS: Avatar bên trái */
.message-bubble.others .message-avatar,
.message-bubble.others .message-avatar-fallback {
    order: 1;
}

/* MY: Không hiển thị avatar riêng của mình */
.message-bubble.own .message-avatar,
.message-bubble.own .message-avatar-fallback {
    display: none;
}

.message-content {
    max-width: 65%;
    display: flex;
    flex-direction: column;
}

/* OTHERS: Content bên phải avatar */
.message-bubble.others .message-content {
    order: 2;
    align-items: flex-start;
}

/* MY: Content bên trái (vì flex-direction: row-reverse) */
.message-bubble.own .message-content {
    align-items: flex-end;
}

.message-author {
    font-size: 12px;
    font-weight: 600;
    color: #65676b;
    margin-bottom: 4px;
    padding: 0 4px;
}

/* MY: Không hiển thị tên mình */
.message-bubble.own .message-author {
    display: none;
}

/* Reply preview in message */
.message-reply-preview {
    background: rgba(0,0,0,0.06);
    border-left: 3px solid #198754;
    padding: 6px 10px;
    border-radius: 8px;
    margin-bottom: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.message-reply-preview:hover {
    background: rgba(0,0,0,0.1);
}

.message-bubble.own .message-reply-preview {
    border-left: none;
    border-right: 3px solid #fff;
}

.reply-preview-author {
    font-weight: 600;
    color: #198754;
    font-size: 11px;
}

.message-bubble.own .reply-preview-author {
    color: #fff;
}

.reply-preview-text {
    color: #65676b;
    margin-top: 2px;
    /* V15 FIX: Allow text to wrap instead of overflow */
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    max-width: 100%;
    /* Limit to 2 lines max for cleaner preview */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.message-bubble.own .reply-preview-text {
    color: rgba(255,255,255,0.9);
}

/* Message text bubble */
.message-text {
    background: #fff;
    padding: 8px 12px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    color: #050505;
    /* V15 FIX: Force long text to wrap - no overflow */
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    max-width: 100%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* MY messages: gradient background */
.message-bubble.own .message-text {
    background: linear-gradient(135deg, #002514 0%, #198754 100%);
    color: #fff;
}

/* ===== V11: IMAGE ZOOM FEATURE ===== */
.message-image {
    margin-top: 4px;
}

.message-image img {
    max-width: 280px;
    max-height: 280px;
    border-radius: 12px;
    cursor: zoom-in;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.message-image img:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

/* Lightbox Modal */
.image-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.image-lightbox.show {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
    animation: zoomIn 0.3s ease;
}

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

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* Message actions */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    padding: 0 4px;
}

.message-bubble.own .message-actions {
    justify-content: flex-end;
}

.btn-action {
    background: transparent;
    border: none;
    color: #65676b;
    font-size: 11px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-action:hover {
    background: rgba(0,0,0,0.05);
}

/* V11: Like button - Chỉ đỏ cho user thả */
.btn-action.btn-like {
    position: relative;
}

.btn-action.btn-like .icon {
    font-size: 13px;
    transition: transform 0.2s;
}

.btn-action.btn-like.liked .icon {
    transform: scale(1.2);
}

/* Chỉ user thả mới thấy đỏ */
.btn-action.btn-like.liked {
    color: #e91e63;
}

/* ===== GUEST NOTICE ===== */
.chat-v10-guest-notice {
    background: linear-gradient(135deg, #830007 0%, #000000 100%);
    color: #fff;
    padding: 5px 20px;
    text-align: center;
    font-size: 14px;
}

.chat-v10-guest-notice a {
    color: #fff;
    font-weight: 600;
    text-decoration: underline;
    margin-left: 8px;
}

.chat-v10-guest-notice a:hover {
    text-decoration: none;
}

/* ===== INPUT AREA ===== */
.chat-v10-input {
    background: #fff;
    border-top: 1px solid #e4e6eb;
}

/* Reply preview in input */
.reply-preview {
    background: #f0f2f5;
    border-bottom: 1px solid #e4e6eb;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reply-content {
    flex: 1;
}

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

.reply-to-text {
    font-size: 13px;
    color: #65676b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-cancel {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #65676b;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reply-cancel:hover {
    background: rgba(0,0,0,0.05);
}

/* Image preview */
.image-preview {
    padding: 12px 20px;
    background: #f0f2f5;
    border-bottom: 1px solid #e4e6eb;
    position: relative;
}

.image-preview img {
    max-width: 120px;
    max-height: 120px;
    border-radius: 8px;
}

.image-cancel {
    position: absolute;
    top: 16px;
    right: 24px;
    background: #f44336;
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
}

/* Input row */
.input-row {
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.btn-upload {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-upload:hover {
    background: #f0f2f5;
}

.message-input {
    flex: 1;
    border: none;
    background: #f0f2f5;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
}

.message-input:focus {
    outline: none;
    background: #e4e6eb;
}

.btn-send {
    background: linear-gradient(135deg, #002514 0%, #198754 100%);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-send:hover {
    transform: scale(1.05);
}

.btn-send:active {
    transform: scale(0.95);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .chat-v10-container {
        margin: 0;
        border-radius: 0;
    }
    
    .message-content {
        max-width: 75%;
    }
    
    .message-image img {
        max-width: 100%;
    }
    
    .scroll-to-bottom {
        bottom: 15px;
        right: 15px;
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
}
/**
 * Chat V15 - Additional Styles
 * Extends Chat V11 with:
 * - Message highlight animation
 * - Admin delete buttons
 * - Global online badge
 */

/* V15: Message highlight animation */
.message-highlighted {
    animation: messageHighlight 2s ease-out;
    box-shadow: 0 0 20px rgba(124, 58, 237, 0.6) !important;
    transform-origin: center;
}

@keyframes messageHighlight {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(124, 58, 237, 0);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(124, 58, 237, 0.8);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(124, 58, 237, 0);
    }
}

/* V15: Admin delete button */
.btn-admin-delete {
    background: #ef4444 !important;
    color: #fff !important;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.btn-admin-delete:hover {
    background: #dc2626 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-admin-delete .icon {
    font-size: 14px;
}

/* V15: Delete all messages from user button */
.btn-admin-delete-all {
    background: #dc2626 !important;
    color: #fff !important;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
}

.btn-admin-delete-all:hover {
    background: #b91c1c !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.4);
}

.btn-admin-delete-all .icon {
    font-size: 14px;
}

/* V15: Admin badge on messages */
.message-bubble.admin-message::before {
    content: "ADMIN";
    position: absolute;
    top: -8px;
    right: 10px;
    background: #7c3aed;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 3px;
    z-index: 1;
}

/* V15: Global online badge */
.chat-global-online-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #10b981;
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.chat-global-online-badge::before {
    content: "🌍";
    font-size: 14px;
}

.chat-global-online {
    font-weight: 600;
}

/* V15: Fullscreen button */
.btn-fullscreen {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.btn-fullscreen:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.btn-fullscreen:active {
    transform: scale(0.95);
}

/* Fullscreen mode styles */
.chat-v10-container.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    z-index: 9999999999 !important;
    border-radius: 0 !important;
    margin: 0 auto !important;
}

.chat-v10-container.fullscreen .chat-v10-messages {
       height: calc(100vh - 200px) !important;
}

/* V15: Context menu for admin actions */
.admin-context-menu {
    position: fixed;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    z-index: 9999;
    min-width: 200px;
}

.admin-context-menu-item {
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.admin-context-menu-item.danger {
    color: #ef4444;
}

.admin-context-menu-item.danger:hover {
    background: #fee2e2;
}

/* V15: Message actions spacing (add room for admin button) */
.message-actions {
    gap: 8px; /* Ensure spacing between buttons */
}

.message-bubble.own .btn-admin-delete {
    /* Hide admin delete on own messages */
    display: none;
}

/* V15: Improve avatar display for custom avatars */
.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e5e7eb;
}

.message-avatar-fallback {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    border: 2px solid #e5e7eb;
}

/* V15: Smooth transitions */
.message-bubble {
    transition: all 0.3s ease;
}

.message-bubble:hover {
    transform: translateY(-1px);
}

/* V15: Loading state for delete action */
.message-bubble.deleting {
    opacity: 0.5;
    pointer-events: none;
}

.message-bubble.deleting::after {
    content: "Đang xóa...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 10;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .btn-admin-delete {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .btn-admin-delete .icon {
        font-size: 12px;
    }
    
    .message-highlighted {
        animation: messageHighlightMobile 1.5s ease-out;
    }
    
    @keyframes messageHighlightMobile {
        0%, 100% {
            transform: scale(1);
        }
        50% {
            transform: scale(1.02);
        }
    }
}
