/* ai-chatbot.css */

:root {
    --primary-color: #0073aa;
    --primary-color-hover: #005a87;
    --header-color: var(--primary-color);
    --header-text-color: #ffffff;
    --bubble-color: var(--primary-color);
    --bubble-shadow-color: rgba(0, 0, 0, 0.2);
    --user-message-color: var(--primary-color);
    --user-text-color: #ffffff;
    --bot-message-color: var(--primary-color);
    --bot-text-color: #ffffff;
    --bot-message-shadow: #005a87;
    --input-border-color: #e0e0e0;
    --input-focus-border-color: var(--primary-color);
    --input-focus-shadow-color: rgba(0, 115, 170, 0.2);
}

/* Chat Bubble */
#ai-chatbot-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background-color: #0073aa;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#ai-chatbot-bubble:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

#ai-chatbot-bubble img {
    width: 50px;
    height: 50px;
    transition: transform 0.3s ease;
}

#ai-chatbot-bubble:hover img {
    transform: rotate(10deg);
}

/* Flashing Animation */
#ai-chatbot-bubble.flash {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); }
    50% { transform: scale(1.1); box-shadow: 0 8px 20px rgba(0, 115, 170, 0.4); }
    100% { transform: scale(1); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); }
}

/* Chat Window */
#ai-chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 350px;
    height: 500px;
    background-color: #ffffff;
    border: none;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
}

#ai-chatbot-window.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    visibility: hidden;
}

/* Chat Header */
#ai-chatbot-header {
    background-color: #0073aa;
    color: #ffffff;
    padding: 14px;
    font-size: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

#ai-chatbot-title {
    font-weight: 500;
    letter-spacing: 0.3px;
}

#ai-chatbot-close {
    cursor: pointer;
    font-size: 20px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

#ai-chatbot-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* New Chat Button */
#ai-chatbot-new-chat {
    cursor: pointer;
    font-size: 20px;
    margin-right: 15px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

#ai-chatbot-new-chat:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: rotate(180deg);
}

/* Chat Messages */
#chat-window {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
}

.chat-message {
    margin-bottom: 16px;
    padding: 14px;
    border-radius: 18px;
    max-width: 85%;
    position: relative;
    box-shadow: 0 1px 4px rgba(0, 115, 170, 0.2);
    animation: messageAppear 0.3s ease-out;
    color: #ffffff !important; /* Force white text for all messages */
}

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

.user-message {
    background-color: #0073aa;
    color: #ffffff;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.bot-message {
    background-color: #0073aa;
    color: #ffffff !important;
    align-self: flex-start;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    border-left: 3px solid #005a87;
}

/* Error messages with better visibility */
.bot-message.error {
    background-color: #fff0f0 !important;
    border-left: 3px solid #ff5252 !important;
    color: #d32f2f !important;
    padding: 14px;
    font-size: 14px;
    line-height: 1.5;
}

.bot-message.error strong {
    color: #d32f2f !important;
    font-weight: bold;
}

.bot-message.error code {
    background-color: #ffeeee;
    padding: 3px 5px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 13px;
    color: #e53935 !important;
}

.bot-message.error button {
    background-color: #2196F3;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    margin-top: 10px;
    cursor: pointer;
    font-size: 13px;
    transition: background-color 0.2s;
}

.bot-message.error button:hover {
    background-color: #1976D2;
}

/* Chat Input */
#ai-chatbot-input {
    display: flex;
    padding: 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background-color: #ffffff;
    align-items: center;
}

#ai-chatbot-input input,
#ai-chatbot-input textarea,
#user-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid var(--input-border-color);
    border-radius: 24px;
    outline: none;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    resize: none;
    height: 40px;
}

#user-input:focus,
#ai-chatbot-input input:focus,
#ai-chatbot-input textarea:focus {
    outline: none !important;
    border-color: var(--input-focus-border-color) !important;
    box-shadow: 0 1px 5px var(--input-focus-shadow-color) !important;
}

#send-button,
.send,
#ai-chatbot-input button {
    font-size: 20px !important;
    font-weight: bold !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 50px !important;
    height: 50px !important;
    border-radius: 50% !important;
    padding: 0 !important;
    min-width: 50px !important;
    background-color: var(--header-color) !important;
    border: none !important;
    color: var(--header-text-color) !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25) !important;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
    cursor: pointer !important;
    position: relative !important;
    overflow: hidden !important;
}

/* Add subtle gradient overlay */
#send-button:before,
.send:before,
#ai-chatbot-input button:before {
    content: "" !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%) !important;
    border-radius: 50% !important;
    z-index: 1 !important;
}

#send-button:after,
.send:after,
#ai-chatbot-input button:after {
    content: "\2192" !important; /* Unicode arrow character */
    font-size: 26px !important;
    font-weight: bold !important;
    position: relative !important;
    display: inline-block !important;
    top: -1px !important;
    left: 1px !important; /* Slight adjustment for visual centering */
    line-height: 1 !important;
    z-index: 2 !important; /* Ensure arrow is above gradient */
}

#send-button:hover,
.send:hover,
#ai-chatbot-input button:hover {
    background-color: var(--primary-color-hover) !important;
    transform: translateY(-2px) scale(1.05) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3) !important;
}

