/* Widget CSS */
:root {
    --chat-primary-color: #2563eb;
    --chat-secondary-color: #1e40af;
    --chat-bg-color: #ffffff;
    --chat-text-color: #333333;
    --chat-message-user-bg: #2563eb;
    --chat-message-user-text: #ffffff;
    --chat-message-bot-bg: #f3f4f6;
    --chat-message-bot-text: #1f2937;
    --chat-font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --transition-speed: 0.3s;
}

/* Floating Action Button */
.chat-widget-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: var(--chat-primary-color);
    color: white;
    border-radius: 50%;
    border: none;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: transform var(--transition-speed), background-color var(--transition-speed);
}

.chat-widget-fab:hover {
    background-color: var(--chat-secondary-color);
    transform: scale(1.05);
}

.chat-widget-fab svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 500px;
    max-height: 80vh;
    background-color: var(--chat-bg-color);
    border-radius: 16px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transition: all var(--transition-speed) ease-in-out;
    font-family: var(--chat-font-family);
}

.chat-window.open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.chat-header {
    background-color: var(--chat-primary-color);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.chat-close-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0;
    opacity: 0.8;
}

.chat-close-btn:hover {
    opacity: 1;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: #fafafa;
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background-color: var(--chat-message-user-bg);
    color: var(--chat-message-user-text);
    border-bottom-right-radius: 2px;
}

.message.bot {
    align-self: flex-start;
    background-color: var(--chat-message-bot-bg);
    color: var(--chat-message-bot-text);
    border-bottom-left-radius: 2px;
}

.message.typing {
    font-style: italic;
    color: #888;
    background: none;
    padding: 0;
    margin-left: 10px;
    font-size: 0.8rem;
}

/* Chat Input Area */
.chat-input-area {
    padding: 12px;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: white;
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--chat-primary-color);
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #64748b;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
}

.icon-btn:hover {
    background-color: #f1f5f9;
    color: var(--chat-primary-color);
}

.icon-btn.active {
    color: #ef4444;
    /* Red for recording */
    background-color: #fee2e2;
    animation: pulse 1.5s infinite;
}

.icon-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

@media (max-width: 480px) {
    .chat-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        max-height: 100%;
        border-radius: 0;
    }
}