#vh-chatbox-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#vh-chatbox-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2b7cf0, #1a54c4);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(30, 111, 217, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#vh-chatbox-toggle:hover {
    transform: scale(1.07);
    box-shadow: 0 8px 24px rgba(30, 111, 217, 0.55);
}

#vh-notify-dot {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 14px;
    height: 14px;
    background: #ff4757;
    border: 2px solid #fff;
    border-radius: 50%;
    animation: vh-pulse 1.4s infinite;
}

@keyframes vh-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

#vh-chatbox-panel {
    position: absolute;
    bottom: 78px;
    right: 0;
    width: 360px;
    max-width: 92vw;
    height: 520px;
    max-height: 72vh;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.2);
    overflow: hidden;
    opacity: 0;
    transform: translateY(14px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    display: flex;
    flex-direction: column;
}

#vh-chatbox-container.vh-open #vh-chatbox-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ===== Header ===== */
#vh-chatbox-header {
    background: linear-gradient(135deg, #2b7cf0, #1a54c4);
    color: #fff;
    padding: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

#vh-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

#vh-header-text strong {
    font-size: 15.5px;
    display: block;
}

#vh-header-subtext {
    margin: 3px 0 0;
    font-size: 12px;
    opacity: 0.92;
    display: flex;
    align-items: center;
    gap: 5px;
}

.vh-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

.vh-status-dot.vh-online { background: #3ddc84; }
.vh-status-dot.vh-offline { background: #ffb84d; }

.vh-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* ===== View 1: form ban đầu ===== */
#vh-start-view {
    padding: 18px;
    overflow-y: auto;
}

#vh-chatbox-form label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: #333;
    margin: 10px 0 4px;
}

#vh-chatbox-form label:first-child { margin-top: 0; }

#vh-chatbox-form input,
#vh-chatbox-form textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 11px;
    border: 1.5px solid #e2e5eb;
    border-radius: 10px;
    font-size: 13.5px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.15s ease;
}

#vh-chatbox-form input:focus,
#vh-chatbox-form textarea:focus {
    outline: none;
    border-color: #2b7cf0;
}

#vh-start-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

#vh-chatbox-submit {
    flex: 1;
    padding: 11px;
    background: linear-gradient(135deg, #2b7cf0, #1a54c4);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease;
}

#vh-chatbox-submit:hover { opacity: 0.9; }
#vh-chatbox-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.vh-icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1.5px solid #e2e5eb;
    background: #fff;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.vh-icon-btn:hover {
    background: #f2f6ff;
    border-color: #2b7cf0;
    color: #2b7cf0;
}

.vh-error-box {
    margin-top: 12px;
    padding: 12px;
    border-radius: 10px;
    font-size: 13.5px;
    line-height: 1.5;
    background: #fdeaea;
    color: #c62828;
}

/* ===== Attach preview chips ===== */
.vh-attach-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.vh-attach-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f2f4f7;
    border-radius: 8px;
    padding: 5px 8px;
    font-size: 11.5px;
    max-width: 160px;
}

.vh-attach-thumb {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    object-fit: cover;
    flex-shrink: 0;
}

.vh-attach-file-icon { font-size: 14px; }

.vh-attach-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 90px;
}

.vh-attach-remove {
    border: none;
    background: none;
    color: #888;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.vh-attach-remove:hover { color: #c62828; }

/* ===== View 2: khung chat ===== */
#vh-chat-ticket-info {
    padding: 9px 18px;
    font-size: 11px;
    color: #999;
    background: #fafbfc;
    flex-shrink: 0;
    border-bottom: 1px solid #f0f1f3;
}

#vh-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.vh-msg-row {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: vh-fade-in 0.2s ease;
}

@keyframes vh-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.vh-row-client {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.vh-row-admin { align-self: flex-start; }

.vh-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e2e5eb;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    font-weight: 700;
    flex-shrink: 0;
}

.vh-row-client .vh-msg-avatar {
    background: linear-gradient(135deg, #2b7cf0, #1a54c4);
    color: #fff;
}

.vh-msg-bubble {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.vh-msg-sender {
    font-size: 10.5px;
    font-weight: 700;
    color: #999;
    padding: 0 4px;
}

.vh-row-client .vh-msg-sender { text-align: right; }

.vh-msg-text {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    word-wrap: break-word;
}

.vh-row-client .vh-msg-text {
    background: linear-gradient(135deg, #2b7cf0, #1a54c4);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.vh-row-admin .vh-msg-text {
    background: #f0f2f5;
    color: #222;
    border-bottom-left-radius: 4px;
}

.vh-msg-image-wrap { display: block; }

.vh-msg-image {
    max-width: 180px;
    max-height: 180px;
    border-radius: 12px;
    display: block;
    object-fit: cover;
}

.vh-msg-file {
    padding: 8px 12px;
    border-radius: 10px;
    background: #f0f2f5;
    font-size: 12.5px;
    color: #333;
}

.vh-row-client .vh-msg-file {
    background: rgba(43,124,240,0.12);
    color: #1a54c4;
}

/* ===== Input row ===== */
#vh-chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #f0f1f3;
    flex-shrink: 0;
}

#vh-chat-input {
    flex: 1;
    resize: none;
    border: 1.5px solid #e2e5eb;
    border-radius: 18px;
    padding: 10px 15px;
    font-size: 13.5px;
    font-family: inherit;
    max-height: 80px;
    transition: border-color 0.15s ease;
}

#vh-chat-input:focus {
    outline: none;
    border-color: #2b7cf0;
}

#vh-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2b7cf0, #1a54c4);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.12s ease;
}

#vh-chat-send:hover { transform: scale(1.06); }

#vh-chat-attach-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

#vh-chat-attach-preview {
    padding: 0 12px;
}

#vh-chat-closed-notice {
    padding: 10px 16px;
    font-size: 12.5px;
    text-align: center;
    color: #888;
    background: #fafbfc;
    border-top: 1px solid #f0f1f3;
    flex-shrink: 0;
}

/* Scrollbar mảnh, dễ nhìn hơn */
#vh-chat-messages::-webkit-scrollbar,
#vh-start-view::-webkit-scrollbar {
    width: 5px;
}
#vh-chat-messages::-webkit-scrollbar-thumb,
#vh-start-view::-webkit-scrollbar-thumb {
    background: #dcdfe4;
    border-radius: 3px;
}

@media (max-width: 480px) {
    #vh-chatbox-panel {
        width: calc(100vw - 32px);
        right: -8px;
        height: 68vh;
    }
}
