.ts-chat-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3178c6, #7b45b5);
    border: none;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(49, 120, 198, 0.4);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.ts-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(49, 120, 198, 0.5);
}

.ts-chat-toggle svg {
    width: 28px;
    height: 28px;
    fill: white;
    transition: transform 0.3s;
}

.ts-chat-toggle.active svg {
    transform: rotate(90deg);
}

.ts-chat-pulse {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    background: #f5a623;
    border-radius: 50%;
    border: 3px solid white;
    animation: tsPulse 2s ease-in-out infinite;
}

@keyframes tsPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

.ts-chat-panel {
    position: fixed;
    bottom: 7rem;
    right: 2rem;
    width: 400px;
    max-height: 560px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: tsSlideUp 0.3s ease-out;
}

.ts-chat-panel.open {
    display: flex;
}

@keyframes tsSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.ts-chat-header {
    background: linear-gradient(135deg, #3178c6, #7b45b5);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ts-chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ts-chat-header-avatar img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.ts-chat-header-info {
    flex: 1;
}

.ts-chat-header-title {
    color: white;
    font-family: 'Syne', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.2;
}

.ts-chat-header-status {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ts-chat-header-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}

.ts-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 0.25rem;
}

.ts-chat-close:hover {
    opacity: 1;
}

.ts-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 360px;
    min-height: 200px;
    scroll-behavior: smooth;
}

.ts-chat-msg {
    display: flex;
    gap: 0.5rem;
    max-width: 85%;
    animation: tsFadeIn 0.3s ease-out;
}

@keyframes tsFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.ts-chat-msg.agent {
    align-self: flex-start;
}

.ts-chat-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ts-chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: white;
    margin-top: 2px;
}

.ts-chat-msg.agent .ts-chat-msg-avatar {
    background: linear-gradient(135deg, #3178c6, #7b45b5);
}

.ts-chat-msg.user .ts-chat-msg-avatar {
    background: #64748b;
}

.ts-chat-msg-bubble {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.ts-chat-msg.agent .ts-chat-msg-bubble {
    background: #f1f5f9;
    color: #0f172a;
    border-bottom-left-radius: 4px;
}

.ts-chat-msg.user .ts-chat-msg-bubble {
    background: linear-gradient(135deg, #3178c6, #2563a8);
    color: white;
    border-bottom-right-radius: 4px;
}

.ts-chat-typing {
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
    background: #f1f5f9;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.ts-chat-typing span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: tsTyping 1.4s ease-in-out infinite;
}

.ts-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.ts-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes tsTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.ts-chat-input-area {
    padding: 1rem 1.25rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    background: white;
}

.ts-chat-input {
    flex: 1;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.625rem 0.875rem;
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    resize: none;
    max-height: 80px;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.4;
}

.ts-chat-input:focus {
    border-color: #3178c6;
}

.ts-chat-input::placeholder {
    color: #94a3b8;
}

.ts-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3178c6, #7b45b5);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.ts-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(49, 120, 198, 0.3);
}

.ts-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ts-chat-send svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.ts-chat-powered {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.7rem;
    color: #94a3b8;
    background: #f8fafc;
}

@media (max-width: 480px) {
    .ts-chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-height: 100vh;
        border-radius: 16px 16px 0 0;
    }

    .ts-chat-messages {
        max-height: calc(100vh - 200px);
    }

    .ts-chat-toggle {
        bottom: 1.25rem;
        right: 1.25rem;
        width: 56px;
        height: 56px;
    }
}
