/* Chat Widget Container */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Image Button - Updated with no background */
.chat-image-button {
    cursor: pointer;
    max-width: 150px; /* Adjust size as needed */
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    transition: transform 0.3s ease;
    background: none; /* No background */
    border: none; /* No border */
    padding: 0; /* No padding */
    box-shadow: none; /* No shadow */
}

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

/* Original Button - Kept for backward compatibility */
.chat-button {
    width: auto;
    min-width: 160px;
    height: 48px;
    border-radius: 24px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0 24px;
    font-size: 16px;
    font-weight: 500;
}

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

.chat-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.button-logo {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 350px;
    min-height: 400px;
    max-width: 800px;
    max-height: 900px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.chat-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.online-status {
    font-size: 12px;
    color: #4ade80;
    display: flex;
    align-items: center;
    gap: 4px;
}

.close-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Message Styles */
.message-wrapper {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-wrapper.bot {
    align-self: flex-start;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 100%;
    word-wrap: break-word;
    line-height: 1.5;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    white-space: pre-wrap;
}

.bot .message-bubble {
    background-color: white;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}

.user .message-bubble {
    border-bottom-right-radius: 4px;
}

.message-timestamp {
    font-size: 11px;
    color: #64748b;
    padding: 0 4px;
}

.user .message-timestamp {
    text-align: right;
}

/* Message Links */
.message-bubble a {
    text-decoration: underline;
    word-break: break-word;
}

.message-bubble a:hover {
    opacity: 0.8;
}

/* Message formatting styles */
.message-bubble p {
    margin: 0 0 10px 0;
}

.message-bubble p:last-child {
    margin-bottom: 0;
}

.message-bubble ul, 
.message-bubble ol {
    margin: 10px 0;
    padding-left: 20px;
}

.message-bubble li {
    margin: 5px 0;
}

/* Input Area */
.input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 24px;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    max-height: 120px;
    min-height: 24px;
    background: #f8fafc;
    transition: all 0.2s ease;
}

.chat-input:focus {
    border-color: #2563eb;
    background: white;
}

/* Send Button */
.send-button {
    min-width: 80px;
    height: 40px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    padding: 0 16px;
    font-size: 14px;
    font-weight: 500;
}

.send-button-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.02);
    opacity: 0.95;
}

.send-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Typing Indicator */
.typing-indicator {
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 64px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.32s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.64s; }

@keyframes bounce {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-6px);
    }
}

/* Resize handle */
.resize-handle {
    position: absolute;
    top: 16px;
    left: 16px;
    width: 20px;
    height: 20px;
    cursor: nw-resize;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.resize-handle::before {
    content: '';
    width: 8px;
    height: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
}

.resize-handle:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Custom Scrollbar */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .chat-window {
        width: calc(100% - 32px);
        height: calc(100vh - 140px);
        bottom: 80px;
        right: 16px;
    }
    
    .chat-button {
        min-width: auto;
        padding: 0 16px;
    }
    
    .chat-image-button {
        max-width: 100px; /* Smaller on mobile */
        bottom: 15px;
        right: 15px;
    }

    .message-wrapper {
        max-width: 90%;
    }
    
    .input-container {
        padding: 12px;
    }

    .chat-input {
        font-size: 16px; /* Better for mobile typing */
    }
    
    .send-button {
        min-width: 70px;
        font-size: 13px;
    }
}

/* Accessibility Improvements */
.chat-button:focus,
.chat-input:focus,
.send-button:focus,
.close-button:focus,
.chat-image-button:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

.chat-button:focus:not(:focus-visible),
.chat-input:focus:not(:focus-visible),
.send-button:focus:not(:focus-visible),
.close-button:focus:not(:focus-visible),
.chat-image-button:focus:not(:focus-visible) {
    outline: none;
}


/* Print Styles */
@media print {
    .chat-widget {
        display: none;
    }
}