/* Live Chat Widget Styles */
:root {
    --chat-primary: #667eea;
    --chat-primary-dark: #5568d3;
    --chat-success: #28a745;
    --chat-danger: #dc3545;
    --chat-warning: #ffc107;
}

/* Chat Bubble Button */
.chat-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    z-index: 9998;
}

.chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.chat-bubble i {
    color: white;
    font-size: 24px;
}

.chat-bubble-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--chat-danger);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

/* Chat Window */
.chat-window {
    position: fixed !important;
    bottom: 90px !important;
    right: 20px !important;
    width: 380px;
    height: 550px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    z-index: 99999 !important;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.chat-window.open {
    display: flex;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header-info {
    display: flex;
    align-items: center;
    flex: 1;
}

.chat-merchant-avatar {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    margin-right: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.chat-merchant-info h6 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.chat-status {
    display: flex;
    align-items: center;
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
}

.chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

.chat-status-dot.online {
    background: var(--chat-success);
}

.chat-status-dot.offline {
    background: #6c757d;
}

.chat-header-actions button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 18px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-header-actions button:hover {
    opacity: 1;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg-secondary);
}

.chat-message {
    display: flex;
    margin-bottom: 12px;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.sent {
    justify-content: flex-end;
}

.chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-shrink: 0;
    margin: 0 8px;
    position: relative;
}

.chat-message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.chat-message-avatar .avatar-fallback {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    font-size: 12px;
}

.chat-message.received .chat-message-avatar {
    order: -1;
}

.chat-message.sent .chat-message-avatar {
    order: 1;
}

.chat-message-sender {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.8;
}

.chat-message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
}

.chat-message.received .chat-message-bubble {
    background: var(--bg-card);
    border-bottom-left-radius: 4px;
}

.chat-message.sent .chat-message-bubble {
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message-text {
    font-size: 14px;
    line-height: 1.4;
}

.chat-message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
}

.chat-system-message {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin: 16px 0;
}

.chat-typing-indicator {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    background: var(--bg-card);
    border-radius: 16px;
    width: fit-content;
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    margin: 0 2px;
    animation: typingDot 1.4s infinite;
}

.chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}

/* Chat Input */
.chat-input {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}

.chat-input-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-input-wrapper {
    flex: 1;
    position: relative;
}

.chat-input-field {
    width: 100%;
    padding: 10px 40px 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    resize: none;
    max-height: 100px;
    font-family: inherit;
}

.chat-input-field:focus {
    outline: none;
    border-color: var(--chat-primary);
}

.chat-input-attachment {
    position: absolute;
    right: 8px;
    bottom: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
}

.chat-input-attachment:hover {
    color: var(--chat-primary);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.1);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-window {
        width: calc(100% - 20px);
        height: calc(100vh - 110px);
        right: 10px;
        bottom: 80px;
    }
    
    .chat-bubble {
        right: 10px;
        bottom: 10px;
    }
}

/* Merchant Chat Dashboard */
.chat-dashboard {
    height: calc(100vh - 120px);
    display: flex;
    gap: 0;
}

.chat-conversations-list {
    width: 350px;
    border-right: 1px solid var(--border-color);
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
}

.chat-conversations-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.chat-conversations-search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    margin-top: 8px;
}

.chat-conversations-items {
    flex: 1;
    overflow-y: auto;
}

.chat-conversation-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-conversation-item:hover {
    background: var(--bg-hover);
}

.chat-conversation-item.active {
    background: var(--bg-hover);
    border-left: 3px solid var(--chat-primary);
}

.chat-conversation-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.chat-conversation-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.chat-conversation-avatar .avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-primary-dark) 100%);
    color: white;
    font-weight: 600;
}

.chat-conversation-details {
    flex: 1;
    min-width: 0;
}

.chat-conversation-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-conversation-time {
    font-size: 11px;
    color: var(--text-muted);
}

.chat-conversation-preview {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-conversation-badge {
    background: var(--chat-primary);
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
}

.chat-main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.chat-empty-state i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}
