/* Chat Widget */
:root {
    --chat-primary:   #2e3090;
    --chat-trigger:   #2e3090;
    --chat-trigger-2: #1d1f6b;
    --chat-bot-bg:    #f4f5fb;
}

@keyframes cs-trigger-pulse {
    0%, 100% {
        background: var(--chat-trigger);
        box-shadow: 0 4px 16px rgba(0,0,0,.20);
    }
    50% {
        background: var(--chat-trigger-2, var(--chat-trigger));
        box-shadow: 0 6px 24px rgba(0,0,0,.32);
    }
}

/* Jiggle: animates 'bottom' so it doesn't conflict with transform (hover scale) or pulse (background) */
@keyframes cs-trigger-jiggle {
    0%,  100% { bottom: 20px; }
    4%         { bottom: 100px; }
    8%         { bottom: 20px; }
    12%        { bottom: 70px; }
    16%        { bottom: 20px; }
    20%        { bottom: 45px; }
    24%        { bottom: 20px; }
}

.cs-chat-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--chat-trigger);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, opacity .3s;
}
.cs-chat-trigger:hover { transform: scale(1.08); }
.cs-chat-trigger.hidden { opacity: 0; pointer-events: none; transform: scale(0); animation: none !important; }
.cs-chat-trigger svg { width: 26px; height: 26px; fill: #fff; }

.cs-chat-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    width: 380px;
    height: 520px;
    max-width: calc(100% - 24px);
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(.95);
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
}
.cs-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.cs-chat-header {
    background: var(--chat-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.cs-chat-header-info { flex: 1; min-width: 0; }
.cs-chat-header-title { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-chat-header-subtitle { font-size: 11px; opacity: .8; }
.cs-chat-close {
    background: none; border: none; color: #fff; font-size: 22px;
    cursor: pointer; opacity: .7; padding: 4px; line-height: 1;
}
.cs-chat-close:hover { opacity: 1; }

.cs-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cs-chat-msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}
.cs-chat-msg a { color: inherit; text-decoration: underline; }
.cs-chat-msg-user {
    align-self: flex-end;
    background: var(--chat-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.cs-chat-msg-bot {
    align-self: flex-start;
    background: var(--chat-bot-bg);
    color: #1c1c1c;
    border-bottom-left-radius: 4px;
}

.cs-chat-typing { align-self: flex-start; padding: 10px 18px; }
.cs-chat-typing span {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    margin: 0 2px;
    animation: cs-dot .8s infinite;
}
.cs-chat-typing span:nth-child(2) { animation-delay: .15s; }
.cs-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cs-dot {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.cs-chat-input-wrap {
    border-top: 1px solid #e5e7eb;
    padding: 10px 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}
.cs-chat-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 8px 14px;
    font-size: 14px;
    resize: none;
    max-height: 80px;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
}
.cs-chat-input:focus { border-color: var(--chat-primary); }
.cs-chat-send {
    background: var(--chat-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .15s;
}
.cs-chat-send:hover { opacity: .85; }
.cs-chat-send:disabled { opacity: .4; cursor: default; }
.cs-chat-send svg { width: 18px; height: 18px; fill: #fff; }

/* Left side tab */
.cs-chat-tab {
    position: fixed;
    left: 0;
    bottom: 20%;
    z-index: 9998;
    background: var(--chat-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    padding: 14px 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .06em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    border-radius: 0 8px 8px 0;
    box-shadow: 2px 2px 12px rgba(0,0,0,.15);
    opacity: 0;
    transform: translateX(-100%);
    transition: opacity .4s ease, transform .4s ease, filter .15s;
    font-family: inherit;
}
.cs-chat-tab.visible { opacity: 1; transform: translateX(0); }
.cs-chat-tab:hover { filter: brightness(1.1); }
.cs-chat-tab.hidden { opacity: 0; pointer-events: none; transform: translateX(-100%); }

@media (max-width: 480px) {
    .cs-chat-window { width: calc(100% - 16px); right: 8px; bottom: 8px; height: calc(100vh - 16px); border-radius: 12px; }
    .cs-chat-trigger { bottom: 12px; right: 12px; }
    .cs-chat-tab { display: none; }
}
