/* ChatGPT Chatbot Styles - Positioned above existing analytics chatbot */
.chatgpt-chatbot-container {
    position: fixed;
    bottom: 150px; /* Position higher above the analytics chatbot */
    right: 20px;
    z-index: 9998; /* One level below analytics chatbot z-index 9999 */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.chatgpt-chatbot-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.chatgpt-chatbot-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(139, 92, 246, 0.6);
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
}

.chatgpt-chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 320px;
    height: 420px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e1e5e9;
}

.chatgpt-chatbot-header {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatgpt-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chatgpt-header-icon {
    font-size: 18px;
    color: white;
}

.chatgpt-chatbot-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.chatgpt-chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatgpt-chatbot-clear,
.chatgpt-chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.chatgpt-chatbot-close {
    font-size: 24px;
}

.chatgpt-chatbot-clear:hover,
.chatgpt-chatbot-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.chatgpt-chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chatgpt-chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatgpt-chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chatgpt-chatbot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

.chatgpt-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.chatgpt-message {
    display: flex;
    margin-bottom: 12px;
    animation: fadeInUp 0.3s ease;
}

.chatgpt-message.user {
    justify-content: flex-end;
}

.chatgpt-message.bot {
    justify-content: flex-start;
}

.chatgpt-message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.chatgpt-message.user .chatgpt-message-content {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatgpt-message.bot .chatgpt-message-content {
    background: white;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chatgpt-message.bot.error .chatgpt-message-content {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.chatgpt-message.bot.system .chatgpt-message-content {
    background: #f0f9ff;
    color: #0369a1;
    border-color: #bae6fd;
    font-style: italic;
    font-size: 12px;
    opacity: 0.8;
}

.chatgpt-message-time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.chatgpt-message.bot .chatgpt-message-time {
    text-align: left;
}

/* Typing indicator */
.typing-message .chatgpt-message-content {
    background: white;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chatgpt-typing-indicator {
    display: flex;
    gap: 2px;
}

.chatgpt-typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8b5cf6;
    animation: chatgpt-typing 1.4s infinite;
}

.chatgpt-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.chatgpt-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes chatgpt-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

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

.chatgpt-chatbot-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chatgpt-chatbot-input-area form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#chatgpt-chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    background: #f9fafb;
    resize: none;
    min-height: 40px;
    max-height: 100px;
}

#chatgpt-chatbot-input:focus {
    border-color: #8b5cf6;
    background: white;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

#chatgpt-chatbot-input::placeholder {
    color: #9ca3af;
}

#chatgpt-chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 14px;
    flex-shrink: 0;
}

#chatgpt-chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.4);
}

#chatgpt-chatbot-send:active {
    transform: scale(0.95);
}

#chatgpt-chatbot-send:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Message formatting styles */
.chatgpt-message-content h2 {
    font-size: 16px;
    margin: 8px 0 4px 0;
    color: inherit;
}

.chatgpt-message-content h3 {
    font-size: 15px;
    margin: 6px 0 3px 0;
    color: inherit;
}

.chatgpt-message-content h4 {
    font-size: 14px;
    margin: 4px 0 2px 0;
    color: inherit;
}

.chatgpt-message-content code {
    background: #f3f4f6;
    color: #dc2626;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
}

.chatgpt-message-content pre {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
}

.chatgpt-message-content pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: 12px;
}

.chatgpt-message-content ul {
    margin: 8px 0;
    padding-left: 16px;
}

.chatgpt-message-content ol {
    margin: 8px 0;
    padding-left: 16px;
}

.chatgpt-message-content li {
    margin: 4px 0;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    .chatgpt-chatbot-container {
        bottom: 150px; /* Adjust for mobile - higher positioning */
        right: 15px;
    }
    
    .chatgpt-chatbot-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 200px);
        bottom: 80px;
        right: 10px;
        left: 10px;
        border-radius: 12px;
    }
    
    .chatgpt-chatbot-button {
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
    
    .chatgpt-message-content {
        max-width: 90%;
    }
}

@media (max-width: 360px) {
    .chatgpt-chatbot-window {
        width: calc(100vw - 10px);
        right: 5px;
        left: 5px;
    }
}

/* Ensure ChatGPT chatbot doesn't conflict with analytics chatbot */
.chatgpt-chatbot-container * {
    box-sizing: border-box;
}

/* Special positioning adjustments when both chatbots are present */
.chatbot-container ~ .chatgpt-chatbot-container {
    bottom: 140px; /* Move higher when analytics chatbot is present */
}

/* Slight visual distinction for the ChatGPT button */
.chatgpt-chatbot-button {
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.chatgpt-chatbot-button:hover {
    border-color: rgba(255, 255, 255, 0.3);
}