/* Chat Widget Styles */

#chat-widget-toggle {
    position: fixed;
    bottom: 20px;
    right: 90px; /* Offset from floatBT button */
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #0085cd;
    color: white;
    border: none;
    cursor: pointer;
    z-index: 98;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chat-widget-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#chat-widget-toggle:focus {
    outline: none;
}

#chat-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    z-index: 98;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-widget-hidden {
    display: none !important;
}

/* Header */
.chat-widget-header {
    background: #0085cd;
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-widget-header span {
    font-weight: 600;
    font-size: 16px;
}

.chat-widget-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.chat-widget-close:hover {
    opacity: 1;
}

/* Messages Area */
.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 200px;
    max-height: 300px;
}

/* Message Bubbles */
.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.4;
    font-size: 14px;
    word-wrap: break-word;
}

.chat-message.user {
    align-self: flex-end;
    background: #0085cd;
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant {
    align-self: flex-start;
    background: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 4px;
}

.chat-message p {
    margin: 0;
}

.chat-message p + p {
    margin-top: 8px;
}

/* Sources */
.chat-message .sources {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 12px;
}

.chat-message .sources-title {
    font-weight: 600;
    margin-bottom: 4px;
    color: #666;
}

.chat-message .source-link {
    display: block;
    color: #0085cd;
    text-decoration: none;
    margin: 2px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-message .source-link:hover {
    text-decoration: underline;
}

.chat-message .source-item {
    display: block;
    color: #555;
    margin: 2px 0;
    font-size: 11px;
}

/* Loading Animation */
.chat-message.loading {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-message.loading .dot {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.chat-message.loading .dot:nth-child(1) {
    animation-delay: -0.32s;
}

.chat-message.loading .dot:nth-child(2) {
    animation-delay: -0.16s;
}

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

/* Filter Area */
.chat-widget-filter {
    padding: 8px 16px;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.chat-widget-filter select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}

.chat-widget-filter select:focus {
    border-color: #0085cd;
    outline: none;
}

/* Input Area */
.chat-widget-input {
    padding: 12px 16px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.chat-widget-input textarea {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
    max-height: 80px;
}

.chat-widget-input textarea:focus {
    border-color: #0085cd;
}

.chat-widget-input button {
    background: #0085cd;
    color: white;
    border: none;
    border-radius: 8px;
    width: 44px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-input button:hover {
    background: #006ba3;
}

.chat-widget-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Footer */
.chat-widget-footer {
    padding: 10px 16px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
    flex-shrink: 0;
    background: #fafafa;
}

.chat-widget-footer a {
    color: #0085cd;
    text-decoration: none;
    font-size: 13px;
}

.chat-widget-footer a:hover {
    text-decoration: underline;
}

/* Error State */
.chat-message.error {
    background: #fff3f3;
    color: #c00;
    border: 1px solid #ffcdd2;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #chat-widget {
        width: calc(100% - 20px);
        right: 10px;
        left: 10px;
        bottom: 80px;
        max-height: 70vh;
    }

    #chat-widget-toggle {
        right: 80px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .chat-widget-messages {
        max-height: calc(70vh - 180px);
    }
}

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

.chat-widget-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-widget-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chat-widget-messages::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}
