/**
 * BizCity WebChat Widget Styles
 * ChatGPT-like Refresh – Modern & Clean
 */

/* === Font & base === */
.bizcity-chat-embedded,
.bizcity-chat-embedded * {
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    box-sizing: border-box;
}

/* === EMBEDDED CHAT CONTAINER === */
.bizcity-chat-embedded {
    position: relative !important;
    display: flex !important;
    flex-direction: column;
    width: 100% !important;
    height: 70vh !important;
    max-height: 90vh !important;
    margin: 16px auto;
    padding: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.08);
    overflow: hidden;
}

.bizcity-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #ffffff;
}

/* === CHAT HEADER === */
.bizcity-chat-header {
    background: linear-gradient(135deg, #10a37f 0%, #0d8a6b 100%);
    color: #fff;
    padding: 16px 20px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    box-shadow: 0 2px 8px rgba(16, 163, 127, 0.2);
}

.bizcity-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.bizcity-chat-info {
    flex: 1;
}

.bizcity-chat-info h3 {
    margin: 0 0 2px 0;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}

.bizcity-chat-status {
    font-size: 12px;
    opacity: 0.9;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 400;
}

/* === MESSAGES AREA === */
.bizcity-chat-messages {
    flex: 1 1 auto;
    background: #f9fafb;
    padding: 24px 20px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    width: 100%;
    text-align: left;
}

/* Scrollbar tinh gọn */
.bizcity-chat-messages::-webkit-scrollbar { 
    width: 6px; 
}
.bizcity-chat-messages::-webkit-scrollbar-thumb { 
    background: #cbd5e1; 
    border-radius: 10px; 
}
.bizcity-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
.bizcity-chat-messages::-webkit-scrollbar-track { 
    background: transparent; 
}

/* Message container */
.bizcity-message {
    margin: 12px 0;
    display: flex;
    width: 100%;
    animation: messageSlideIn 0.3s ease-out;
}

.bizcity-message:first-child {
    margin-top: 0;
}

.bizcity-message:last-child {
    margin-bottom: 0;
}

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

/* User messages - aligned right */
.bizcity-message-user {
    justify-content: flex-end;
}

/* Bot messages - aligned left */
.bizcity-message-bot {
    justify-content: flex-start;
}

/* Message bubbles */
.bizcity-message-content {
    display: inline-block;
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    line-height: 1.5;
    font-size: 14px;
    white-space: pre-wrap;
}

/* User bubble - ChatGPT green */
.bizcity-message-user .bizcity-message-content {
    background: linear-gradient(135deg, #10a37f 0%, #0ea472 100%);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 2px 8px rgba(16,163,127,0.2);
}

/* Bot bubble - White with border */
.bizcity-message-bot .bizcity-message-content {
    background: #ffffff;
    color: #374151;
    border-radius: 18px 18px 18px 4px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Message content with image - adjust padding - using class instead of :has */
.bizcity-message-content .bizcity-message-image {
    padding: 0;
    margin: 0 0 8px 0;
}

.bizcity-message-content .bizcity-message-image:only-child {
    margin: 0;
}

/* Message text inside content with image */
.bizcity-message-content .bizcity-message-text {
    padding: 0;
    margin: 0;
}

/* Typing indicator */
.bizcity-typing .bizcity-message-content {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border-radius: 14px 14px 14px 2px;
    background: #ffffff;
    border: 1px solid #eef2f7;
}

.bizcity-typing .bizcity-message-content::after {
    content: '';
    display: flex;
    gap: 4px;
}

/* Typing dots animation */
.bizcity-typing-dot {
    width: 6px;
    height: 6px;
    background: #6b7280;
    border-radius: 50%;
    display: inline-block;
    animation: typingBlink 1s infinite;
}

.bizcity-typing-dot:nth-child(2) { animation-delay: .15s; }
.bizcity-typing-dot:nth-child(3) { animation-delay: .3s; }

@keyframes typingBlink {
    0%, 80%, 100% { 
        opacity: .2; 
        transform: translateY(0); 
    }
    40% { 
        opacity: 1; 
        transform: translateY(-2px); 
    }
}

/* Error messages */
.bizcity-message-error .bizcity-message-content {
    background: #fee2e2;
    border-color: #fecaca;
    color: #991b1b;
}

/* Markdown/code styling in bot messages */
.bizcity-message-bot .bizcity-message-content pre,
.bizcity-message-bot .bizcity-message-content code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
    background: rgba(11, 16, 33, 0.1);
    color: #0b1021;
    padding: 2px 6px;
    border-radius: 6px;
}

.bizcity-message-bot .bizcity-message-content pre {
    display: block;
    padding: 10px;
    overflow-x: auto;
}

/* === INPUT AREA === */
.bizcity-chat-input-area {
    position: relative;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 12px 16px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
}

/* Attach button */
.bizcity-chat-attach-btn {
    background: transparent;
    border: none;
    color: #6b7280;
    height: 40px;
    width: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.bizcity-chat-attach-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.bizcity-chat-attach-btn:active {
    transform: scale(0.95);
}

.bizcity-chat-attach-btn svg {
    display: block;
}

/* Textarea */
#bizcity-chat-input {
    flex: 1;
    min-height: 40px;
    max-height: 120px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    color: #111827;
    border-radius: 20px;
    padding: 10px 16px;
    outline: none;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    font-family: inherit;
    transition: all 0.2s ease;
}

#bizcity-chat-input:focus {
    border-color: #10a37f;
    box-shadow: 0 0 0 3px rgba(16,163,127,0.1);
}

#bizcity-chat-input::placeholder {
    color: #9ca3af;
}