/* Suggested Questions */
#suggested-questions {
    padding: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    display: flex;
    flex-wrap: wrap;
    background-color: #ffffff;
}

.suggested-question {
    background-color: #f0f7fa;
    color: #0073aa;
    border: 1px solid #e0e0e0;
    padding: 6px 12px;
    margin: 5px 5px 0 0;
    cursor: pointer;
    font-size: 13px;
    border-radius: 16px;
    transition: all 0.2s ease;
    animation: fadeIn 0.5s ease-out;
}

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

.suggested-question:hover {
    background-color: #e1f0f7;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 14px;
    background-color: #0073aa;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    border-left: 3px solid #005a87;
    align-self: flex-start;
    max-width: 85%;
    margin-right: auto;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0, 115, 170, 0.2);
    color: #ffffff;
}

.typing-indicator .dot {
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: currentColor; /* Match the text color of the container */
    border-radius: 50%;
    opacity: 0.7;
    animation: bounce 1.3s linear infinite;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-4px);
    }
}

/* Responsive Design */
@media screen and (max-width: 767px) {
    #ai-chatbot-window {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
        border-radius: 0;
        margin: 0;
        max-width: none;
        max-height: none;
        z-index: 999999;
        /* Safe area insets for notches and home indicators */
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        padding-left: env(safe-area-inset-left, 0);
        padding-right: env(safe-area-inset-right, 0);
    }
    
    #ai-chatbot-header {
        border-radius: 0;
        padding: 16px;
        position: sticky;
        top: 0;
        z-index: 2;
    }
    
    #ai-chatbot-input {
        position: sticky;
        bottom: 0;
        padding: 16px;
        background: #ffffff;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
        z-index: 2;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
    }
    
    #chat-window {
        flex: 1;
        height: calc(100% - 130px); /* Account for header and input */
        overflow-y: auto;
    }
    
    /* Hide bubble when window is open on mobile */
    body.chatbot-open #ai-chatbot-bubble {
        display: none;
    }
    
    /* Ensure chatbot doesn't get covered by fixed elements */
    body.chatbot-open {
        overflow: hidden;
    }
}

/* Fullscreen Mode on Mobile */
#ai-chatbot-window.mobile-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0 !important;
    margin: 0 !important;
    max-width: none !important;
    max-height: none !important;
    z-index: 999999 !important;
    /* Safe area insets for notches and home indicators */
    padding-top: env(safe-area-inset-top, 0) !important;
    padding-bottom: env(safe-area-inset-bottom, 0) !important;
    padding-left: env(safe-area-inset-left, 0) !important;
    padding-right: env(safe-area-inset-right, 0) !important;
}

#ai-chatbot-window.mobile-fullscreen #ai-chatbot-header {
    border-radius: 0 !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
}

#ai-chatbot-window.mobile-fullscreen #ai-chatbot-input {
    position: sticky !important;
    bottom: 0 !important;
    background: #ffffff !important;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
    z-index: 100 !important;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0)) !important;
}

#ai-chatbot-window.mobile-fullscreen #chat-window {
    flex: 1 !important;
    height: calc(100% - 130px) !important; /* Account for header and input */
    overflow-y: auto !important;
}

/* Button Styling Fixes */
#ai-chatbot-new-chat, #ai-chatbot-close {
    font-size: 24px !important;
    font-weight: bold !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: none !important;
    border: none !important;
    color: white !important;
}

/* Improve message content styling for better visibility */
.message-content {
    color: white !important;
}

.message-content code {
    background-color: rgba(255, 255, 255, 0.2);
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
    color: #f0f0f0 !important;
}

.message-content pre {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 10px 0;
}

.message-content pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    display: block;
    white-space: pre;
}

.message-content h1, .message-content h2, .message-content h3 {
    margin: 10px 0;
    font-weight: bold;
}

.message-content h1 {
    font-size: 1.4em;
}

.message-content h2 {
    font-size: 1.2em;
}

.message-content h3 {
    font-size: 1.1em;
}

.message-content ul, .message-content ol {
    margin: 10px 0;
    padding-left: 20px;
}

.message-content strong {
    font-weight: bold;
}

.message-content em {
    font-style: italic;
}

/* Make code blocks copyable/selectable with a better appearance */
.message-content pre code {
    user-select: all;
    cursor: pointer;
}

.message-content a {
    color: #ffffff !important;
    text-decoration: underline;
    font-weight: bold;
}

.message-content a:hover {
    text-decoration: none;
    opacity: 0.8;
}

/* More specific device targeting */
/* Small phones */
@media screen and (max-width: 375px) {
    #ai-chatbot-window {
        width: 100% !important;
        height: 100% !important;
    }
    
    .chat-message {
        max-width: 90%;
    }
}

/* Tablets and small laptops */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    #ai-chatbot-window {
        width: 450px !important;
        height: 600px !important; 
        max-width: 90%;
        max-height: 80%;
    }
}

/* For the chatbot bubble positioning on mobile */
@media screen and (max-width: 767px) {
    #ai-chatbot-bubble {
        width: 60px;
        height: 60px;
        bottom: 15px;
        right: 15px;
    }
    
    #ai-chatbot-bubble img {
        width: 35px;
        height: 35px;
    }
}
