/**
 * Nút liên hệ mascot (template-parts/contact-launcher.php). Trạng thái do contact-launcher.js gắn lên .sm-launcher:
 * .is-online, .is-open (bảng kênh), .has-bubble (lời mời), .is-wiggle (nhún khi rảnh).
 */
.sm-launcher {
    --ln-bg: #ffffff;
    --ln-text: #0b1a3a;
    --ln-muted: #5b6b85;
    --ln-line: rgba(11, 26, 58, 0.08);
    --ln-ring: #ffffff;
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9990;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
}
html[data-theme="dark"] .sm-launcher {
    --ln-bg: #151d30;
    --ln-text: #ffffff;
    --ln-muted: #a9b6cc;
    --ln-line: rgba(255, 255, 255, 0.08);
    --ln-ring: #1f2a44;
}
.sm-launcher > * { pointer-events: auto; }

/* Nút: đầu mascot trong vòng tròn xanh thương hiệu */
.sm-launcher-btn {
    position: relative;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    opacity: 0;
    transform: translateY(24px) scale(0.5);
    animation: sm-ln-pop 0.6s cubic-bezier(.3, 1.5, .5, 1) 0.3s forwards;
}
/* Trang chủ lần đầu: chờ intro xong mới bật lên (intro gỡ class sm-intro-lock khi kết thúc) */
html.sm-intro-lock .sm-launcher-btn { animation-play-state: paused; }
.sm-launcher-avatar {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 35%, #3d8cff 0%, #005eff 55%, #0038a8 100%);
    box-shadow: 0 0 0 3px var(--ln-ring), 0 10px 26px -6px rgba(0, 40, 120, 0.55);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.sm-launcher-btn:hover .sm-launcher-avatar,
.sm-launcher-btn:focus-visible .sm-launcher-avatar { transform: scale(1.06); box-shadow: 0 0 0 3px #beff01, 0 12px 30px -6px rgba(0, 40, 120, 0.6); }
.sm-launcher-btn:focus-visible { outline: none; }
.sm-launcher-face {
    position: absolute;
    left: 50%;
    top: 54%;
    width: 112%;
    height: 112%;
    max-width: none;
    transform: translate(-50%, -50%);
    transition: opacity 0.2s ease, transform 0.35s cubic-bezier(.3, 1.5, .5, 1);
}
.sm-launcher-face.is-open { opacity: 0; transform: translate(-50%, -40%) scale(0.9); }
.sm-launcher.is-open .sm-launcher-face.is-idle { opacity: 0; }
.sm-launcher.is-open .sm-launcher-face.is-open { opacity: 1; transform: translate(-50%, -50%); }

/* Chấm trạng thái: xanh chanh khi trong giờ hành chính, xám khi ngoài giờ */
.sm-launcher-status {
    position: absolute;
    right: 1px;
    top: 3px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #94a3b8;
    box-shadow: 0 0 0 3px var(--ln-ring);
}
.sm-launcher.is-online .sm-launcher-status { background: #beff01; }
.sm-launcher.is-online .sm-launcher-status::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: #beff01;
    animation: sm-ln-ping 2s ease-out infinite;
}

/* Nhún nhẹ khi rảnh (JS bật ~15s/lần) */
.sm-launcher.is-wiggle .sm-launcher-avatar { animation: sm-ln-hop 0.9s cubic-bezier(.3, 1.4, .5, 1); }

/* Bong bóng lời mời */
.sm-launcher-bubble {
    position: absolute;
    right: 78px;
    bottom: 8px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    width: max-content;
    max-width: min(260px, calc(100vw - 120px));
    padding: 12px 10px 12px 16px;
    border-radius: 16px 16px 4px 16px;
    background: var(--ln-bg);
    color: var(--ln-text);
    border: 1px solid var(--ln-line);
    box-shadow: 0 14px 34px -12px rgba(0, 30, 90, 0.35);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    transform-origin: 100% 100%;
}
.sm-launcher-bubble:not([hidden]) { animation: sm-ln-bubble 0.45s cubic-bezier(.3, 1.4, .5, 1); }
.sm-launcher-bubble span { color: var(--ln-text) !important; -webkit-text-fill-color: var(--ln-text) !important; cursor: pointer; }
.sm-launcher-bubble-x {
    flex: none;
    width: 22px;
    height: 22px;
    margin-top: -2px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ln-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.sm-launcher-bubble-x:hover { background: var(--ln-line); color: var(--ln-text); }

/* Bảng kênh liên hệ */
.sm-launcher-panel {
    position: absolute;
    right: 0;
    bottom: 80px;
    width: 320px;
    max-width: calc(100vw - 28px);
    overflow: hidden;
    border-radius: 20px;
    background: var(--ln-bg);
    border: 1px solid var(--ln-line);
    box-shadow: 0 24px 60px -18px rgba(0, 30, 90, 0.45);
    opacity: 0;
    transform: translateY(12px) scale(0.92);
    transform-origin: 100% 100%;
    transition: opacity 0.18s ease, transform 0.28s cubic-bezier(.3, 1.3, .5, 1);
}
.sm-launcher.is-open .sm-launcher-panel { opacity: 1; transform: none; }
.sm-launcher-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 16px 16px 20px;
    background:
        radial-gradient(circle at 85% 20%, rgba(190, 255, 1, 0.22) 0, rgba(190, 255, 1, 0) 40%),
        linear-gradient(135deg, #00287a 0%, #0047c9 50%, #005eff 100%);
}
.sm-launcher-head p { margin: 0; color: #fff !important; -webkit-text-fill-color: #fff !important; }
.sm-launcher-title { font-size: 18px; font-weight: 700; line-height: 1.3; }
.sm-launcher-state { display: flex; align-items: center; gap: 7px; margin-top: 4px !important; font-size: 13px; opacity: 0.9; }
.sm-launcher-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; flex: none; }
.sm-launcher.is-online .sm-launcher-dot { background: #beff01; box-shadow: 0 0 0 3px rgba(190, 255, 1, 0.25); }
.sm-launcher-state-on { display: none; }
.sm-launcher.is-online .sm-launcher-state-on { display: inline; }
.sm-launcher.is-online .sm-launcher-state-off { display: none; }
.sm-launcher-close {
    flex: none;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    cursor: pointer;
}
.sm-launcher-close:hover { background: rgba(255, 255, 255, 0.24); }
.sm-launcher-list { list-style: none; margin: 0; padding: 8px; }
.sm-launcher-item a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border-radius: 14px;
    color: var(--ln-text);
    text-decoration: none;
    transition: background-color 0.15s ease;
}
.sm-launcher-item a:hover,
.sm-launcher-item a:focus-visible { background: var(--ln-line); outline: none; }
.sm-launcher-icon {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    color: #fff;
}
.is-zalo .sm-launcher-icon { background: #0068ff; }
.is-call .sm-launcher-icon { background: #beff01; color: #0b1a3a; }
.is-form .sm-launcher-icon { background: linear-gradient(135deg, #0038a8, #005eff); }
.sm-launcher-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sm-launcher-text strong { font-size: 15px; font-weight: 700; line-height: 1.3; color: var(--ln-text) !important; -webkit-text-fill-color: var(--ln-text) !important; }
.sm-launcher-text small { font-size: 13px; line-height: 1.35; color: var(--ln-muted) !important; -webkit-text-fill-color: var(--ln-muted) !important; }
.sm-launcher-go { color: var(--ln-muted); font-size: 14px; }

/* "Gọi ngay" chỉ cho thiết bị cảm ứng (điện thoại) */
@media (hover: hover) and (pointer: fine) {
    .sm-launcher-item.is-call { display: none; }
}

@media (max-width: 767px) {
    .sm-launcher { right: 14px; bottom: 14px; }
    .sm-launcher-btn { width: 58px; height: 58px; }
    .sm-launcher-bubble { right: 70px; bottom: 6px; font-size: 13px; }
    .sm-launcher-panel { bottom: 72px; }
}

@media (prefers-reduced-motion: reduce) {
    .sm-launcher-btn { animation: none; opacity: 1; transform: none; }
    .sm-launcher.is-wiggle .sm-launcher-avatar,
    .sm-launcher-bubble:not([hidden]),
    .sm-launcher.is-online .sm-launcher-status::after { animation: none; }
}

@keyframes sm-ln-pop {
    0% { opacity: 0; transform: translateY(24px) scale(0.5, 0.35); }
    55% { opacity: 1; transform: translateY(-6px) scale(0.94, 1.08); }
    80% { transform: translateY(0) scale(1.05, 0.95); }
    100% { opacity: 1; transform: none; }
}
@keyframes sm-ln-hop {
    0%, 100% { transform: none; }
    30% { transform: translateY(-7px) rotate(-6deg); }
    55% { transform: translateY(0) rotate(4deg); }
    75% { transform: rotate(-2deg); }
}
@keyframes sm-ln-ping {
    0% { transform: scale(1); opacity: 0.7; }
    100% { transform: scale(2.4); opacity: 0; }
}
@keyframes sm-ln-bubble {
    0% { opacity: 0; transform: translateX(10px) scale(0.7); }
    100% { opacity: 1; transform: none; }
}
