/* --- NÚT TRÒN MỞ CHAT --- */
#ms-chat-toggle {
    position: fixed; bottom: 20px; right: 20px;
    width: 60px; height: 60px; border-radius: 50%;
    background-color: #0084FF;
    box-shadow: 0 4px 12px rgba(0, 132, 255, 0.4);
    border: none; cursor: pointer; z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s;
}
#ms-chat-toggle:hover { transform: scale(1.1); }
#ms-chat-toggle svg { width: 30px; height: 30px; fill: white; }

/* --- KHUNG CHAT CHÍNH --- */
#ms-chat-box {
    display: none; /* JS sẽ bật */
    flex-direction: column;
    position: fixed; bottom: 90px; right: 20px;
    width: 350px; height: 500px;
    background: #fff; border-radius: 18px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.15);
    z-index: 99999; overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    border: 1px solid #e5e5e5;
}

/* HEADER */
.ms-header {
    padding: 15px; background: #fff; border-bottom: 1px solid #f0f0f0;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02); height: 50px; box-sizing: border-box;
}
.ms-header-title { font-weight: 700; color: #0084FF; font-size: 16px; }
.ms-btn-icon { background: #f2f2f2; border: none; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; color: #333; font-weight: bold; display: flex; align-items: center; justify-content: center; }
.ms-btn-icon:hover { background: #e4e6eb; }

/* --- TRANG CHỦ (HOME VIEW) --- */
#ms-home-view {
    flex: 1; display: flex; flex-direction: column; overflow: hidden;
}
.ms-home-actions { padding: 20px; text-align: center; border-bottom: 1px solid #eee; }
.btn-new-chat {
    background: #ff4757; color: white; border: none;
    padding: 12px 25px; border-radius: 25px;
    font-weight: 600; font-size: 15px; cursor: pointer;
    box-shadow: 0 4px 10px rgba(255, 71, 87, 0.3);
    width: 100%; transition: transform 0.2s;
}
.btn-new-chat:hover { background: #ff6b81; transform: translateY(-2px); }

.ms-history-label { padding: 10px 20px 0; font-size: 13px; color: #888; font-weight: 600; }
.ms-history-list { flex: 1; overflow-y: auto; padding: 10px; }
.history-item {
    padding: 12px; border-radius: 10px; cursor: pointer;
    border-bottom: 1px solid #f5f5f5; transition: background 0.2s;
    display: flex; justify-content: space-between; align-items: center;
}
.history-item:hover { background: #f0f2f5; }
.hist-date { font-size: 14px; font-weight: 500; color: #333; }
.hist-status { font-size: 11px; padding: 2px 6px; border-radius: 4px; }
.st-open { background: #d1e7dd; color: #0f5132; }
.st-closed { background: #e2e3e5; color: #41464b; }

/* --- MÀN HÌNH CHAT (CHAT VIEW) --- */
#ms-chat-view {
    flex: 1; display: none; flex-direction: column; height: 100%;
}

/* Body Chat (Tin nhắn) */
.ms-body {
    flex: 1; /* QUAN TRỌNG: Đẩy Input xuống đáy */
    overflow-y: auto;
    padding: 15px;
    background: #fff;
    display: flex; flex-direction: column; gap: 8px;
}
.ms-body::-webkit-scrollbar { width: 5px; }
.ms-body::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }

/* Tin nhắn */
.ms-msg { max-width: 75%; padding: 8px 12px; border-radius: 18px; font-size: 14px; line-height: 1.4; word-wrap: break-word; position: relative; }
.ms-msg-bot { background: #e4e6eb; color: #050505; align-self: flex-start; border-bottom-left-radius: 4px; }
.ms-msg-user { background: #0084FF; color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.ms-time { font-size: 10px; margin-top: 3px; opacity: 0.7; text-align: right; display: block; }

/* Footer (Input) */
.ms-footer {
    padding: 10px;
    border-top: 1px solid #eee;
    background: #fff;
    display: flex; gap: 8px; align-items: center;
    /* Đảm bảo nằm dưới cùng */
    margin-top: auto; 
}
.ms-input { flex: 1; padding: 10px 15px; border-radius: 20px; background: #f0f2f5; border: none; outline: none; font-size: 14px; }
.ms-send-btn { background: none; border: none; color: #0084FF; font-weight: bold; cursor: pointer; font-size: 20px; padding: 0 5px; }
.btn-back { margin-right: 10px; font-size: 18px; cursor: pointer; color: #333; background: none; border: none; }