/* 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;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 87, 49, 0.3);
    animation: pulse 2s infinite;
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 100000;
    border: 4px solid #2db568;
    transition: all 0.3s ease;
}

.mpti-chatbox.minimized .header,
.mpti-chatbox.minimized .messages,
.mpti-chatbox.minimized .input-area {
    display: none;
}

.mpti-chatbox.minimized::after {
    content: '';
    display: block;
    width: 28px;
    height: 28px;
    background-color: #2db568;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z'/%3E%3C/svg%3E");
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

/* Header Styles */
.mpti-chatbox .header {
    background: linear-gradient(135deg, #005731 0%, #2db568 100%);
    color: white;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    box-shadow: 0 2px 10px rgba(0, 87, 49, 0.2);
}

.mpti-chatbox .header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.mpti-chatbox .logo {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    background-image: url('../mpti_logo.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.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: 28px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.mpti-chatbox .chat-toggle i {
    display: block;
}

/* Messages Area */
.mpti-chatbox .messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: linear-gradient(135deg, #f8fffe 0%, #f0f9f5 100%);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.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, #005731, #2db568);
}

.mpti-chatbox .message.bot .message-avatar {
    background: linear-gradient(135deg, #6b7280, #9ca3af);
}

.mpti-chatbox .message-content {
    padding: 5px 10px;
    border-radius: 12px;
    font-size: 11px;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    word-wrap: break-word;
}

.mpti-chatbox .message.user .message-content {
    background: linear-gradient(135deg, #005731, #2db568);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 3px 12px rgba(0, 87, 49, 0.2);
}

.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: #2db568;
    background: white;
    box-shadow: 0 0 0 3px rgba(45, 181, 104, 0.15);
}

.mpti-chatbox .send-btn {
    background: linear-gradient(135deg, #005731, #2db568);
    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;
    box-shadow: 0 2px 8px rgba(0, 87, 49, 0.3);
}

.mpti-chatbox .send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(45, 181, 104, 0.4);
    background: linear-gradient(135deg, #2db568, #75be86);
}

.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, #c3e0c5, #f0f9f5);
    border-radius: 12px;
    margin-bottom: 8px;
    border: 1px solid #75be86;
    box-shadow: 0 2px 8px rgba(117, 190, 134, 0.1);
}

.mpti-chatbox .welcome-message h4 {
    margin: 0 0 6px 0;
    color: #005731;
    font-size: 11px;
    font-weight: 600;
}

.mpti-chatbox .welcome-message p {
    margin: 0;
    color: #2db568;
    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: 12px;
    }

    .mpti-chatbox .messages {
        padding: 10px;
    }

    .mpti-chatbox .input-area {
        padding: 12px;
    }
}

/* Enhanced Message Features */
.mpti-chatbox .message-content p {
    margin: 0;
}

.mpti-chatbox .message-content p + p {
    margin-top: 4px;
}

.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: #005731;
    font-weight: 600;
}

.mpti-chatbox .mpti-link {
    color: #2db568;
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    transition: color 0.2s ease;
}

.mpti-chatbox .mpti-link:hover {
    color: #005731;
    text-decoration: underline;
}

.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;
        transform: scale(1);
    }
    50% { 
        opacity: 0.9;
        transform: scale(1.05);
    }
}

/* Chat Popup */
.mpti-chat-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    z-index: 100001;
    max-width: 350px;
    width: 90vw;
    text-align: center;
    animation: popupSlideIn 0.4s ease;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    border: 2px solid #2db568;
}

.mpti-chat-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 100000;
    animation: fadeIn 0.3s ease;
}

.mpti-chat-popup .popup-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.mpti-chat-popup .popup-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #005731, #2db568);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

.mpti-chat-popup h3 {
    margin: 0;
    color: #005731;
    font-size: 20px;
    font-weight: 600;
}

.mpti-chat-popup p {
    margin: 15px 0 20px 0;
    color: #666;
    line-height: 1.5;
}

.mpti-chat-popup .popup-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.mpti-chat-popup .popup-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    font-size: 14px;
}

.mpti-chat-popup .popup-btn.primary {
    background: linear-gradient(135deg, #005731, #2db568);
    color: white;
}

.mpti-chat-popup .popup-btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 181, 104, 0.3);
}

.mpti-chat-popup .popup-btn.secondary {
    background: #f5f5f5;
    color: #666;
}

.mpti-chat-popup .popup-btn.secondary:hover {
    background: #e5e5e5;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Quick Actions and Suggestions */
.mpti-chatbox .quick-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.mpti-chatbox .quick-btn {
    background: linear-gradient(135deg, #005731, #2db568);
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 15px;
    font-size: 9px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.mpti-chatbox .quick-btn:hover {
    background: linear-gradient(135deg, #2db568, #75be86);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(45, 181, 104, 0.3);
}

.mpti-chatbox .message-suggestions,
.mpti-chatbox .message-followup {
    margin: 12px 0;
    padding: 12px;
    background: linear-gradient(135deg, #c3e0c5, #f0f9f5);
    border-radius: 12px;
    border: 1px solid #75be86;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mpti-chatbox .suggestions-label,
.mpti-chatbox .followup-label {
    font-size: 10px;
    font-weight: 600;
    color: #005731;
    margin-bottom: 8px;
}

.mpti-chatbox .suggestions-list,
.mpti-chatbox .followup-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mpti-chatbox .suggestion-btn,
.mpti-chatbox .followup-btn {
    background: white;
    border: 1px solid #2db568;
    color: #005731;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-weight: 500;
}

.mpti-chatbox .suggestion-btn:hover,
.mpti-chatbox .followup-btn:hover {
    background: linear-gradient(135deg, #2db568, #75be86);
    color: white;
    transform: translateX(3px);
    box-shadow: 0 2px 8px rgba(45, 181, 104, 0.2);
}

/* Intelligence Indicators */
.mpti-chatbox .intelligence-info {
    font-size: 8px;
    color: #2db568;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid #c3e0c5;
    opacity: 0.9;
    font-weight: 500;
}

.mpti-chatbox .message-source {
    font-size: 8px;
    color: #75be86;
    margin-top: 2px;
    opacity: 0.8;
}

/* Enhanced Message Features */
.mpti-chatbox .message.bot .message-content {
    background: white;
    color: #374151;
    border-bottom-left-radius: 6px;
    border: 1px solid #c3e0c5;
    box-shadow: 0 2px 8px rgba(195, 224, 197, 0.2);
}

/* Typing indicator enhancement */
.mpti-chatbox .typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    border: 1px solid #c3e0c5;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(195, 224, 197, 0.2);
}

.mpti-chatbox .typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2db568;
    animation: typingBounce 1.4s infinite ease-in-out;
}

/* Hover effects for minimized state */
.mpti-chatbox.minimized:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 87, 49, 0.4);
}