/* AI Chat Widget Styles */
.ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 500px;
    height: 700px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    transition: width 0.3s ease, height 0.3s ease, left 0.3s ease, top 0.3s ease, bottom 0.3s ease;
    resize: both;
    overflow: hidden;
}

.ai-chat-widget.collapsed .ai-chat-body {
    display: none;
}

.ai-chat-widget.collapsed {
    max-height: 60px;
    height: 60px !important;
    min-height: 60px;
    resize: none;
}

.ai-chat-widget.minimized {
    width: 60px !important;
    height: 60px !important;
    min-width: 60px !important;
    min-height: 60px !important;
    max-width: 60px !important;
    max-height: 60px !important;
    border-radius: 50%;
    resize: none !important;
}

.ai-chat-widget.minimized .ai-chat-header,
.ai-chat-widget.minimized .ai-chat-body {
    display: none;
}

.ai-chat-header {
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    color: white;
    padding: 16px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
    user-select: none;
}

.ai-chat-header.dragging {
    cursor: grabbing;
}

.ai-chat-widget.collapsed .ai-chat-header {
    cursor: pointer;
}

.chat-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 16px;
}

.chat-controls {
    display: flex;
    gap: 4px;
}

.chat-controls .btn {
    padding: 4px 8px;
}

.ai-chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
}

.chat-message {
    margin-bottom: 12px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user-message {
    display: flex;
    justify-content: flex-end;
}

.chat-message.user-message .message-bubble {
    background: #0d6efd;
    color: white;
    border-radius: 18px 18px 4px 18px;
}

.chat-message.ai-message .message-bubble {
    background: white;
    color: #333;
    border-radius: 18px 18px 18px 4px;
    border: 1px solid #e0e0e0;
}

.chat-message.system-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    background: #e3f2fd;
    border-radius: 8px;
    font-size: 13px;
    color: #1976d2;
}

.message-bubble {
    padding: 10px 14px;
    max-width: 80%;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-bubble code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.message-bubble pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 8px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 8px 0;
}

.chat-input-container {
    border-top: 1px solid #e0e0e0;
    padding: 12px;
    background: white;
    border-radius: 0 0 12px 12px;
}

.chat-input-container .input-group {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.context-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    padding: 4px 8px;
    background: #f0f0f0;
    border-radius: 4px;
}

.context-indicator i {
    color: #0d6efd;
}

#contextToggleBtn {
    margin-left: auto;
    padding: 2px 6px;
    color: #0d6efd;
}

#contextToggleBtn:hover {
    color: #0a58ca;
}

#contextToggleBtn i {
    font-size: 16px;
}

#chatInput {
    flex: 1;
    resize: none;
    border-radius: 20px;
    padding: 10px 16px;
    border: 1px solid #e0e0e0;
    font-size: 14px;
    max-height: 120px;
    overflow-y: hidden;
    line-height: 1.5;
}

#chatInput:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
    outline: none;
}

#chatSendBtn {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    padding: 0;
    background: #0d6efd;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#chatSendBtn i {
    margin-top: -2px;
    font-size: 14px;
}

#chatSendBtn:hover {
    background: #0a58ca;
}

#chatSendBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Floating button when minimized */
.ai-chat-widget.minimized::before {
    content: '\f086';
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 24px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    border-radius: 50%;
    cursor: pointer;
}

/* Thinking section styles */
.thinking-section {
    margin-bottom: 12px;
    border-left: 3px solid #0d6efd;
    padding-left: 10px;
}

.thinking-toggle {
    background: transparent;
    border: none;
    color: #0d6efd;
    font-size: 12px;
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    transition: color 0.2s;
}

.thinking-toggle:hover {
    color: #0a58ca;
}

.thinking-toggle i {
    font-size: 11px;
}

.thinking-content {
    margin-top: 8px;
    padding: 10px;
    background: rgba(13, 110, 253, 0.05);
    border-radius: 6px;
    font-style: italic;
    font-size: 0.85em;
    color: #666;
    line-height: 1.5;
}

.answer-content {
    color: #333;
}

/* Streaming cursor animation */
.streaming-cursor {
    display: inline-block;
    margin-left: 2px;
    animation: blink 1s infinite;
    color: #0d6efd;
    font-weight: bold;
}

@keyframes blink {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .ai-chat-widget {
        width: 100%;
        max-width: calc(100vw - 40px);
        right: 20px;
        left: 20px;
    }
}
