/* --- Professional Chat System --- */
.reformix-chat {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.reformix-chat.minimized {
    height: 60px;
    overflow: hidden;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, var(--reformix-primary-color, #667eea) 0%, var(--reformix-primary-dark, #764ba2) 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 16px 16px 0 0;
    cursor: pointer;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.chat-info {
    flex: 1;
}

.chat-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-status.online::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.chat-close:hover {
    background: rgba(255,255,255,0.1);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
}

.chat-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
}

.loading-dots {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    text-align: center;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

/* Message Bubbles */
.chat-message {
    display: flex;
    margin-bottom: 12px;
    animation: messageSlide 0.3s ease-out;
    width: 100%;
    clear: both;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.admin {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
}

.chat-message.user .message-bubble {
    background: linear-gradient(135deg, var(--reformix-primary-color, #667eea) 0%, var(--reformix-primary-dark, #764ba2) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.admin .message-bubble {
    background: white;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
}

.message-bubble p {
    margin: 0;
    line-height: 1.4;
}

.message-bubble img {
    max-width: 200px;
    max-height: 150px;
    width: auto;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    display: block;
    object-fit: cover;
}

.message-bubble img:hover {
    transform: scale(1.02);
}

.image-attachment {
    display: inline-block;
    max-width: 200px;
}

.image-attachment img {
    max-width: 100%;
    max-height: 150px;
    width: auto;
    height: auto;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    display: block;
    object-fit: cover;
}

.message-bubble .caption {
    margin-top: 8px;
    font-size: 13px;
    opacity: 0.9;
}

/* File Attachment Styles */
.file-attachment {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.15);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.2);
    max-width: 280px;
    min-width: 200px;
    transition: all 0.2s ease;
    position: relative;
}

.chat-message.admin .file-attachment {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.file-attachment .file-icon {
    font-size: 20px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    flex-shrink: 0;
}

.chat-message.admin .file-attachment .file-icon {
    background: #e2e8f0;
}

.file-attachment .file-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.file-attachment .file-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    color: inherit;
}

.file-attachment .file-size {
    font-size: 12px;
    opacity: 0.8;
    color: inherit;
}

.file-attachment .download-btn {
    color: inherit;
    text-decoration: none;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.file-attachment .download-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.1);
}

.chat-message.admin .file-attachment .download-btn:hover {
    background: #cbd5e1;
}

/* Video Attachment Styles */
.video-attachment {
    max-width: 250px;
}

.video-attachment video {
    width: 100%;
    max-width: 200px;
    border-radius: 8px;
    margin-bottom: 8px;
}

.video-attachment .file-info {
    text-align: center;
    margin-bottom: 8px;
}

.video-attachment .file-name {
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 2px;
}

.video-attachment .file-size {
    font-size: 11px;
    opacity: 0.8;
}

/* Caption Styles */
.image-caption,
.video-caption,
.file-caption {
    margin-top: 8px;
    font-size: 13px;
    opacity: 0.9;
    font-style: italic;
    line-height: 1.3;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.chat-message.admin .message-time {
    text-align: left;
}

/* Input Area */
.chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    border-radius: 0 0 16px 16px;
}

.input-wrapper {
    display: flex;
    align-items: center;
    border-radius: 24px;
    padding: 8px;
    gap: 8px;
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.input-wrapper:focus-within {
    border-color: #667eea;
    background: white;
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    resize: none;
    outline: none;
    font-size: 16px;
    line-height: 1.5;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    overflow: hidden;
}

.input-wrapper textarea::placeholder {
    color: #9ca3af;
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.attach-btn, .send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
    flex-shrink: 0;
    min-width: 36px;
    min-height: 36px;
}

.attach-btn .dashicons,
.send-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.attach-btn {
    background: var(--wp-admin-theme-color, #0073aa);
    color: white;
}

.attach-btn:hover {
    background: var(--wp-admin-theme-color-darker-10, #005a87);
    color: white;
}

.send-btn {
    background: var(--wp-admin-theme-color, #0073aa);
    color: white;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--reformix-primary-light, rgba(102, 126, 234, 0.3));
}

.send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.send-btn .spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* File Preview */
.file-preview {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    margin-bottom: 8px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-preview img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
}

.file-preview .file-icon {
    width: 60px;
    height: 60px;
    background: #f3f4f6;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 24px;
}

.file-preview .file-name {
    flex: 1;
    font-size: 13px;
    color: #374151;
    word-break: break-all;
}

.remove-preview {
    background: #ef4444;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    margin-left: auto;
}

/* Image Modal */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-modal.show {
    opacity: 1;
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.modal-content img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
}

.close-modal {
    position: absolute;
    top: -40px;
    right: 0;
    background: rgba(255,255,255,0.9);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
}

/* Toast Notifications */
.chat-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ef4444;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 10001;
}

.chat-toast.show {
    transform: translateX(0);
}

.chat-toast.error {
    background: #ef4444;
}

.chat-toast.success {
    background: #10b981;
}

/* Typing Indicator */
.typing-indicator {
    animation: fadeIn 0.3s ease-out;
}

.typing-dots {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-toast.info {
    background: #3b82f6;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.3);
}

/* Mobile Responsive - Enhanced */
@media (max-width: 768px) {
    .reformix-chat {
        width: calc(100% - 20px) !important;
        height: calc(100vh - 40px) !important;
        bottom: 10px !important;
        right: 10px !important;
        left: 10px !important;
        border-radius: 12px !important;
    }
    
    .reformix-chat.minimized {
        height: 60px !important;
        width: calc(100% - 20px) !important;
    }
    
    .chat-header {
        padding: 12px 16px !important;
        border-radius: 12px 12px 0 0 !important;
    }
    
    .chat-info h4 {
        font-size: 14px !important;
    }
    
    .chat-status {
        font-size: 11px !important;
    }
    
    .chat-messages {
        padding: 12px !important;
        flex: 1 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    .message-bubble {
        max-width: 85% !important;
        padding: 10px 12px !important;
        font-size: 14px !important;
    }
    
    .chat-input-area {
        padding: 12px !important;
        border-radius: 0 0 12px 12px !important;
    }
    
    .input-wrapper {
        border-radius: 20px !important;
    }
    
    .input-wrapper textarea {
        padding: 10px 12px !important;
        font-size: 14px !important;
        min-height: 18px !important;
        max-height: 80px !important;
    }
    
    .input-actions {
        padding: 6px 10px 6px 0 !important;
        gap: 6px !important;
    }
    
    .attach-btn, .send-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 14px !important;
    }
    
    .file-preview {
        margin-bottom: 6px !important;
        padding: 6px !important;
    }
    
    .file-preview img {
        width: 50px !important;
        height: 50px !important;
    }
    
    .file-preview .file-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 20px !important;
    }
    
    .file-preview .file-name {
        font-size: 12px !important;
    }
    
    .remove-preview {
        width: 20px !important;
        height: 20px !important;
        font-size: 10px !important;
    }
}

/* Legacy container support */
.reformix-chat-container {
    margin-top: 30px;
    border-radius: 16px;
    background: white;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.reformix-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.reformix-chat-messages {
    height: 400px;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
}

.reformix-chat-form {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.reformix-chat-form textarea {
    flex: 1;
    border-radius: 24px;
    padding: 12px 16px;
    resize: none;
    outline: none;
    font-size: 14px;
    background: #f9fafb;
    transition: all 0.2s;
}

.reformix-chat-form textarea:focus {
    border-color: #667eea;
    background: white;
}

.reformix-chat-form button {
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.reformix-chat-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Uploading Indicator */
.uploading-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0.8;
}

.uploading-indicator .loading-dots {
    display: flex;
    gap: 4px;
}

.uploading-indicator .loading-dots span {
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.uploading-indicator p {
    margin: 0;
    font-size: 13px;
}

/* Drag and Drop */
.chat-messages.drag-over {
    background: #f0f9ff;
    border: 2px dashed #3b82f6;
    position: relative;
}

.chat-messages.drag-over::after {
    content: 'Drop file here to upload';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #3b82f6;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10;
}
@media (max-width: 480px) {
    .reformix-chat {
        width: calc(100% - 10px) !important;
        height: calc(100vh - 20px) !important;
        bottom: 5px !important;
        right: 5px !important;
        left: 5px !important;
        border-radius: 8px !important;
    }
    
    .chat-header {
        padding: 10px 12px !important;
        border-radius: 8px 8px 0 0 !important;
    }
    
    .chat-avatar {
        width: 32px !important;
        height: 32px !important;
        font-size: 14px !important;
    }
    
    .chat-info h4 {
        font-size: 13px !important;
    }
    
    .chat-status {
        font-size: 10px !important;
    }
    
    .chat-messages {
        padding: 8px !important;
    }
    
    .message-bubble {
        max-width: 90% !important;
        padding: 8px 10px !important;
        font-size: 13px !important;
    }
    
    .message-bubble img {
        max-width: 150px !important;
        max-height: 100px !important;
    }
    
    .file-attachment {
        max-width: 200px !important;
        min-width: 150px !important;
        padding: 8px !important;
    }
    
    .file-attachment .file-icon {
        width: 28px !important;
        height: 28px !important;
        font-size: 16px !important;
    }
    
    .file-attachment .file-name {
        font-size: 12px !important;
    }
    
    .file-attachment .file-size {
        font-size: 10px !important;
    }
    
    .chat-input-area {
        padding: 8px !important;
        border-radius: 0 0 8px 8px !important;
    }
    
    .input-wrapper textarea {
        padding: 8px 10px !important;
        font-size: 13px !important;
        min-height: 16px !important;
        max-height: 60px !important;
    }
    
    .attach-btn, .send-btn {
        width: 28px !important;
        height: 28px !important;
        font-size: 12px !important;
    }
    
    .message-time {
        font-size: 10px !important;
    }
}

@media (max-width: 320px) {
    .reformix-chat {
        width: calc(100% - 5px) !important;
        height: calc(100vh - 10px) !important;
        bottom: 2px !important;
        right: 2px !important;
        left: 2px !important;
        border-radius: 6px !important;
    }
    
    .chat-header {
        padding: 8px 10px !important;
        border-radius: 6px 6px 0 0 !important;
    }
    
    .chat-avatar {
        width: 28px !important;
        height: 28px !important;
        font-size: 12px !important;
    }
    
    .chat-info h4 {
        font-size: 12px !important;
    }
    
    .chat-messages {
        padding: 6px !important;
    }
    
    .message-bubble {
        max-width: 95% !important;
        padding: 6px 8px !important;
        font-size: 12px !important;
    }
    
    .chat-input-area {
        padding: 6px !important;
        border-radius: 0 0 6px 6px !important;
    }
    
    .input-wrapper textarea {
        padding: 6px 8px !important;
        font-size: 12px !important;
    }
    
    .attach-btn, .send-btn {
        width: 24px !important;
        height: 24px !important;
        font-size: 10px !important;
    }
}

/* Admin Chat Mobile Responsive */
@media (max-width: 768px) {
    .reformix-admin-chat-container {
        height: calc(100vh - 100px) !important;
        flex-direction: column !important;
    }
    
    .chat-sidebar {
        width: 100% !important;
        height: 200px !important;
        border-right: none !important;
        border-bottom: 1px solid #e1e5e9 !important;
    }
    
    .chat-main {
        flex: 1 !important;
        min-height: 0 !important;
    }
    
    .conversation-item {
        padding: 10px 12px !important;
    }
    
    .conversation-item .user-avatar {
        width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
        margin-right: 8px !important;
    }
    
    .conversation-name {
        font-size: 13px !important;
    }
    
    .conversation-preview {
        font-size: 12px !important;
    }
    
    .conversation-time {
        font-size: 11px !important;
    }
    
    .chat-messages {
        padding: 12px !important;
    }
    
    .message-bubble {
        max-width: 85% !important;
        padding: 8px 12px !important;
        font-size: 13px !important;
    }
    
    .chat-input-container {
        padding: 12px !important;
    }
    
    .input-wrapper {
        padding: 6px 12px !important;
    }
    
    .input-wrapper textarea {
        font-size: 13px !important;
        min-height: 18px !important;
        max-height: 80px !important;
    }
    
    .btn-attach, .btn-send {
        width: 32px !important;
        height: 32px !important;
    }
}

@media (max-width: 480px) {
    .reformix-admin-chat-container {
        height: calc(100vh - 80px) !important;
    }
    
    .chat-sidebar {
        height: 150px !important;
    }
    
    .sidebar-header {
        padding: 12px !important;
    }
    
    .search-box input {
        padding: 6px 10px 6px 28px !important;
        font-size: 13px !important;
    }
    
    .conversation-item {
        padding: 8px 10px !important;
    }
    
    .conversation-item .user-avatar {
        width: 28px !important;
        height: 28px !important;
        font-size: 11px !important;
        margin-right: 6px !important;
    }
    
    .conversation-name {
        font-size: 12px !important;
    }
    
    .conversation-preview {
        font-size: 11px !important;
    }
    
    .conversation-time {
        font-size: 10px !important;
    }
    
    .chat-header {
        padding: 12px 16px !important;
    }
    
    .user-info .user-avatar {
        width: 49px !important;
        height: 35px !important;
        font-size: 12px !important;
        margin-right: 8px !important;
    }
    
    .user-details h3 {
        font-size: 14px !important;
    }
    
    .user-status {
        font-size: 11px !important;
    }
    
    .chat-messages {
        padding: 8px !important;
    }
    
    .message-bubble {
        max-width: 90% !important;
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
    
    .message-time {
        font-size: 10px !important;
    }
    
    .chat-input-container {
        padding: 8px !important;
    }
    
    .input-wrapper {
        padding: 4px 8px !important;
    }
    
    .input-wrapper textarea {
        font-size: 12px !important;
        min-height: 16px !important;
        max-height: 60px !important;
    }
    
    .btn-attach, .btn-send {
        width: 28px !important;
        height: 28px !important;
    }
}

/* Customer Information Popup */
.chat-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.customer-info-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.customer-info-btn:hover {
    background: rgba(255,255,255,0.1);
}



.customer-info-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
}

.popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    cursor: pointer;
}

.popup-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    overflow: hidden;
}

.popup-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}



.popup-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}



.popup-body {
    padding: 20px;
}

.customer-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #9ca3af;
}

.customer-profile {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.customer-avatar {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    flex-shrink: 0;
}

.customer-info h4 {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 600;
    color: #374151;
}

.contact-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #6b7280;
}

.contact-item i {
    color: #667eea;
    width: 16px;
    flex-shrink: 0;
}

.contact-item a {
    color: #667eea;
    text-decoration: none;
}

.contact-item a:hover {
    text-decoration: underline;
}

/* Touch-friendly improvements */
@media (max-width: 768px) {
    .attach-btn, .send-btn, .btn-attach, .btn-send {
        min-height: 44px !important;
        min-width: 44px !important;
        touch-action: manipulation !important;
    }
    
    .conversation-item {
        min-height: 44px !important;
        touch-action: manipulation !important;
    }
    
    .customer-info-btn {
        min-height: 44px !important;
        min-width: 44px !important;
        touch-action: manipulation !important;
    }
    
    .file-preview-remove, .remove-preview {
        min-height: 32px !important;
        min-width: 32px !important;
        touch-action: manipulation !important;
    }
    
    .popup-content {
        width: 95%;
        max-width: none;
    }
    
    .customer-profile {
        flex-direction: column;
        text-align: center;
    }
    
    .customer-avatar {
        align-self: center;
    }
}

/* Ensure proper scrolling on mobile */
@media (max-width: 768px) {
    .chat-messages, .reformix-chat-messages, .conversations-list {
        -webkit-overflow-scrolling: touch !important;
        overflow-y: auto !important;
    }
    
    .reformix-chat {
        -webkit-transform: translateZ(0) !important;
        transform: translateZ(0) !important;
    }
}

/* Enhanced File Upload Feedback */
.file-status {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 10px;
    background: #e3f2fd;
    color: #1976d2;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.file-status.uploading {
    background: #fff3e0;
    color: #f57c00;
}

.file-status.success {
    background: #e8f5e8;
    color: #2e7d32;
}

.file-status.error {
    background: #ffebee;
    color: #c62828;
}

/* File Upload Progress */
.upload-progress {
    width: 100%;
    height: 3px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}

.upload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

/* File attachment hover effects */
.file-attachment:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.chat-message.user .file-attachment:hover {
    background: rgba(255,255,255,0.25);
}

.chat-message.admin .file-attachment:hover {
    background: #e2e8f0;
}

/* Better file type icons */
.file-attachment .file-icon i[class*="pdf"] {
    color: #e74c3c !important;
}

.file-attachment .file-icon i[class*="doc"] {
    color: #2980b9 !important;
}

.file-attachment .file-icon i[class*="image"] {
    color: #27ae60 !important;
}

.file-attachment .file-icon i[class*="archive"] {
    color: #f39c12 !important;
}

/* File upload animation */
@keyframes fileUpload {
    0% { opacity: 0; transform: scale(0.8); }
    50% { opacity: 0.5; transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

.file-attachment.uploading {
    animation: fileUpload 0.6s ease-out;
}

/* File sent confirmation */
.file-sent-indicator {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #10b981;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    animation: bounceIn 0.5s ease-out;
}

@keyframes bounceIn {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* File Upload Button Fixes */
.reformix-send-files-btn,
.btn-send-file {
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: #28a745 !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 6px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
    margin-top: 10px !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    min-height: 36px !important;
    text-decoration: none !important;
    box-sizing: border-box !important;
}

.reformix-send-files-btn:hover,
.btn-send-file:hover {
    background: #218838 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3) !important;
}

.reformix-send-files-btn:disabled,
.btn-send-file:disabled {
    background: #6c757d !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

/* File Preview Message Styling */
.reformix-file-preview-msg {
    background: #f8f9fa !important;
    border: 2px dashed #28a745 !important;
    border-radius: 8px !important;
    padding: 15px !important;
    margin: 10px 0 !important;
    animation: slideIn 0.3s ease !important;
}

.reformix-file-counter {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 10px !important;
    font-size: 12px !important;
    color: #28a745 !important;
    font-weight: 600 !important;
}

.reformix-counter-left {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

.reformix-check-icon {
    background: #28a745 !important;
    color: white !important;
    border-radius: 50% !important;
    width: 16px !important;
    height: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 10px !important;
    font-weight: bold !important;
}

.reformix-close-preview {
    background: #dc3545 !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 20px !important;
    height: 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    font-size: 12px !important;
    font-weight: bold !important;
}

.reformix-file-container {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    margin-bottom: 10px !important;
}

.reformix-file-thumbnail {
    position: relative !important;
    flex-shrink: 0 !important;
}

.reformix-file-thumbnail img {
    max-width: 60px !important;
    max-height: 60px !important;
    border-radius: 4px !important;
    object-fit: cover !important;
}

.reformix-file-icon {
    width: 60px !important;
    height: 60px !important;
    background: #e9ecef !important;
    border-radius: 4px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #6c757d !important;
}

.reformix-file-check {
    position: absolute !important;
    top: -4px !important;
    right: -4px !important;
    background: #28a745 !important;
    color: white !important;
    border-radius: 50% !important;
    width: 16px !important;
    height: 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 10px !important;
    font-weight: bold !important;
}

.reformix-file-name {
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #495057 !important;
    word-break: break-word !important;
}

/* File Menu Styling */
#reformix-file-menu {
    position: absolute !important;
    bottom: 100% !important;
    left: 0 !important;
    background: white !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    z-index: 1000 !important;
    min-width: 120px !important;
    display: none !important;
}

.reformix-menu-option {
    display: block !important;
    width: 100% !important;
    padding: 10px 15px !important;
    border: none !important;
    background: none !important;
    text-align: left !important;
    cursor: pointer !important;
    font-size: 14px !important;
    color: #374151 !important;
    transition: background 0.2s !important;
}

.reformix-menu-option:hover {
    background: #f3f4f6 !important;
}

.reformix-menu-option:first-child {
    border-radius: 8px 8px 0 0 !important;
}

.reformix-menu-option:last-child {
    border-radius: 0 0 8px 8px !important;
}

/* Attach Button Styling */
#reformix-show-file-menu {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: var(--reformix-primary-color, #667eea) !important;
    color: white !important;
    border: none !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
    position: relative !important;
}

#reformix-show-file-menu:hover {
    background: var(--reformix-primary-dark, #5a67d8) !important;
    transform: scale(1.05) !important;
}

/* Force visibility for all file upload related elements */
.reformix-attach-btn,
.attach-btn,
.btn-attach,
#reformix-show-file-menu {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 10 !important;
}

/* Animation for file preview */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}



/* User Chat Styles */
.file-preview-box {
    background: #e5e7eb;
    color: #374151;
    border-radius: 16px;
    padding: 12px 16px;
    margin: 8px 0;
    text-align: center;
}

.preview-status {
    color: var(--reformix-primary-color, #3b82f6);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.preview-name {
    color: #374151;
    font-weight: 600;
    margin-bottom: 4px;
}

.preview-size {
    color: #6b7280;
    font-size: 12px;
    margin-bottom: 12px;
}

.send-file-btn {
    background: var(--reformix-primary-color, #3b82f6);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    margin-right: 8px;
}

.cancel-file-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.send-file-btn:hover {
    background: var(--reformix-primary-dark, #2563eb);
}

.cancel-file-btn:hover {
    background: #dc2626;
}

.user-message {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin: 8px 0;
}

.admin-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin: 8px 0;
}

.user-message .message-bubble {
    background: var(--reformix-primary-color, #3b82f6);
    color: white;
    padding: 8px 12px;
    border-radius: 16px;
    max-width: 80%;
    word-wrap: break-word;
}

.user-message .message-bubble .file-message {
    background: transparent !important;
    color: #374151 !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.user-message .message-bubble:has(.file-message) {
    background: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.admin-message .message-bubble {
    background: #e5e7eb;
    color: #374151;
    padding: 8px 12px;
    border-radius: 16px;
    max-width: 80%;
    word-wrap: break-word;
}

.admin-message .message-bubble .file-message {
    background: transparent !important;
    color: #374151 !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.admin-message .message-bubble:has(.file-message) {
    background: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

/* Force remove background from any message bubble containing files */
.message-bubble:has(img),
.message-bubble:has(.file-message) {
    background: transparent !important;
    padding: 0 !important;
    border-radius: 0 !important;
}

.message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}

.message-image {
    max-width: 200px;
    border-radius: 8px;
    cursor: pointer;
}

.file-message {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: inherit;
}

.file-message a {
    color: inherit;
    font-size: 12px;
    text-decoration: underline;
}

.upload-message {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin: 8px 0;
    opacity: 0.7;
}

.upload-message div {
    background: var(--reformix-primary-color, #3b82f6);
    color: white;
    padding: 8px 12px;
    border-radius: 16px;
}

.empty-chat {
    text-align: center;
    color: #6b7280;
    padding: 20px;
}

.file-preview-message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin: 8px 0;
}

.file-preview-message .file-preview-box {
    max-width: 80%;
    margin: 0;
}