/* Chat widget container - positioned at bottom-right */
.chat-widget-container {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Toggle button */
.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.chat-toggle-btn:active {
    transform: translateY(0);
}

/* Chat window */
.chat-window {
    position: fixed;
    bottom: 10px;
    right: 10px;
    width: 35vw;
    max-width: calc(100vw - 40px);
    height: 60vh;
    max-height: calc(100vh - 120px);
    background: rgba(26, 26, 46, 0.98);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

/* Ensure min/max dimensions so it stays usable */
.chat-window {
    min-width: 300px;
    min-height: 200px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 120px);
}

/* Prevent inner scrollbars from being obscured when resizing */
.chat-window * {
    box-sizing: border-box;
}

/* Chat header */
.chat-window-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
    color: #e4e6ea;
}

.chat-window-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-window-close {
    background: none;
    border: none;
    color: #e4e6ea;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.chat-window-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Chat body */
.chat-window-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 0;
}

/* Custom scrollbar */
.chat-window-body::-webkit-scrollbar {
    width: 8px;
}

.chat-window-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.chat-window-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.chat-window-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Empty state */
.chat-empty-state {
    opacity: 0.9;
    text-align: center;
    margin: 2rem 0;
    color: #e4e6ea;
}

.chat-empty-state h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
}

.chat-empty-state p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Message wrapper */
.chat-message-wrapper {
    display: flex;
    margin-bottom: 0.5rem;
}

.chat-message-wrapper.user {
    justify-content: flex-end;
}

/* Message bubble */
.chat-message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 14px;
    word-wrap: break-word;
    background: rgba(255, 255, 255, 0.08);
    color: #e4e6ea;
}

.chat-message.user {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}

.chat-message.assistant {
    background: rgba(255, 255, 255, 0.08);
    color: #e4e6ea;
}

/* Chat input */
.chat-window-input {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

.chat-window-input input {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.2);
    color: #e4e6ea;
    outline: none;
}

.chat-window-input input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.chat-window-input input::placeholder {
    color: rgba(228, 230, 234, 0.5);
}

.chat-send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
    font-size: 1.4rem;
}

.chat-send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.chat-send-btn:active:not(:disabled) {
    transform: translateY(0);
}

.chat-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: linear-gradient(135deg, #6b7280, #9ca3af);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Markdown styling in messages */
.chat-message strong {
    font-weight: 700;
    color: #fff;
}

.chat-message em {
    font-style: italic;
}

.chat-message code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    color: #7dd3fc;
}

.chat-message pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
    border-left: 3px solid #667eea;
}

.chat-message pre code {
    background: none;
    padding: 0;
    color: #e4e6ea;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: 10px;
    }
    
    .chat-message {
        max-width: 90%;
    }
    
    .chat-window-input {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .chat-window-input input {
        padding: 0.6rem 0.8rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .chat-send-btn {
        width: 44px;
        height: 44px;
    }
}
