/* Chat Widget Styles */
.ca-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    z-index: 999999;
}

/* Chat Bubble */
.ca-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    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;
    z-index: 1000000;
}

.ca-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.ca-bubble-hidden {
    display: none;
}

.ca-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

/* Chat Window */
.ca-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 40px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000001;
}

/* Header */
.ca-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.ca-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ca-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ca-clear {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
    flex-shrink: 0;
    opacity: 0.8;
}

.ca-clear:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
}

.ca-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
    flex-shrink: 0;
    margin-left: 4px;
}

.ca-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages Container */
.ca-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f8f9fa;
    min-height: 0;
}

.ca-messages::-webkit-scrollbar {
    width: 6px;
}

.ca-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ca-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.ca-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Message Bubbles */
.ca-msg {
    margin-bottom: 16px;
    display: flex;
    animation: msgSlideIn 0.3s ease;
}

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

.ca-msg-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

.ca-msg-user {
    justify-content: flex-end;
}

.ca-msg-user .ca-msg-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ca-msg-bot {
    justify-content: flex-start;
}

.ca-msg-bot .ca-msg-content {
    background: white;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Typing Indicator */
.ca-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.ca-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e0;
    animation: typeBounce 1.4s infinite;
}

.ca-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.ca-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typeBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Input Container */
.ca-input-wrap {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.ca-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    resize: none;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
    max-height: 120px;
    overflow-y: auto;
}

.ca-input:focus {
    border-color: #667eea;
}

.ca-input::-webkit-scrollbar {
    width: 4px;
}

.ca-input::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.ca-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ca-send:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ca-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Powered By */
.ca-powered {
    padding: 8px 16px;
    text-align: center;
    font-size: 11px;
    color: #a0aec0;
    background: white;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .ca-window {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .ca-bubble {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }
}
