/* ============================================
   Benshine Contact Widget - Frontend Styles
   位置：右侧垂直居中
   ============================================ */

:root {
    --cw-whatsapp: #25D366;
    --cw-whatsapp-dark: #128C7E;
    --cw-email: #6C63FF;
    --cw-email-dark: #4F46E5;
    --cw-bg: rgba(30, 30, 46, 0.95);
    --cw-card-bg: rgba(255, 255, 255, 0.06);
    --cw-card-hover: rgba(255, 255, 255, 0.12);
    --cw-text: #ffffff;
    --cw-text-muted: rgba(255, 255, 255, 0.6);
    --cw-radius: 16px;
    --cw-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 40px rgba(37, 211, 102, 0.15);
    --cw-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Animations ── */
@keyframes cw-shake-swing {
    0% {
        transform: translateX(0) rotate(0deg);
    }

    8% {
        transform: translateX(-14px) rotate(-6deg) scale(1.08);
    }

    16% {
        transform: translateX(14px) rotate(6deg) scale(1.08);
    }

    24% {
        transform: translateX(-12px) rotate(-5deg) scale(1.05);
    }

    32% {
        transform: translateX(12px) rotate(5deg) scale(1.05);
    }

    40% {
        transform: translateX(-8px) rotate(-3deg);
    }

    50% {
        transform: translateX(8px) rotate(3deg);
    }

    60% {
        transform: translateX(-5px) rotate(-2deg);
    }

    70% {
        transform: translateX(5px) rotate(2deg);
    }

    80% {
        transform: translateX(-2px) rotate(-1deg);
    }

    90% {
        transform: translateX(2px) rotate(1deg);
    }

    100% {
        transform: translateX(0) rotate(0deg);
    }
}

@keyframes cw-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cw-pulse-ring {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.6;
    }

    50% {
        transform: scale(1.15);
        opacity: 0;
    }
}

@keyframes cw-glow {

    0%,
    100% {
        box-shadow: 0 4px 15px rgba(37, 211, 102, 0.3);
    }

    50% {
        box-shadow: 0 4px 25px rgba(37, 211, 102, 0.6), 0 0 40px rgba(37, 211, 102, 0.2);
    }
}

@keyframes cw-email-glow {

    0%,
    100% {
        box-shadow: 0 4px 15px rgba(108, 99, 255, 0.3);
    }

    50% {
        box-shadow: 0 4px 25px rgba(108, 99, 255, 0.5), 0 0 35px rgba(108, 99, 255, 0.2);
    }
}

@keyframes cw-slide-in {
    0% {
        opacity: 0;
        transform: translate(20px, -50%) scale(0.95);
    }

    100% {
        opacity: 1;
        transform: translate(0, -50%) scale(1);
    }
}

/* ── Buttons Container (right-center, vertical) ── */
#cw-buttons-wrap {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    font-family: var(--cw-font);
}

/* ── Email Floating Button ── */
#cw-email-float {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--cw-email), var(--cw-email-dark));
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 18px rgba(108, 99, 255, 0.35);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: cw-email-glow 2.5s ease-in-out infinite;
    position: relative;
    text-decoration: none;
}

#cw-email-float:hover {
    transform: scale(1.12);
    box-shadow: 0 8px 30px rgba(108, 99, 255, 0.5);
}

#cw-email-float svg {
    width: 22px;
    height: 22px;
    fill: #fff;
}

/* Email tooltip — now appears to the LEFT */
#cw-email-float .cw-tooltip {
    position: absolute;
    top: 50%;
    right: calc(100% + 14px);
    transform: translateY(-50%) translateX(10px);
    background: rgba(30, 30, 46, 0.95);
    color: #fff;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#cw-email-float .cw-tooltip::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 100%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: rgba(30, 30, 46, 0.95);
}

#cw-email-float:hover .cw-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* ── WhatsApp Toggle Button (pill) ── */
#cw-toggle-btn {
    height: 46px;
    border-radius: 23px;
    border: none;
    background: #2D3134;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 18px 0 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: cw-glow 2s ease-in-out infinite;
    position: relative;
    font-family: var(--cw-font);
    overflow: visible;
}

#cw-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 30px rgba(37, 211, 102, 0.4);
}

#cw-toggle-btn.cw-shaking {
    animation: cw-shake-swing 1s ease-in-out, cw-glow 2s ease-in-out infinite;
}

