/* Mikai Chat Base Styles */
.mikai-chat {
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    max-width: 500px;
    margin: 20px auto;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.mikai-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #2c3e50;
    text-align: center;
}

.mikai-messages {
    height: 350px;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 15px;
    scroll-behavior: smooth;
}

.mikai-message {
    margin-bottom: 12px;
    animation: fadeIn 0.3s ease;
}

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

.mikai-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    max-width: 85%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.mikai-user-bubble {
    background: #007bff;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 5px;
    text-align: right;
}

.mikai-assistant-bubble {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    margin-right: auto;
    border-bottom-left-radius: 5px;
    text-align: left;
}

.mikai-error-bubble {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
    margin-right: auto;
    border-radius: 18px;
}

.mikai-input-area {
    display: flex;
    gap: 10px;
}

.mikai-user-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.mikai-user-input:focus {
    border-color: #007bff;
}

.mikai-user-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.mikai-send-btn {
    padding: 12px 24px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.3s;
    min-width: 80px;
}

.mikai-send-btn:hover:not(:disabled) {
    background: #0056b3;
}

.mikai-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Popup Chat Styles */
.mikai-chat-popup-container {
    position: fixed;
    z-index: 99999;
}

.mikai-chat-popup-container.bottom-right {
    bottom: 20px;
    right: 20px;
}

.mikai-chat-popup-container.bottom-left {
    bottom: 20px;
    left: 20px;
}

.mikai-chat-popup-container.top-right {
    top: 20px;
    right: 20px;
}

.mikai-chat-popup-container.top-left {
    top: 20px;
    left: 20px;
}

.mikai-chat-popup {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    max-height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mikai-chat-popup-container.bottom-left .mikai-chat-popup {
    right: auto;
    left: 0;
}

.mikai-chat-popup-container.top-right .mikai-chat-popup {
    bottom: auto;
    top: 80px;
}

.mikai-chat-popup-container.top-left .mikai-chat-popup {
    bottom: auto;
    top: 80px;
    right: auto;
    left: 0;
}

.mikai-popup-header {
    padding: 16px 20px;
    background: #007bff;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mikai-popup-title {
    font-weight: 600;
    font-size: 16px;
}

.mikai-popup-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.mikai-popup-close:hover {
    background: rgba(255,255,255,0.2);
}

.mikai-popup-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    max-height: 300px;
    background: #f8f9fa;
}

.mikai-popup-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

.mikai-popup-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.mikai-popup-input:focus {
    border-color: #007bff;
}

.mikai-popup-send-btn {
    padding: 12px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.3s;
    min-width: 70px;
}

.mikai-popup-send-btn:hover {
    background: #0056b3;
}

/* Floating Toggle Button */
.mikai-chat-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    font-family: inherit;
    padding: 0;
}

.mikai-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.mikai-chat-toggle.active {
    transform: rotate(90deg);
}

.mikai-toggle-icon {
    font-size: 24px;
    line-height: 1;
}

.mikai-toggle-text {
    font-size: 10px;
    margin-top: 2px;
    font-weight: 500;
}

/* Button Shortcode */
.mikai-chat-popup-btn {
    padding: 12px 24px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.3s;
    font-family: inherit;
}

.mikai-chat-popup-btn:hover {
    background: #0056b3;
}

/* Typing animation */
.mikai-typing .mikai-bubble {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 8px 16px;
}

.typing-dots {
    display: inline-flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* HTML formatting */
.mikai-assistant-bubble h1,
.mikai-assistant-bubble h2,
.mikai-assistant-bubble h3 {
    margin: 0 0 8px 0;
    color: #2c3e50;
}

.mikai-assistant-bubble p {
    margin: 0 0 10px 0;
}

.mikai-assistant-bubble ul,
.mikai-assistant-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.mikai-assistant-bubble li {
    margin: 4px 0;
}

.mikai-assistant-bubble code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.mikai-assistant-bubble pre {
    background: #f5f5f5;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 10px 0;
    font-family: monospace;
    font-size: 0.9em;
}

.mikai-assistant-bubble a {
    color: #007bff;
    text-decoration: none;
}

.mikai-assistant-bubble a:hover {
    text-decoration: underline;
}

/* Scrollbars */
.mikai-messages::-webkit-scrollbar,
.mikai-popup-messages::-webkit-scrollbar {
    width: 6px;
}

.mikai-messages::-webkit-scrollbar-track,
.mikai-popup-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.mikai-messages::-webkit-scrollbar-thumb,
.mikai-popup-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.mikai-messages::-webkit-scrollbar-thumb:hover,
.mikai-popup-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive */
@media (max-width: 768px) {
    .mikai-chat-popup {
        width: 300px;
        max-height: 400px;
        bottom: 70px;
    }
    
    .mikai-chat-popup-container {
        bottom: 10px;
        right: 10px;
    }
    
    .mikai-chat-popup-container.bottom-left {
        bottom: 10px;
        left: 10px;
    }
    
    .mikai-chat-popup-container.top-right {
        top: 10px;
        right: 10px;
    }
    
    .mikai-chat-popup-container.top-left {
        top: 10px;
        left: 10px;
    }
    
    .mikai-chat-toggle {
        width: 56px;
        height: 56px;
    }
    
    .mikai-chat {
        margin: 10px;
        max-width: none;
    }
}