/**
 * AC Context Aware Chatbase - Chatbot Styles
 * 
 * Basic chatbot styling for the context-aware chatbase plugin.
 * This provides the core chatbot interface styles.
 * 
 * @package AC_Context_Aware_Chatbase
 * @version 1.0.0
 */

/* Chatbot Overlay */
.chatbot-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    display: none !important;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chatbot-overlay.enabled {
    display: block !important;
}

.chatbot-overlay.enabled.active {
    opacity: 1;
    visibility: visible;
}

/* Chatbot Button */
#custom-chatbot-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none !important;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
    z-index: 9999;
}

#custom-chatbot-button.enabled {
    display: flex !important;
}

#custom-chatbot-button:hover {
    background: #0056b3;
    transform: scale(1.05);
}

#custom-chatbot-button.active {
    background: #0056b3;
}

/* Chatbot Window */
#custom-chatbot-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: none !important;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

#custom-chatbot-window.enabled {
    display: none !important;
}

#custom-chatbot-window.enabled.active {
    display: flex !important;
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Legacy support for old container ID */
#chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    max-width: 90vw;
    height: 600px;
    max-height: 80vh;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#chatbot-container.open {
    display: flex;
}

/* Chatbot Header */
.chatbot-header {
    background: #007bff;
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.chatbot-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

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

.chatbot-header-btn,
.chatbot-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.chatbot-header-btn:hover,
.chatbot-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.chatbot-header-btn svg,
.chatbot-close-btn svg {
    width: 20px;
    height: 20px;
}

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

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

/* Chatbot Messages */
#chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    min-height: 0;
}

.chatbot-message {
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.chatbot-message.user-message {
    flex-direction: row-reverse;
}

.message {
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #007bff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.message-avatar svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.chatbot-message.user-message .message-avatar,
.user-message .message-avatar {
    background: #28a745;
}

.message-content {
    flex: 1;
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 80%;
}

.chatbot-message.user-message .message-content,
.user-message .message-content {
    background: #007bff;
    color: white;
}

.message-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.message-text {
    line-height: 1.5;
    word-wrap: break-word;
}

.message-text a {
    color: inherit;
    text-decoration: underline;
}

.chatbot-message.user-message .message-text a,
.user-message .message-text a {
    color: rgba(255, 255, 255, 0.9);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #007bff;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.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% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Chatbot Form */
.chatbot-form {
    flex-shrink: 0;
    border-top: 1px solid #e9ecef;
}

/* Chatbot Input */
.chatbot-input-container {
    padding: 20px;
    background: white;
    display: flex;
    gap: 12px;
    align-items: center;
}

.chatbot-input-container.typing-active {
    opacity: 0.6;
    pointer-events: none;
}

#chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#chatbot-input:focus {
    border-color: #007bff;
}

#chatbot-submit {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

#chatbot-submit svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

#chatbot-submit:hover:not(:disabled) {
    background: #0056b3;
}

#chatbot-submit:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

/* Chatbot Toggle Button */
#chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 4px 16px rgba(0, 123, 255, 0.3);
    transition: all 0.3s ease;
    z-index: 9998;
}

#chatbot-toggle:hover {
    background: #0056b3;
    transform: scale(1.05);
}

#chatbot-toggle.hidden {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    #custom-chatbot-window {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    #custom-chatbot-button {
        bottom: 20px;
        right: 20px;
    }
    
    #chatbot-container {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
    
    .chatbot-header {
        border-radius: 0;
    }
}

/* Typing Animation */
.typing-word-fade {
    opacity: 0;
    animation: typingWordFadeIn 0.3s ease-in-out forwards;
}

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

/* Inline Chatbot Styles */
.chatbot-inline-container {
    border: none;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(85, 34, 221, 0.2);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 20px 0;
    max-height: 100%;
    height: auto;
}

.chatbot-inline-header {
    background: #5522dd;
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chatbot-inline-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: white;
}

.chatbot-inline-new-chat {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.chatbot-inline-new-chat:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chatbot-inline-new-chat svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.chatbot-inline-messages {
    flex: 1 1 auto;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f8f9fa;
    min-height: 0;
    max-height: 100%;
    height: 100%;
    display: block;
    position: relative;
}

.chatbot-inline-form {
    flex-shrink: 0;
    border-top: none;
}

.chatbot-inline-input-container {
    padding: 20px;
    background: white;
    display: flex;
    gap: 12px;
    align-items: center;
}

.chatbot-inline-input {
    flex: 1;
    width: 100%;
    padding: 12px 16px;
    border: none !important;
    border-radius: 500px !important;
    font-size: 14px;
    outline: none !important;
    transition: background-color 0.2s;
    background: #f8f9fa;
}

.chatbot-inline-input:focus {
    background: #ffffff;
    box-shadow: none !important;
    border: none !important;
    outline: none !important;
}

.chatbot-inline-submit {
    background: #dd7722 !important;
    color: white !important;
    border: none !important;
    padding: 0 !important;
    width: 44px !important;
    height: 44px !important;
    border-radius: 500px !important;
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.2s;
    flex-shrink: 0;
    box-shadow: none !important;
    min-width: 44px !important;
    min-height: 44px !important;
    line-height: 1 !important;
    margin: 0 !important;
}

.chatbot-inline-submit:hover:not(:disabled) {
    background: #b8631c !important;
    box-shadow: none !important;
    color: white !important;
}

.chatbot-inline-submit svg {
    fill: white !important;
    color: white !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    vertical-align: middle !important;
}

.chatbot-inline-submit:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.chatbot-inline-submit svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Inline chatbot message styling with custom colors */
.chatbot-inline-container .chatbot-message.user-message .message-content {
    background: #5522dd;
    color: white;
}

.chatbot-inline-container .chatbot-message.assistant-message .message-avatar {
    background: #5522dd;
}

.chatbot-inline-container .message-text a {
    color: inherit;
    text-decoration: underline;
}

.chatbot-inline-container .chatbot-message.user-message .message-text a {
    color: rgba(255, 255, 255, 0.9);
}

.chatbot-inline-container .typing-dots span {
    background: #5522dd;
}

/* Responsive for inline chatbot */
@media (max-width: 768px) {
    .chatbot-inline-container {
        margin: 10px 0;
    }
    
    .chatbot-inline-messages {
        padding: 15px;
    }
}
