:root {
    --wcskh-primary: #15803d;
    --wcskh-primary-dark: #14532d;
    --wcskh-accent: #f59e0b;
    --wcskh-right-offset: 7%;
}

/* Quy tắc ẩn tuyệt đối thắng mọi ID selector */
.wcskh-hidden,
#wasin-cskh-launcher.wcskh-hidden,
#wasin-cskh-greeting-popup.wcskh-hidden,
#wasin-cskh-window.wcskh-hidden,
#wasin-cskh-lead-screen.wcskh-hidden,
#wasin-cskh-chat-screen.wcskh-hidden {
    display: none !important;
}

/* 1. BONG BÓNG CHAT KÉO THẢ TỰ DO & POPUP CÂU CHÀO */
#wasin-cskh-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999998;
    display: flex;
    align-items: center;
    gap: 12px;
    touch-action: none;
    user-select: none;
    cursor: grab;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
#wasin-cskh-launcher:active {
    cursor: grabbing;
}

#wasin-cskh-greeting-popup {
    position: relative;
    background: #ffffff;
    color: #1e293b;
    padding: 12px 16px;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
    border: 2px solid var(--wcskh-primary);
    max-width: 255px;
    font-size: 13px;
    line-height: 1.45;
    font-weight: 600;
    cursor: pointer;
    animation: wcskhFloatGreeting 3s ease-in-out infinite;
}
#wasin-cskh-greeting-popup .wcskh-greet-badge {
    display: inline-block;
    background: #dcfce7;
    color: var(--wcskh-primary-dark);
    font-size: 10px;
    font-weight: 800;
    padding: 2px 7px;
    border-radius: 99px;
    margin-bottom: 4px;
    text-transform: uppercase;
}
#wasin-cskh-greeting-close {
    position: absolute;
    top: -8px;
    left: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #0f172a;
    color: #fff;
    border: 2px solid #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#wasin-cskh-bubble-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--wcskh-primary);
    border: 3px solid #ffffff;
    box-shadow: 0 10px 25px rgba(21, 128, 61, 0.45);
    position: relative;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.25s ease;
}
#wasin-cskh-bubble-btn:hover {
    transform: scale(1.08);
}
#wasin-cskh-bubble-btn img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    pointer-events: none;
}
.wcskh-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #22c55e;
    border: 2px solid #fff;
    border-radius: 50%;
    z-index: 3;
}
.wcskh-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    z-index: 4;
}
.wcskh-drag-hint {
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.75);
    color: #fff;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 99px;
    white-space: nowrap;
    pointer-events: none;
}

.wcskh-effect-pulse::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--wcskh-primary);
    animation: wcskhPulseRing 2s infinite;
}
.wcskh-effect-bounce {
    animation: wcskhBounce 2.2s infinite;
}
.wcskh-effect-shake {
    animation: wcskhShake 2.5s infinite;
}

@keyframes wcskhPulseRing {
    0% { transform: scale(1); opacity: 0.9; }
    100% { transform: scale(1.45); opacity: 0; }
}
@keyframes wcskhBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
@keyframes wcskhShake {
    0%, 100% { transform: rotate(0deg); }
    15% { transform: rotate(-10deg); }
    30% { transform: rotate(10deg); }
    45% { transform: rotate(-6deg); }
    60% { transform: rotate(6deg); }
    75% { transform: rotate(0deg); }
}
@keyframes wcskhFloatGreeting {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-4px); }
}

/* ==========================================================================
   2. KHUNG CHAT MỞ RA: NẰM DƯỚI CÙNG GÓC PHẢI, CÁCH CẠNH PHẢI ĐÚNG 7%
   ========================================================================== */
#wasin-cskh-window {
    position: fixed;
    bottom: 20px;
    right: var(--wcskh-right-offset, 7%);
    width: 385px;
    max-width: calc(100vw - 24px);
    height: 570px;
    max-height: calc(100vh - 40px);
    background: #ffffff;
    border-radius: 22px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
    border: 2px solid rgba(21, 128, 61, 0.25);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    animation: wcskhWindowOpen 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes wcskhWindowOpen {
    0% { opacity: 0; transform: translateY(20px) scale(0.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 768px) {
    #wasin-cskh-window {
        right: 4%;
        bottom: 14px;
        width: 360px;
        height: 530px;
    }
    #wasin-cskh-greeting-popup {
        max-width: 210px;
        font-size: 12px;
        padding: 10px 13px;
    }
}
@media (max-width: 480px) {
    #wasin-cskh-window {
        right: 3%;
        left: 3%;
        width: auto;
        bottom: 10px;
        height: 82vh;
        max-height: 560px;
    }
}

