/* Chat Widget Container */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: 'Inter', sans-serif;
}

/* Toggle Button */
.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.chat-toggle-btn svg {
    width: 30px;
    height: 30px;
}

/* Chat Window */
.chat-window {
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    overflow: hidden;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    position: absolute;
    bottom: 70px;
    right: 0;
}

.chat-window.open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: all;
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    padding: 15px 20px;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.chat-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0;
}

.chat-status-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    backdrop-filter: blur(5px);
}

.chat-mode-btn {
    background: white;
    color: #4facfe;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 8px;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.chat-mode-btn:hover {
    background: #f0f9ff;
}

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

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

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

/* Message Bubbles */
.message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 85%;
}

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

.message-row.received {
    align-self: flex-start;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: #555;
    flex-shrink: 0;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

/* Sent by User */
.message-row.sent .message-bubble {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 5px rgba(79, 172, 254, 0.3);
}

/* Received from Sophrologue */
.message-row.received.sophrologue .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border: 1px solid #eee;
}

.message-row.received.sophrologue .message-avatar {
    background: #4facfe;
    color: white;
}

/* Received from AI */
.message-row.received.ai .message-bubble {
    background: #f3e5f5;
    /* Light purple */
    color: #4a148c;
    border-bottom-left-radius: 2px;
    border: 1px solid #e1bee7;
}

.message-row.received.ai .message-avatar {
    background: #9c27b0;
    color: white;
}

/* Input Area */
.chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
}

.chat-form {
    display: flex;
    gap: 10px;
}

.chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.chat-input:focus {
    border-color: #4facfe;
}

.chat-send-btn {
    background: transparent;
    border: none;
    color: #4facfe;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.chat-send-btn:hover {
    transform: scale(1.1);
    color: #00f2fe;
}

.chat-send-btn svg {
    width: 24px;
    height: 24px;
}

/* Inactive State */
.chat-inactive-msg {
    text-align: center;
    font-size: 0.85rem;
    color: #888;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .chat-widget {
        position: fixed !important;
        bottom: 15px !important;
        right: 15px !important;
        z-index: 9999 !important;
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    .chat-toggle-btn {
        z-index: 10000 !important;
    }

    .chat-window {
        width: calc(100vw - 40px);
        max-height: calc(100vh - 100px);
        bottom: 80px;
        right: 0;
    }
}

/* Typing Animation */
.typing-animation {
    display: flex;
    gap: 4px;
    padding: 8px 0;
    align-items: center;
    justify-content: center;
}

.typing-animation span {
    width: 8px;
    height: 8px;
    background: #9c27b0;
    border-radius: 50%;
    opacity: 0.4;
    animation: typing 1.4s infinite;
}

.typing-animation span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-animation span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
}