#tuvan-chat-toggle {
    position: fixed; bottom: 55px; right: 5px;
    background: #0073aa; color: #fff; border: 1px solid #ffffff91;
    padding: 0px 10px; border-radius: 50px;
    cursor: pointer; font-size: 16px; z-index: 9999;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

#tuvan-chat-widget {
    position: fixed; bottom: 80px; right: 20px;
    width: 340px; height: 450px; background: #fff;
    border: 1px solid #ccc; border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    display: none; flex-direction: column; z-index: 9999;
    font-family: Arial, sans-serif; overflow: hidden;
}

/* ================== HEADER ================== */
#tuvan-chat-header {
    background: #0073aa; color: #fff; padding: 12px 15px;
    display: flex; justify-content: space-between; align-items: center; 
    flex-shrink: 0; /* KHÓA CỨNG HEADER */
}
.tuvan-header-profile { display: flex; align-items: center; gap: 12px; }
.tuvan-avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255, 255, 255, 0.4); }
.tuvan-header-info { display: flex; flex-direction: column; }
.tuvan-name { font-weight: bold; font-size: 15px; letter-spacing: 0.5px; }
.tuvan-status { font-size: 12px; color: #e1e1e1; margin-top: 2px; }
.tuvan-status::before { content: ''; display: inline-block; width: 8px; height: 8px; background-color: #4cd137; border-radius: 50%; margin-right: 5px; }
#tuvan-chat-header button { background: none; border: none; color: white; cursor: pointer; font-size: 18px; font-weight: bold; opacity: 0.8; margin-right: 0em; padding: 0em; min-height: unset; line-height: unset;
}

/* ================== MÀN HÌNH ĐĂNG NHẬP ================== */
#tuvan-chat-login-screen {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 20px; background: #f4f7f6; text-align: center;
}
.tuvan-login-icon { font-size: 45px; margin-bottom: 10px; }
.tuvan-login-text { font-size: 14px; color: #333; margin-bottom: 20px; line-height: 1.4; }
#tuvan-phone-input { width: 90%; padding: 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 15px; text-align: center; outline: none; margin-bottom: 15px; }
#tuvan-phone-input:focus { border-color: #0073aa; }
#tuvan-start-btn { width: 90%; background: #0073aa; color: white; border: none; border-radius: 6px; font-size: 15px; font-weight: bold; cursor: pointer; margin-left: auto; margin-right: auto;}
.tuvan-login-note { font-size: 12px; color: #777; margin-top: 15px; font-style: italic; }

/* ================== MÀN HÌNH CHAT ================== */
#tuvan-chat-body { 
    flex: 1; /* Lấy hết khoảng trống còn lại */
    overflow-y: auto; 
    padding: 15px; 
    background: #f4f7f6; 
    min-height: 0; /* CHÌA KHÓA: Ép khung cuộn lại, không được đẩy footer */
}
.chat-msg-row { display: flex; gap: 10px; margin-bottom: 15px; align-items: flex-end; }
.chat-msg-row.bot { justify-content: flex-start; }
.chat-msg-row.user { justify-content: flex-end; }
.chat-msg-avatar { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.chat-message { padding: 10px 14px; font-size: 14px; line-height: 1.4; max-width: 75%; word-wrap: break-word; }
.bot-message { background: #fff; color: #333; border: 1px solid #e0e0e0; border-radius: 15px 15px 15px 4px; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.user-message { background: #0073aa; color: white; border-radius: 15px 15px 4px 15px; }
.chat-message.bot-message a { color: #0073aa; text-decoration: underline; font-weight: bold; }

/* CHÌA KHÓA: Fix kích thước ảnh để không bị tràn màn hình */
.tuvan-chat-img { 
    max-width: 100%; 
    max-height: 220px; /* Ảnh tối đa cao 220px */
    object-fit: contain; /* Hiển thị toàn bộ ảnh, thu nhỏ vừa viền */
    border-radius: 5px; 
    margin-bottom: 5px; 
    display: block; 
}

/* ================== FOOTER (KHUNG NHẬP CHỮ) ================== */
#tuvan-chat-footer { 
    display: flex; 
    padding: 10px 12px; 
    border-top: 1px solid #eee; 
    background: #fff; 
    align-items: center; 
    flex-shrink: 0; 
}

/* Format mới cho Nút Đính kèm */
#tuvan-chat-attach { 
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    background-color: #f0f2f5; /* Nền xám nhạt giống Zalo */
    cursor: pointer;
    color: #606770;
    margin-right: 8px;
    transition: all 0.2s ease;
    margin-bottom: 0em;
}

#tuvan-chat-attach:hover { 
    background-color: #e4e6eb; /* Đậm hơn khi rê chuột */
    color: #0073aa; 
}

#tuvan-chat-attach svg {
    width: 18px; 
    height: 18px;
    transform: rotate(45deg); /* Xoay nghiêng ghim giấy cho sành điệu */
}

/* Tối ưu lại ô nhập chữ và nút gửi cho cân đối với nút ghim */
#tuvan-chat-input { 
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    background: #f4f7f6;
    margin-bottom: 0em;
}

#tuvan-chat-send {
    background: none; 
	color: #ffffff; 
	border: none; 
	padding: 0 10px; 
	margin-left: 5px;  
	cursor: pointer; 
	font-weight: unset; 
	font-size: 15px; 
	border-radius: 100px; 
	margin-right: 0em; 
	min-width: 45px; 
	text-transform: none;
	margin-bottom: 0em;
}

#tuvan-chat-send:hover {
    opacity: 0.8;
}