/* NÚT TRÒN MỞ CHAT NỔI */
.mh-chat-launcher {
    position: fixed;
    right: 25px;
    bottom: 94px;
    z-index: 9990;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #0284c7;
    color: #ffffff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(2, 132, 199, 0.36);
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}
.mh-chat-launcher:hover {
    transform: scale(1.06);
    background: #0369a1;
}

/* CHẤM ĐỎ THÔNG BÁO TIN NHẮN MỚI */
.mh-chat-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 99px;
    background: #e60012;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 6px rgba(230, 0, 18, 0.45);
    display: none;
    animation: mhClientBadgePulse 1.6s infinite;
}

@keyframes mhClientBadgePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.16); }
    100% { transform: scale(1); }
}

/* KHUNG CỬA SỔ CHAT */
.mh-chat-box {
    position: fixed;
    right: 25px;
    bottom: 94px;
    z-index: 9998;
    width: 375px;
    max-width: calc(100vw - 24px);
    height: 520px;
    max-height: calc(100vh - 110px);
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
.mh-chat-box.open { display: flex; }

/* HEADER KHUNG CHAT CÓ LOGO FAVICON & HIỆU ỨNG ONLINE */
.mh-chat-head {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    border-top: 3px solid #e60012;
    padding: 11px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.mh-chat-head-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.mh-head-logo-wrap {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.mh-head-logo-wrap img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    border-radius: 50%;
}

.mh-chat-head-title {
    font-size: 14.5px;
    font-weight: 600;
    color: #0f172a;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mh-chat-head-sub {
    font-size: 12px;
    font-weight: 500;
    color: #16a34a;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.mh-online-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #16a34a;
    display: inline-block;
    position: relative;
    flex-shrink: 0;
}
.mh-online-pulse-dot::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: rgba(22, 163, 74, 0.4);
    animation: mhOnlineRing 1.6s infinite ease-out;
}

@keyframes mhOnlineRing {
    0% { transform: scale(0.7); opacity: 1; }
    100% { transform: scale(1.9); opacity: 0; }
}

.mh-chat-close {
    background: #f1f5f9;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #475569;
    cursor: pointer;
    flex-shrink: 0;
}
.mh-chat-close:hover { background: #e2e8f0; }

/* FORM KHỞI TẠO */
.mh-chat-start-form {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}
.mh-chat-field label {
    display: block;
    font-size: 12.5px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 4px;
}
.mh-chat-input, .mh-chat-select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 13.5px;
    background: #ffffff;
    color: #0f172a;
    box-sizing: border-box;
    outline: none;
}
.mh-chat-input:focus, .mh-chat-select:focus { border-color: #0284c7; }
.mh-btn-start-chat {
    margin-top: 4px;
    padding: 10px;
    background: #e60012;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* KHUNG TIN NHẮN & AVATAR TỪNG TIN NHẮN */
.mh-chat-messages {
    flex: 1;
    padding: 14px 12px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mh-msg-item {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 88%;
}
.mh-msg-item.client {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.mh-msg-item.admin {
    align-self: flex-start;
}

.mh-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #ffffff;
}
.mh-msg-item.admin .mh-msg-avatar img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}
.mh-msg-item.client .mh-msg-avatar {
    background: #e0f2fe;
    color: #0284c7;
    border-color: #bae6fd;
}

.mh-msg-content-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.mh-msg-item.client .mh-msg-content-col { align-items: flex-end; }
.mh-msg-item.admin .mh-msg-content-col { align-items: flex-start; }

.mh-msg-sender {
    font-size: 11px;
    color: #64748b;
    margin-bottom: 3px;
}

.mh-msg-bubble {
    padding: 9px 13px;
    border-radius: 13px;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
}
.mh-msg-item.client .mh-msg-bubble {
    background: #0284c7;
    color: #ffffff;
    border-bottom-right-radius: 3px;
}
.mh-msg-item.admin .mh-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 3px;
}

.mh-chat-img-attach {
    max-width: 205px;
    border-radius: 11px;
    border: 1px solid #e2e8f0;
    display: block;
    cursor: zoom-in;
    background: #ffffff;
}

/* THẺ SẢN PHẨM BÁO GIÁ TRONG KHUNG CHAT */
.mh-chat-prod-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px;
    width: 225px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.mh-chat-prod-card img {
    width: 100%;
    height: 105px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 7px;
    border: 1px solid #f1f5f9;
}
.mh-chat-prod-title {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 4px;
    line-height: 1.35;
}
.mh-chat-prod-price {
    font-size: 13.5px;
    font-weight: 600;
    color: #e60012;
    margin-bottom: 8px;
}
.mh-chat-prod-btn {
    display: block;
    text-align: center;
    padding: 6px;
    background: #fff5f5;
    color: #e60012;
    border: 1px solid #fecaca;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
}

/* POPUP CHỌN SẢN PHẨM */
.mh-chat-catalog-popup {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 8px 10px;
    max-height: 170px;
    overflow-y: auto;
    display: none;
}
.mh-cat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12.5px;
}
.mh-cat-item:hover { background: #f1f5f9; }
.mh-cat-item img { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; }

/* THANH NHẬP TIN NHẮN & GỬI ẢNH */
.mh-chat-footer {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.mh-btn-tool-icon {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    width: 34px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    cursor: pointer;
    flex-shrink: 0;
}
.mh-btn-tool-icon:hover {
    background: #f1f5f9;
    color: #0284c7;
}
.mh-chat-text-input {
    flex: 1;
    min-width: 0;
    height: 36px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 13.5px;
    outline: none;
}
.mh-chat-text-input:focus { border-color: #0284c7; }
.mh-btn-send-msg {
    background: #0284c7;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 0 12px;
    height: 36px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .mh-chat-launcher {
        right: 16px;
        bottom: 78px;
        width: 48px;
        height: 48px;
    }
    .mh-chat-box {
        right: 12px;
        bottom: 76px;
        width: calc(100vw - 24px);
    }
}