.wcskh-win-header {
    background: linear-gradient(135deg, var(--wcskh-primary-dark), var(--wcskh-primary));
    color: #ffffff;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.wcskh-staff-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.wcskh-staff-meta img {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #bbf7d0;
    flex-shrink: 0;
}
.wcskh-staff-title {
    margin: 0;
    font-size: 14.5px;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wcskh-staff-status {
    font-size: 11px;
    color: #dcfce7;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
.wcskh-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}
.wcskh-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.wcskh-icon-btn {
    background: rgba(255, 255, 255, 0.16);
    border: none;
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.wcskh-icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Màn hình 1: Form Nhập Tên & SĐT */
#wasin-cskh-lead-screen {
    flex: 1;
    padding: 22px 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
}
.wcskh-lead-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}
.wcskh-lead-welcome {
    font-size: 13.5px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.5;
    margin: 0 0 16px;
    padding: 10px 12px;
    background: #f0fdf4;
    border-left: 4px solid var(--wcskh-primary);
    border-radius: 8px;
}
.wcskh-field {
    margin-bottom: 14px;
}
.wcskh-field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 5px;
}
.wcskh-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 13px;
    outline: none;
    background: #f8fafc;
    transition: all 0.2s;
}
.wcskh-field input:focus {
    background: #fff;
    border-color: var(--wcskh-primary);
    box-shadow: 0 0 0 3px rgba(21, 128, 61, 0.14);
}
.wcskh-start-btn {
    width: 100%;
    background: var(--wcskh-primary);
    color: #ffffff;
    border: none;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(21, 128, 61, 0.28);
    transition: opacity 0.2s;
}
.wcskh-start-btn:hover {
    opacity: 0.94;
}

/* Màn hình 2: Khung Trò Chuyện Chính */
#wasin-cskh-chat-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f1f5f9;
    overflow: hidden;
}
.wcskh-customer-bar {
    background: #ecfdf5;
    border-bottom: 1px solid #bbf7d0;
    padding: 6px 12px;
    font-size: 11px;
    color: #14532d;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.wcskh-customer-bar button {
    background: none;
    border: none;
    color: #0284c7;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
}

#wasin-cskh-messages {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.wcskh-msg-row {
    display: flex;
    flex-direction: column;
    max-width: 86%;
    animation: wcskhFadeIn 0.22s ease;
}
@keyframes wcskhFadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}
.wcskh-msg-row.bot {
    align-self: flex-start;
}
.wcskh-msg-row.user {
    align-self: flex-end;
}
.wcskh-bubble {
    padding: 10px 13px;
    border-radius: 15px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-line;
    word-wrap: break-word;
}
.wcskh-msg-row.bot .wcskh-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-top-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}
.wcskh-msg-row.user .wcskh-bubble {
    background: var(--wcskh-primary);
    color: #ffffff;
    border-top-right-radius: 4px;
}
.wcskh-msg-time {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 3px;
    padding: 0 4px;
}
.wcskh-msg-row.user .wcskh-msg-time {
    text-align: right;
}

/* Khu vực hiển thị các nút câu hỏi mẫu */
#wasin-cskh-options {
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 8px 12px;
    max-height: 175px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.wcskh-opt-btn {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: var(--wcskh-primary-dark);
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: all 0.18s;
    display: block;
    text-decoration: none;
    line-height: 1.35;
}
.wcskh-opt-btn:hover {
    background: var(--wcskh-primary);
    color: #ffffff;
    border-color: var(--wcskh-primary);
}
.wcskh-direct-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 4px;
}
.wcskh-btn-zalo {
    background: #0284c7 !important;
    color: #fff !important;
    border-color: #0284c7 !important;
    text-align: center !important;
}
.wcskh-btn-call {
    background: var(--wcskh-accent) !important;
    color: #0f172a !important;
    border-color: var(--wcskh-accent) !important;
    text-align: center !important;
}

/* Ô nhập tin nhắn trực tiếp */
.wcskh-input-bar {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}
#wasin-cskh-text-input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    font-size: 12.5px;
    outline: none;
}
#wasin-cskh-text-input:focus {
    border-color: var(--wcskh-primary);
}
#wasin-cskh-send-btn {
    background: var(--wcskh-primary);
    color: #ffffff;
    border: none;
    padding: 0 15px;
    border-radius: 10px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
}

.wcskh-credit-bar {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 5px 10px;
    text-align: center;
    font-size: 10px;
    color: #64748b;
}
.wcskh-credit-bar a {
    color: var(--wcskh-primary);
    font-weight: 700;
    text-decoration: none;
}