/* Chat Widget Styles */
:root {
    --chat-primary: #6366f1;
    --chat-bg: #ffffff;
    --chat-text: #1e293b;
    --chat-bg-secondary: #f4f4f5;
    --chat-accent: #8b5cf6;
}

.chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    /* Allow clicking through when closed */
}

/* Chat Toggle Button */
.chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-accent) 100%);
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    position: relative;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.chat-toggle svg {
    width: 32px;
    height: 32px;
    color: white;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.chat-toggle .close-icon {
    position: absolute;
    opacity: 0;
    transform: scale(0.5);
}

.chat-toggle.open .chat-icon {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}

.chat-toggle.open .close-icon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Chat Window */
.chat-window {
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 20px;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    visibility: hidden;
}

.chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
}

/* Chat Header */
.chat-header {
    padding: 20px;
    background: linear-gradient(135deg, var(--chat-primary) 0%, var(--chat-accent) 100%);
    color: white;
    flex-shrink: 0;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
    position: relative;
}

.agent-status {
    position: absolute;
    bottom: 0px;
    right: 0px;
    width: 10px;
    height: 10px;
    background: #22c55e;
    border: 2px solid var(--chat-primary);
    border-radius: 50%;
}

.agent-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.agent-info p {
    font-size: 12px;
    opacity: 0.9;
    margin: 2px 0 0 0;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    align-items: flex-end;
    animation: messageSlideIn 0.3s ease-out forwards;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes messageSlideIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message.ai .message-bubble {
    background: var(--chat-bg-secondary);
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
}

.message.user .message-bubble {
    background: var(--chat-primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 4px;
    margin-left: 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--chat-bg-secondary);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 10px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    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);
    }
}

/* Input Area (Mock) */
.chat-input-area {
    padding: 16px;
    border-top: 1px solid var(--slate-200);
    background: white;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input {
    flex: 1;
    border: 1px solid var(--slate-200);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: var(--chat-primary);
}

.chat-send-btn {
    background: var(--chat-primary);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

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

/* Options / Slots */
.chat-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.chat-option-btn {
    background: white;
    border: 1px solid var(--chat-primary);
    color: var(--chat-primary);
    padding: 8px 16px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-option-btn:hover {
    background: var(--chat-primary);
    color: white;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .chat-window {
        width: 100vw;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        bottom: 0;
        right: 0;
        margin-bottom: 0;
    }

    .chat-widget {
        bottom: 0;
        right: 0;
        padding: 0;
    }

    .chat-toggle {
        margin: 20px;
    }
}