#cw-toggle-btn .cw-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 28px;
    background: rgba(37, 211, 102, 0.25);
    animation: cw-pulse-ring 2s ease-out infinite;
    pointer-events: none;
}

#cw-toggle-btn .cw-wa-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

#cw-toggle-btn .cw-wa-icon svg {
    width: 26px;
    height: 26px;
    fill: var(--cw-whatsapp);
}

#cw-toggle-btn .cw-wa-label {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.2px;
    color: #fff;
    position: relative;
    z-index: 1;
    line-height: 1;
}

/* Open state: show close icon */
#cw-toggle-btn.cw-open .cw-wa-icon,
#cw-toggle-btn.cw-open .cw-wa-label {
    display: none;
}

#cw-toggle-btn.cw-open .cw-icon-close {
    display: flex;
}

#cw-toggle-btn:not(.cw-open) .cw-icon-close {
    display: none;
}

#cw-toggle-btn .cw-icon-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
}

#cw-toggle-btn .cw-icon-close svg {
    width: 22px;
    height: 22px;
    fill: #fff;
}

#cw-toggle-btn.cw-open {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
    background: linear-gradient(135deg, #444, #333);
}

/* ── Panel (slides from right, vertically centered) ── */
#cw-panel {
    position: fixed;
    top: 50%;
    right: 80px;
    transform: translateY(-50%);
    z-index: 99998;
    width: 340px;
    max-height: calc(100vh - 100px);
    background: var(--cw-bg);
    border-radius: var(--cw-radius);
    box-shadow: var(--cw-shadow);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    display: none;
    flex-direction: column;
    font-family: var(--cw-font);
}

#cw-panel.cw-visible {
    display: flex;
    animation: cw-slide-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Panel Header */
.cw-header {
    padding: 20px 22px 14px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cw-header h3 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 700;
    color: var(--cw-text);
    letter-spacing: -0.3px;
}

.cw-header p {
    margin: 0;
    font-size: 12.5px;
    color: var(--cw-text-muted);
    line-height: 1.4;
}

/* Panel Body */
.cw-body {
    padding: 14px 16px 18px;
    overflow-y: auto;
}

/* Section Labels */
.cw-section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--cw-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.cw-section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
}

/* Agent Cards */
.cw-agents {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cw-agent-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--cw-card-bg);
    text-decoration: none;
    color: var(--cw-text);
    transition: all 0.2s ease;
    border: 1px solid transparent;
    animation: cw-fadeInUp 0.3s ease forwards;
    opacity: 0;
}

.cw-agent-card:hover {
    background: var(--cw-card-hover);
    border-color: rgba(37, 211, 102, 0.3);
    transform: translateX(-3px);
}

/* Agent Avatar */
.cw-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    position: relative;
}

.cw-avatar::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    background: var(--cw-whatsapp);
    border-radius: 50%;
    border: 2px solid var(--cw-bg);
}

/* Agent Info */
.cw-agent-info {
    flex: 1;
    min-width: 0;
}

.cw-agent-name {
    font-size: 14px;
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
    color: var(--cw-text);
}

.cw-agent-role {
    font-size: 11.5px;
    color: var(--cw-text-muted);
    display: block;
}

/* Chat arrow */
.cw-chat-arrow {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--cw-whatsapp), var(--cw-whatsapp-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.cw-agent-card:hover .cw-chat-arrow {
    transform: scale(1.1);
}

.cw-chat-arrow svg {
    width: 16px;
    height: 16px;
    fill: #fff;
}

/* Footer */
.cw-footer {
    padding: 10px 18px 14px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.cw-footer span {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.3);
}

/* ── Responsive ── */
@media (max-width: 480px) {
    #cw-buttons-wrap {
        right: 12px;
        top: 50%;
    }

    #cw-toggle-btn {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        padding: 0;
        justify-content: center;
    }

    #cw-toggle-btn .cw-wa-label {
        display: none;
    }

    #cw-panel {
        top: auto;
        bottom: 20px;
        right: 12px;
        left: 12px;
        width: auto;
        max-height: calc(100vh - 140px);
        transform: translateY(0);
    }

    #cw-panel.cw-visible {
        animation: cw-slide-up 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    @keyframes cw-slide-up {
        0% {
            opacity: 0;
            transform: translateY(20px) scale(0.98);
        }

        100% {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }
}