/* XResearch Chat Widget Styles */

:root {
    --mint-teal: #083a3a;
    --mint-bg: #d4e8e8;
}

/* Chat Widget */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--mint-teal) 0%, #0a4a4a 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(8, 58, 58, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    transition: all 0.3s ease;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(8, 58, 58, 0.5);
}

.chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9998;
}

.chat-window.open {
    display: flex;
}

.chat-header {
    background: linear-gradient(135deg, var(--mint-teal) 0%, #0a4a4a 100%);
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.chat-header-buttons {
    display: flex;
    gap: 0.5rem;
}

.chat-header-button {
    background: none;
    border: none;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.chat-header-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-close {
    font-size: 1.5rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #f8f9fa;
}

.chat-message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
}

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

.chat-message.assistant {
    align-self: flex-start;
}

.chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.chat-message.user .chat-avatar {
    background: var(--mint-teal);
}

.chat-message.assistant .chat-avatar {
    background: #e8f5f5;
}

.chat-bubble {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
}

.chat-message.user .chat-bubble {
    background: var(--mint-teal);
    color: white;
}

.chat-message.assistant .chat-bubble {
    background: white;
    color: #333;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-bubble h1, .chat-bubble h2, .chat-bubble h3, .chat-bubble h4 {
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.chat-bubble h1 { font-size: 1.4rem; }
.chat-bubble h2 { font-size: 1.3rem; }
.chat-bubble h3 { font-size: 1.15rem; }
.chat-bubble h4 { font-size: 1.05rem; }

.chat-bubble p {
    margin-bottom: 0.75rem;
}

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

.chat-bubble ul, .chat-bubble ol {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.chat-bubble li {
    margin-bottom: 0.25rem;
}

.chat-bubble code {
    background: #f5f5f5;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.chat-bubble pre {
    background: #f5f5f5;
    padding: 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
    margin-bottom: 0.75rem;
}

.chat-bubble pre code {
    background: none;
    padding: 0;
}

.chat-bubble strong {
    font-weight: 600;
}

.chat-bubble em {
    font-style: italic;
}

.chat-bubble blockquote {
    border-left: 3px solid var(--mint-teal);
    padding-left: 1rem;
    margin: 0.75rem 0;
    color: #666;
}

.chat-sources {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e0e0e0;
    font-size: 0.85rem;
}

.chat-sources-title {
    font-weight: 600;
    color: #666;
    margin-bottom: 0.5rem;
}

.chat-source-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    background: #f8f9fa;
    border-radius: 6px;
    text-decoration: none;
    color: var(--mint-teal);
    transition: all 0.2s ease;
}

.chat-source-link:hover {
    background: #e8f5f5;
    transform: translateX(3px);
}

.chat-source-icon {
    font-size: 1rem;
}

.chat-source-text {
    flex: 1;
    font-size: 0.85rem;
}

.chat-input-container {
    padding: 1rem;
    background: white;
    border-top: 1px solid #e0e0e0;
    position: relative;
}

.chat-input {
    width: 100%;
    padding: 0.5rem 3.5rem 0.5rem 1rem;
    border: 2px solid var(--mint-bg);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    overflow-y: auto;
    height: 56px;
    line-height: 1.4;
}

.chat-input:focus {
    outline: none;
    border-color: var(--mint-teal);
}

.chat-send-button {
    position: absolute;
    right: 1.5rem;
    bottom: 1.5rem;
    width: 36px;
    height: 36px;
    background: var(--mint-teal);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
}

.chat-send-button:hover {
    background: #0a4a4a;
    transform: scale(1.05);
}

.chat-send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.chat-send-button svg {
    width: 20px;
    height: 20px;
}

.chat-loading {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: fit-content;
}

.chat-loading-dot {
    width: 8px;
    height: 8px;
    background: var(--mint-teal);
    border-radius: 50%;
    animation: loading-bounce 1.4s infinite ease-in-out both;
}

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

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

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

/* Responsive */
@media (max-width: 768px) {
    .chat-window {
        width: calc(100vw - 40px);
        right: 20px;
        left: 20px;
    }
}
