:root {
    --primary-color: #0072FF;
    --primary-gradient: linear-gradient(135deg, #00C6FF, #0072FF);
    --bg-color: #eef2f6;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
    --text-color: #1e293b;
    --text-muted: #64748b;
    --message-ai-bg: #ffffff;
    --message-user-bg: var(--primary-gradient);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at top left, #dce7f3, transparent 40%),
                      radial-gradient(circle at bottom right, #d3e1f1, transparent 40%);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
}

.widget-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 16px;
}

.widget-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-gradient);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 114, 255, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.widget-toggle-btn:hover {
    transform: scale(1.1);
}

.widget-toggle-btn svg {
    width: 28px;
    height: 28px;
    fill: white;
    transition: opacity 0.2s;
    position: absolute;
}

.widget-toggle-btn .hidden {
    opacity: 0;
    pointer-events: none;
}

.chat-container {
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chat-container.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8) translateY(20px);
}

.chat-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    max-width: 100vw;
    border-radius: 0;
    z-index: 10000;
    transform: none !important;
}

/* Header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.5);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar-container {
    position: relative;
    width: 45px;
    height: 45px;
}

.avatar-container img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 10px rgba(0, 114, 255, 0.2);
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background-color: #10b981;
    border: 2px solid white;
    border-radius: 50%;
}

.header-info h2 {
    font-size: 16px;
    font-weight: 600;
}

.header-info p {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 400;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.icon-btn svg {
    width: 22px;
    height: 22px;
    fill: var(--text-muted);
}

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

.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.1);
    border-radius: 10px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 90%;
    animation: slide-up 0.4s ease;
}

.message-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.ai-message {
    align-self: flex-start;
}

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

.message-content {
    padding: 14px 18px;
    border-radius: 20px;
    line-height: 1.5;
    font-size: 15px;
    word-wrap: break-word;
}

/* Fix markdown spacing */
.message-content p { margin-bottom: 8px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content strong { font-weight: 600; }
.message-content ul, .message-content ol { padding-left: 20px; margin-bottom: 8px; }

.ai-message .message-content {
    background-color: var(--message-ai-bg);
    border: 1px solid rgba(0,0,0,0.04);
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    border-bottom-left-radius: 4px;
}

.user-message .message-content {
    background: var(--primary-gradient);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(0, 114, 255, 0.2);
}

/* Typing Indicator Overlay */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
    background-color: var(--message-ai-bg);
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    max-width: fit-content;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    margin-bottom: 16px;
}
.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #94a3b8;
    border-radius: 50%;
    animation: blink 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; }

/* Suggested Chips */
.suggested-chips {
    padding: 0 24px 16px 24px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
}

.suggested-chips::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.chip {
    white-space: nowrap;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid rgba(0, 114, 255, 0.2);
    background: rgba(0, 114, 255, 0.05);
    color: var(--primary-color);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 114, 255, 0.2);
}

/* Input Area */
.chat-input-area {
    padding: 20px 24px;
    background: rgba(255, 255, 255, 0.5);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: white;
    padding: 10px 14px;
    border-radius: 24px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(0, 114, 255, 0.1);
}

#user-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: 15px;
    color: var(--text-color);
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    padding: 8px 0;
}

#user-input::placeholder {
    color: #94a3b8;
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(0, 114, 255, 0.3);
}

.send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
    transform: translateX(1px);
}

/* Animations */
@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@media (max-width: 640px) {
    .widget-wrapper {
        bottom: 16px;
        right: 16px;
    }
    
    .chat-container {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
    }
}
