/* Chat Widget Container */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Segoe UI', sans-serif;
}

/* Floating Button */
.chat-button {
    width: 60px;
    height: 60px;
    background-color: var(--primary-color, #4f46e5);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chat-button:hover {
    transform: scale(1.1);
}

.chat-button svg {
    width: 30px;
    height: 30px;
    fill: var(--text-inverse);
}

/* Chat Window */
.chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 340px;
    height: 500px;
    max-height: calc(100vh - var(--theme-header-height) - 140px);
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: chatOpen 0.3s ease-out;
}

@keyframes chatOpen {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.chat-header {
    background-color: var(--primary-color, #4f46e5);
    color: var(--text-inverse);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid color-mix(in oklab, var(--text-inverse) 12%, transparent 88%);
}

.chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.chat-close {
    background: none;
    border: none;
    color: var(--text-inverse);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: var(--card-bg);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.bot {
    background-color: color-mix(in oklab, var(--card-bg) 92%, var(--text-inverse) 8%);
    color: var(--text-main);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.message.user {
    background-color: var(--primary-color, #4f46e5);
    color: var(--text-inverse);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.chat-input-area {
    padding: 15px;
    border-top: 1px solid var(--border-color);
    background-color: var(--input-bg);
    display: flex;
    gap: 10px;
}

.chat-input-area input {
    flex: 1;
    padding: 10px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area input:focus {
    border-color: var(--primary-color, #4f46e5);
}

.chat-send {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--primary-color, #4f46e5);
    padding: 0 5px;
    transition: transform 0.2s;
}

.chat-send:hover {
    transform: scale(1.1);
}

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

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background-color: #e5e7eb;
    border-radius: 12px;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #6b7280;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

@media (max-width: 480px) {
    .chat-window {
        width: calc(100vw - 40px);
        height: 60vh;
        max-height: calc(100vh - var(--theme-header-height) - 100px);
        bottom: 90px;
    }
}
