/* MPTI Chatbase AI - Chat Widget Styles */
.mpti-chatbox {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 380px;
    max-width: 90vw;
    height: 600px;
    max-height: 80vh;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid #e1e5e9;
}

.mpti-chatbox.minimized {
    height: 70px;
    width: 70px;
    border-radius: 50%;
    cursor: pointer;
}

.mpti-chatbox.minimized .header,
.mpti-chatbox.minimized .messages,
.mpti-chatbox.minimized .input-area {
    display: none;
}

.mpti-chatbox.minimized .chat-toggle {
    display: flex !important;
}

/* Header Styles */
.mpti-chatbox .header {
    background: linear-gradient(135deg, #2d5016 0%, #4a7c59 100%);
    color: white;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.mpti-chatbox .header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.mpti-chatbox .logo {
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.mpti-chatbox .title h3 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
}

.mpti-chatbox .title p {
    margin: 2px 0 0 0;
    font-size: 10px;
    opacity: 0.8;
}

.mpti-chatbox .header-actions {
    display: flex;
    gap: 8px;
}

.mpti-chatbox .header-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 10px;
}

.mpti-chatbox .header-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.mpti-chatbox .chat-toggle {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

/* Messages Area */
.mpti-chatbox .messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mpti-chatbox .message {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mpti-chatbox .message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.mpti-chatbox .message.bot {
    align-self: flex-start;
}

.mpti-chatbox .message-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    flex-shrink: 0;
}

.mpti-chatbox .message.user .message-avatar {
    background: linear-gradient(135deg, #2d5016, #4a7c59);
}

.mpti-chatbox .message.bot .message-avatar {
    background: linear-gradient(135deg, #6b7280, #9ca3af);
}

.mpti-chatbox .message-content {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 11px;
    line-height: 1.3;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.mpti-chatbox .message.user .message-content {
    background: linear-gradient(135deg, #2d5016, #4a7c59);
    color: white;
    border-bottom-right-radius: 6px;
}

.mpti-chatbox .message.bot .message-content {
    background: white;
    color: #374151;
    border-bottom-left-radius: 6px;
    border: 1px solid #e5e7eb;
}

/* Typing Indicator */
.mpti-chatbox .typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    border: 1px solid #e5e7eb;
    align-self: flex-start;
}

.mpti-chatbox .typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.mpti-chatbox .typing-dot:nth-child(1) { animation-delay: -0.32s; }
.mpti-chatbox .typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.mpti-chatbox .input-area {
    padding: 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.mpti-chatbox .input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.mpti-chatbox textarea {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 15px;
    padding: 8px 12px;
    resize: none;
    font-family: inherit;
    font-size: 11px;
    line-height: 1.3;
    max-height: 80px;
    transition: all 0.2s ease;
    background: #f9fafb;
}

.mpti-chatbox textarea:focus {
    outline: none;
    border-color: #4a7c59;
    background: white;
    box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.1);
}

.mpti-chatbox .send-btn {
    background: linear-gradient(135deg, #2d5016, #4a7c59);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 12px;
    flex-shrink: 0;
}

.mpti-chatbox .send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(74, 124, 89, 0.3);
}

.mpti-chatbox .send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.mpti-chatbox .timestamp {
    font-size: 9px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: center;
}

/* Welcome Message */
.mpti-chatbox .welcome-message {
    text-align: center;
    padding: 16px;
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid #bae6fd;
}

.mpti-chatbox .welcome-message h4 {
    margin: 0 0 6px 0;
    color: #2d5016;
    font-size: 11px;
}

.mpti-chatbox .welcome-message p {
    margin: 0;
    color: #4a7c59;
    font-size: 10px;
    line-height: 1.3;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mpti-chatbox {
        right: 10px;
        bottom: 10px;
        width: calc(100vw - 20px);
        max-width: none;
        height: 70vh;
        border-radius: 16px;
    }

    .mpti-chatbox.minimized {
        right: 10px;
        bottom: 10px;
        width: 60px;
        height: 60px;
    }

    .mpti-chatbox .message {
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .mpti-chatbox .header {
        padding: 16px;
    }

    .mpti-chatbox .messages {
        padding: 16px;
    }

    .mpti-chatbox .input-area {
        padding: 16px;
    }
}

/* Enhanced Message Features */
.mpti-chatbox .message-content p {
    margin: 0 0 8px 0;
}

.mpti-chatbox .message-content p:last-child {
    margin-bottom: 0;
}

.mpti-chatbox .message-content ul {
    margin: 8px 0;
    padding-left: 16px;
}

.mpti-chatbox .message-content li {
    margin: 4px 0;
}

.mpti-chatbox .message-content strong {
    color: #2d5016;
}

.mpti-chatbox .mpti-link {
    color: #4a7c59;
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
}

.mpti-chatbox .mpti-link:hover {
    text-decoration: underline;
}

.mpti-chatbox .message-source {
    font-size: 8px;
    color: #6b7280;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e5e7eb;
    opacity: 0.8;
}

/* CTAs and External Links */
.mpti-chatbox .message-ctas,
.mpti-chatbox .message-external-links {
    margin: 12px 0;
    padding: 12px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.mpti-chatbox .cta-label,
.mpti-chatbox .links-label {
    font-size: 10px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.mpti-chatbox .cta-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mpti-chatbox .cta-button {
    display: inline-block;
    padding: 6px 10px;
    background: #4a7c59;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s ease;
}

.mpti-chatbox .cta-button:hover {
    background: #2d5016;
    transform: translateY(-1px);
}

.mpti-chatbox .cta-button.cta-high {
    background: #dc2626;
}

.mpti-chatbox .cta-button.cta-high:hover {
    background: #ef4444;
}

.mpti-chatbox .links-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mpti-chatbox .external-link {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    color: #4a7c59;
    text-decoration: none;
    border-radius: 4px;
    font-size: 10px;
    transition: all 0.2s ease;
}

.mpti-chatbox .external-link:hover {
    background: #e0f2fe;
    text-decoration: none;
}

/* AI Features Indicators */
.mpti-chatbox .ai-feature-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    background: #10b981;
    color: white;
    margin-left: 8px;
}

.mpti-chatbox .sentiment-positive .message-content {
    border-left: 3px solid #10b981;
}

.mpti-chatbox .sentiment-negative .message-content {
    border-left: 3px solid #ef4444;
}

.mpti-chatbox .sentiment-urgent .message-content {
    border-left: 3px solid #f59e0b;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}