/* Chat Widget Styles */

.chat-widget {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 9000;
    display: flex;
    flex-direction: row; /* Side by side */
    align-items: flex-end; /* Align bottom */
    gap: 16px;
    font-family: 'Inter', sans-serif;
    pointer-events: none; /* Allow clicking through wrapper area */
}

.chat-widget > * {
    pointer-events: auto; /* Re-enable clicks on children */
}

/* Chat Button (Blue Dot) */
.chat-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #40C4FF; /* Lighter Blue */
    box-shadow: 0 4px 12px rgba(64, 196, 255, 0.4); /* Tighter shadow */
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    position: relative;
}

.chat-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(64, 196, 255, 0.5);
}

/* Notification Badge */
.chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 22px;
    height: 22px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(255, 68, 68, 0.4);
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.chat-avatar {
    width: 85%; /* Smaller relative to dot */
    height: 85%;
    border-radius: 50%;
    object-fit: cover;
}

/* Welcome Bubble */
.chat-bubble {
    background: white;
    padding: 16px 20px;
    border-radius: 16px;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); /* Adjusted shadow */
    max-width: 300px;
    opacity: 0;
    transform: translateX(-20px) scale(0.9); /* Slide from left */
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid #f0f0f0;
    margin-bottom: 8px; /* Align nicely */
    cursor: pointer; /* Indicate clickable */
}

.chat-bubble.visible {
    opacity: 1;
    transform: translateX(0) scale(1);
}

/* Bubble Content */
.bubble-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.advisor-info {
    display: flex;
    flex-direction: column;
}

.advisor-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.2;
}

.advisor-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    display: inline-block;
}

.status-text {
    color: var(--success);
    font-weight: 600;
}

.bubble-message {
    font-size: 0.9rem;
    color: var(--text-main);
    line-height: 1.5;
}

/* Close button for bubble */
.bubble-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.bubble-close:hover {
    opacity: 1;
    background: #f5f5f5;
}

/* Chat Window Interface */
.chat-window {
    position: fixed;
    bottom: 110px;
    right: 32px;
    width: 360px;
    height: 550px;
    max-height: 80vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 9001;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
    border: 1px solid #f0f0f0;
}

.chat-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Window Header */
.window-header {
    background: #7adcff; /* Lighter Blue */
    padding: 20px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

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

.header-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
}

.header-info h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.header-status {
    font-size: 0.8rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-status .status-dot {
    background: #fff; /* White dot for contrast */
}

.window-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.window-close:hover {
    background: rgba(255,255,255,0.3);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    background: #f9f9f9;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
}

.message.advisor {
    background: white;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.message.user {
    background: #40C4FF; /* Lighter Blue */
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
    box-shadow: 0 2px 8px rgba(64, 196, 255, 0.2);
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 4px;
    display: block;
    text-align: right;
}

/* Input Area */
.chat-input-area {
    padding: 16px;
    background: white;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 12px;
}

.chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    padding: 10px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #40C4FF;
}

.chat-send-btn {
    background: #40C4FF;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.chat-send-btn:hover {
    background: #00B0FF;
    transform: scale(1.05);
}

/* Typing Indicator */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #b0b0b0;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

.message.typing {
    background: white;
    padding: 14px 18px;
}

/* Product Links in Chat - simple inline emoji links */
.message a {
    color: #2e7d32;
    text-decoration: none;
    font-size: 1.1em;
}

.message a:hover {
    text-decoration: underline;
}

.message.user a {
    color: #c8e6c9;
}

/* Message list styling */
.message ul {
    margin: 8px 0;
    padding-left: 20px;
}

.message li {
    margin: 4px 0;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-widget {
        bottom: 20px;
        right: 20px;
        flex-direction: column; /* Stack on mobile if narrow */
        align-items: flex-end;
    }
    
    .chat-btn {
        width: 56px;
        height: 56px;
    }
    
    .chat-bubble {
        max-width: 260px;
        font-size: 0.85rem;
        right: 0;
        bottom: 80px; /* Above button */
        margin-bottom: 0;
        transform: translateY(20px) scale(0.9);
    }
    
    .chat-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: none;
    }
}