/* Send button */
.bizcity-chat-send-btn {
    background: #10a37f;
    border: none;
    color: #fff;
    height: 40px;
    width: 40px;
    min-width: 40px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.bizcity-chat-send-btn:hover {
    background: #0d8a6b;
    transform: scale(1.05);
}

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

.bizcity-chat-send-btn svg {
    display: block;
}

/* === IMAGE PREVIEW === */
.bizcity-chat-preview {
    padding: 8px 16px 0;
    background: #fff;
}

.bizcity-image-preview {
    display: inline-flex;
    align-items: flex-start;
    gap: 8px;
    background: #f9fafb;
    padding: 8px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.bizcity-image-preview img {
    max-width: 200px;
    max-height: 150px;
    width: auto;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
    display: block;
}

.bizcity-remove-image {
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    padding: 0;
}

.bizcity-remove-image:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* === IMAGE IN MESSAGE === */
.bizcity-message-image {
    margin-bottom: 8px;
    display: block !important;
    line-height: 0;
    overflow: visible;
}

.bizcity-message-image img {
    max-width: 280px !important;
    max-height: 200px !important;
    width: auto !important;
    height: auto !important;
    border-radius: 12px;
    display: block !important;
    object-fit: cover;
    background: #f0f0f0;
    visibility: visible !important;
    opacity: 1 !important;
}

.bizcity-message-user .bizcity-message-image img {
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.bizcity-message-bot .bizcity-message-image img {
    border: 1px solid #e5e7eb;
}

.bizcity-message-text {
    margin-top: 0;
    display: block;
}

/* Message with both image and text */
.bizcity-message-content.has-image {
    max-width: 85%;
    padding: 8px;
}

/* === Mobile Responsive === */
@media (max-width: 640px) {
    .bizcity-chat-embedded {
        height: 75vh !important;
        border-radius: 12px;
    }
    
    .bizcity-chat-messages {
        padding: 14px 12px;
    }
    
    .bizcity-message-content {
        max-width: 90%;
    }
    
    .bizcity-message-image img {
        max-width: 240px;
        max-height: 180px;
    }
    
    .bizcity-image-preview img {
        max-width: 160px;
        max-height: 120px;
    }
    
    .bizcity-chat-input-area {
        padding: 10px 12px;
    }
}

/* === Floating Chat (Coming soon) === */
.bizcity-chat-floating {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 360px;
    height: 500px;
    z-index: 9999;
}

/* === Popup Chat (Coming soon) === */
.bizcity-chat-popup {
    /* Popup styles */
}

