.ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ai-chat-toggle {
    width: 60px;
    height: 60px;
    background: var(--chat-color, #007bff);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    color: white;
}

.ai-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.ai-chat-window.active {
    display: flex;
}

.ai-chat-header {
    background: var(--chat-color, #007bff);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.ai-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.ai-message-user {
    align-self: flex-end;
}

.ai-message-assistant,
.ai-message-manager {
    align-self: flex-start;
}

.ai-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}

.ai-message-user .ai-message-content {
    background: var(--chat-color, #007bff);
    color: white;
}

.ai-message-assistant .ai-message-content,
.ai-message-manager .ai-message-content {
    background: #f1f3f5;
    color: #333;
}

.ai-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 8px;
}

.ai-message-user .ai-message-time {
    text-align: right;
}

.ai-chat-input-area {
    padding: 16px;
    border-top: 1px solid #eee;
}

.ai-chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-chat-input-wrapper textarea {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 12px 16px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    max-height: 100px;
    min-height: 40px;
}

.ai-chat-input-wrapper textarea:focus {
    outline: none;
    border-color: var(--chat-color, #007bff);
}

.ai-chat-input-wrapper button {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--chat-color, #007bff);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-input-wrapper button:hover {
    background: color-mix(in srgb, var(--chat-color, #007bff) 90%, black);
}

.ai-chat-input-wrapper button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.ai-escalation-notice {
    text-align: center;
    padding: 12px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    color: #856404;
    font-size: 14px;
}

.ai-typing-indicator {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-size: 14px;
}

.ai-typing-dots {
    display: flex;
    gap: 4px;
}

.ai-typing-dots span {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.ai-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .ai-chat-widget {
        bottom: 10px;
        right: 10px;
    }
    
    .ai-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: -10px;
    }
}