/* SMP Chat Hub – widget */
.smp-chb { --smp-chb-primary: #0d6efd; --smp-chb-radius: 16px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; font-size: 14px; line-height: 1.45; color: #1f2937; }
.smp-chb *, .smp-chb *::before, .smp-chb *::after { box-sizing: border-box; }
.smp-chb [hidden] { display: none !important; }

#smp-chb { position: fixed; bottom: 20px; z-index: 99990; }
#smp-chb.smp-chb--right { right: 20px; }
#smp-chb.smp-chb--left { left: 20px; }

/* Cụm nút nổi */
.smp-chb-fabs { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.smp-chb-fab { position: relative; width: 54px; height: 54px; border-radius: 50%; border: 0; padding: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #fff; text-decoration: none; box-shadow: 0 6px 18px rgba(0,0,0,.18); transition: transform .2s ease; }
.smp-chb-fab:hover { transform: scale(1.07); color: #fff; }
.smp-chb-fab--chat { background: var(--smp-chb-primary); }
.smp-chb-fab--call { background: #16a34a; animation: smp-chb-ring 2.4s infinite; }
.smp-chb-fab--zalo { background: #0068ff; }
.smp-chb-zalo-text { font-weight: 800; font-size: 13px; letter-spacing: .2px; }
.smp-chb-fab .smp-chb-ico-close { display: none; }
#smp-chb.is-open .smp-chb-fab--chat .smp-chb-ico-open { display: none; }
#smp-chb.is-open .smp-chb-fab--chat .smp-chb-ico-close { display: flex; }
.smp-chb-fab span { display: flex; }
.smp-chb-badge { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; border-radius: 10px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; align-items: center; justify-content: center; border: 2px solid #fff; }
.smp-chb-tip { position: absolute; white-space: nowrap; background: #111827; color: #fff; font-size: 12px; padding: 5px 10px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .2s; top: 50%; transform: translateY(-50%); }
.smp-chb--right .smp-chb-tip { right: 64px; }
.smp-chb--left .smp-chb-tip { left: 64px; }
.smp-chb-fab:hover .smp-chb-tip { opacity: 1; }

@keyframes smp-chb-ring {
	0%, 60%, 100% { box-shadow: 0 0 0 0 rgba(22,163,74,.55), 0 6px 18px rgba(0,0,0,.18); }
	30% { box-shadow: 0 0 0 12px rgba(22,163,74,0), 0 6px 18px rgba(0,0,0,.18); }
}

/* Khung chat */
.smp-chb-panel { position: absolute; bottom: 70px; width: 370px; max-width: calc(100vw - 32px); height: 560px; max-height: calc(100vh - 120px); background: #fff; border-radius: var(--smp-chb-radius); box-shadow: 0 18px 50px rgba(0,0,0,.22); display: flex; flex-direction: column; overflow: hidden; animation: smp-chb-pop .22s ease; }
.smp-chb--right .smp-chb-panel { right: 0; }
.smp-chb--left .smp-chb-panel { left: 0; }
@keyframes smp-chb-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.smp-chb-head { background: var(--smp-chb-primary); color: #fff; padding: 14px 14px; display: flex; align-items: center; gap: 10px; }
.smp-chb-avatar { position: relative; width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.smp-chb-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.smp-chb-online { position: absolute; right: 0; bottom: 0; width: 11px; height: 11px; border-radius: 50%; background: #22c55e; border: 2px solid #fff; }
.smp-chb-head__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.smp-chb-head__text strong { font-size: 15px; }
.smp-chb-head__text span { font-size: 12px; opacity: .85; }
.smp-chb-head__btn { background: rgba(255,255,255,.18); border: 0; color: #fff; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.smp-chb-head__btn:hover { background: rgba(255,255,255,.3); }

.smp-chb-body { flex: 1; overflow-y: auto; padding: 16px 14px; background: #f5f7fb; display: flex; flex-direction: column; gap: 10px; }
.smp-chb-msg { display: flex; flex-direction: column; max-width: 85%; }
.smp-chb-msg--visitor { align-self: flex-end; align-items: flex-end; }
.smp-chb-msg--bot, .smp-chb-msg--admin { align-self: flex-start; }
.smp-chb-msg--system { align-self: center; max-width: 100%; }
.smp-chb-msg--system .smp-chb-bubble { background: transparent; color: #6b7280; font-size: 12px; padding: 0; box-shadow: none; }
.smp-chb-msg__who { font-size: 11px; color: #6b7280; margin: 0 0 3px 4px; }
.smp-chb-bubble { padding: 9px 13px; border-radius: 14px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.06); word-wrap: break-word; }
.smp-chb-bubble p { margin: 0 0 6px; }
.smp-chb-bubble p:last-child { margin-bottom: 0; }
.smp-chb-bubble img { max-width: 100%; height: auto; border-radius: 8px; }
.smp-chb-bubble a { color: var(--smp-chb-primary); }
.smp-chb-msg--bot .smp-chb-bubble, .smp-chb-msg--admin .smp-chb-bubble { border-bottom-left-radius: 4px; }
.smp-chb-msg--admin .smp-chb-bubble { border-left: 3px solid var(--smp-chb-primary); }
.smp-chb-msg--visitor .smp-chb-bubble { background: var(--smp-chb-primary); color: #fff; border-bottom-right-radius: 4px; }

.smp-chb-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.smp-chb-qbtn { border: 1px solid var(--smp-chb-primary); background: #fff; color: var(--smp-chb-primary); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; line-height: 1.3; transition: background .15s, color .15s; }
.smp-chb-qbtn:hover { background: var(--smp-chb-primary); color: #fff; }
.smp-chb-qbtn--zalo { border-color: #0068ff; color: #0068ff; }
.smp-chb-qbtn--zalo:hover { background: #0068ff; }
.smp-chb-qbtn--call { border-color: #16a34a; color: #16a34a; }
.smp-chb-qbtn--call:hover { background: #16a34a; }

.smp-chb-typing { display: flex; gap: 4px; padding: 12px 14px; }
.smp-chb-typing i { width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; animation: smp-chb-dot 1.2s infinite; }
.smp-chb-typing i:nth-child(2) { animation-delay: .15s; }
.smp-chb-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes smp-chb-dot { 0%, 60%, 100% { transform: none; opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.smp-chb-input { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid #e5e7eb; background: #fff; margin: 0; }
.smp-chb-input textarea { flex: 1; resize: none; border: 1px solid #e5e7eb; border-radius: 20px; padding: 9px 14px; font: inherit; max-height: 110px; outline: none; background: #f9fafb; color: #1f2937; margin: 0; }
.smp-chb-input textarea:focus { border-color: var(--smp-chb-primary); background: #fff; }
.smp-chb-input button { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--smp-chb-primary); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 0; }

/* Form */
.smp-chb-formwrap { flex: 1; overflow-y: auto; padding: 16px; background: #fff; }
.smp-chb-form { display: flex; flex-direction: column; gap: 10px; margin: 0; }
.smp-chb-form__title { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.smp-chb-form input, .smp-chb-form select, .smp-chb-form textarea { width: 100%; border: 1px solid #d1d5db; border-radius: 10px; padding: 10px 12px; font: inherit; color: #1f2937; background: #fff; margin: 0; }
.smp-chb-form input:focus, .smp-chb-form select:focus, .smp-chb-form textarea:focus { outline: none; border-color: var(--smp-chb-primary); box-shadow: 0 0 0 3px rgba(13,110,253,.12); }
.smp-chb-form .smp-chb-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.smp-chb-btn { background: var(--smp-chb-primary); color: #fff; border: 0; border-radius: 10px; padding: 11px; font-weight: 600; font-size: 15px; cursor: pointer; }
.smp-chb-btn:disabled { opacity: .6; cursor: wait; }
.smp-chb-form__msg { font-size: 13px; min-height: 18px; }
.smp-chb-form__msg.is-error { color: #dc2626; }
.smp-chb-form__msg.is-ok { color: #16a34a; }
.smp-chb-back { margin-top: 12px; background: none; border: 0; color: #6b7280; cursor: pointer; padding: 0; font-size: 13px; }

/* Shortcode */
.smp-chb-inline { max-width: 460px; padding: 22px; border: 1px solid #e5e7eb; border-radius: 14px; background: #fff; }

@media (max-width: 480px) {
	#smp-chb { bottom: 14px; }
	#smp-chb.smp-chb--right { right: 14px; }
	#smp-chb.smp-chb--left { left: 14px; }
	.smp-chb-fab { width: 50px; height: 50px; }
	.smp-chb-panel { position: fixed; inset: 0; width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; bottom: 0; }
	#smp-chb.is-open .smp-chb-fab--zalo, #smp-chb.is-open .smp-chb-fab--call { display: none; }
	#smp-chb.is-open .smp-chb-fab--chat { position: fixed; top: 12px; right: 12px; width: 36px; height: 36px; z-index: 2; background: rgba(0,0,0,.25); box-shadow: none; }
	.smp-chb-head { padding-right: 56px; }
}
