/* Chatbot Widget Styles */
/* Force preloader to always be on top of everything, including the chatbot */
.mil-preloader {
    z-index: 999999 !important;
}

#knovista-chatbot-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 99999;
    font-family: 'Inter', sans-serif;
}

#knovista-chat-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(249, 115, 22, 0.4);
    border: 2px solid #ffffff;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    outline: none;
    position: relative;
    z-index: 1000;
}

#knovista-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.6);
}

#knovista-chat-toggle svg {
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

#knovista-chat-window {
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 380px;
    height: 560px;
    background-color: #ffffff;
    border-radius: 20px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    display: none;
    flex-direction: column;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    transform-origin: bottom right;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    opacity: 0;
    transform: scale(0.7);
}

#knovista-chat-window.active {
    display: flex;
    opacity: 1;
    transform: scale(1);
}

.knovista-chat-header {
    background: transparent;
    padding: 0;
    border: none;
    position: relative;
    height: 60px;
}

.knovista-chat-header-close {
    background: #f1f3f4;
    border: none;
    color: #000;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: absolute;
    top: 20px;
    right: 20px;
    transition: background-color 0.2s ease;
}

.knovista-chat-header-close:hover {
    background: #e1e3e4;
}

.knovista-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: transparent;
    position: relative;
}

.chat-empty-state {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.15rem;
    font-weight: 500;
    color: #000;
    text-align: center;
    width: 100%;
}

.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: none;
}

.chat-message.ai {
    background: #f1f3f4;
    color: #000;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: none;
}

.chat-message.user {
    background: #000;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    border: none;
}

.chat-message p {
    margin: 0 0 10px 0;
}

.chat-message p:last-child {
    margin-bottom: 0;
}

.chat-message strong {
    font-weight: 700;
}

.chat-message em {
    font-style: italic;
    color: inherit;
    opacity: 0.8;
}

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

.chat-message li {
    margin-bottom: 5px;
}

.knovista-chat-quick-options {
    padding: 12px 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background-color: transparent;
}

.chat-quick-btn {
    background: #2a2a2a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    font-family: 'Inter', sans-serif;
    outline: none;
    -webkit-appearance: none;
}

.chat-quick-btn:hover {
    background: #FF5E14;
    border-color: #FF5E14;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 94, 20, 0.4);
}

.knovista-chat-input-container {
    padding: 10px 20px 20px 20px;
    background-color: transparent;
    border-top: none;
}

.chat-input-wrapper {
    position: relative;
    width: 100%;
    height: 50px;
}

#knovista-chat-input {
    width: 100%;
    height: 50px;
    box-sizing: border-box;
    background-color: #ebebeb;
    border: none;
    color: #333;
    padding: 0 50px 0 20px;
    border-radius: 25px;
    font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
    outline: none;
    transition: background-color 0.2s ease;
}

#knovista-chat-input:focus {
    background-color: #e0e0e0;
}

.chat-mic-btn {
    position: absolute;
    right: 62px;
    top: 13px;
    background: transparent;
    border: none;
    padding: 0;
    width: 24px;
    height: 24px;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#knovista-chat-send {
    position: absolute;
    right: 6px;
    top: 6px;
    background-color: #000;
    color: white;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease;
}

#knovista-chat-send:hover {
    background-color: #333;
}

#knovista-chat-send:disabled {
    background-color: #aaa;
    cursor: not-allowed;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #f1f3f4;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
    margin-bottom: 15px;
}

/* Chat Lead Form */
.chat-lead-form {
    margin-top: 15px;
    padding: 18px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid rgba(0,0,0,0.05);
}

.chat-lead-form input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 15px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    outline: none;
    background: #fafafa;
    transition: all 0.2s ease;
}

.chat-lead-form input:focus {
    border-color: #FF5E14;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(255, 94, 20, 0.1);
}

.chat-lead-form button {
    width: 100%;
    padding: 12px;
    background: #000;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 5px;
}

.chat-lead-form button:hover {
    background: #FF5E14;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(255, 94, 20, 0.3);
}

.chat-lead-form button:disabled {
    background: #888;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: #888;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Scrollbar styling for chat */
.knovista-chat-messages::-webkit-scrollbar {
    width: 6px;
}
.knovista-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.knovista-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
.knovista-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    #knovista-chatbot-container {
        bottom: 20px;
        right: 20px;
    }

    #knovista-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px); /* Taller on mobile */
        max-height: 600px;
        right: 0;
        bottom: 0;
        border-radius: 16px;
    }
    
    #knovista-chat-input {
        padding: 0 70px 0 15px; /* Slightly less padding on mobile */
    }
    
    .chat-mic-btn {
        right: 42px;
    }
}

@media (max-width: 480px) {
    #knovista-chatbot-container {
        bottom: 15px;
        right: 15px;
    }
    
    #knovista-chat-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 40px); /* Maximize space */
        bottom: 0;
        border-radius: 12px;
    }
    
    .chat-lead-form {
        padding: 12px; /* Tighter padding for forms */
    }
}

/* Chat Button Links (Navigating to pages) */
.chat-btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 22px;
    margin-top: 12px;
    background-color: #000;
    color: #fff !important;
    text-decoration: none;
    border-radius: 25px;
    font-size: 13.5px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    letter-spacing: 0.3px;
}

.chat-btn-link:hover {
    background-color: #FF5E14;
    color: #fff !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(255, 94, 20, 0.4);
}

/* Inline Chat Links */
.chat-inline-link {
    color: #FF5E14;
    text-decoration: underline;
    font-weight: 600;
    transition: color 0.2s ease;
}

.chat-inline-link:hover {
    color: #cc4a10;
}

/* AI Avatar and Message Row */
.chat-message-row.ai {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 90%;
}

.chat-message-row.ai .chat-message.ai {
    max-width: 100%;
}

.chat-ai-avatar {
    width: 34px;
    height: 34px;
    border-radius: 5px;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Tooltip for Build Solution */
.chat-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    white-space: normal;
    width: 200px;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.chat-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: #000 transparent transparent transparent;
}

.chat-tooltip.show {
    opacity: 1;
}

/* Mobile Responsiveness for Chatbot Widget */
@media (max-width: 480px) {
    #knovista-chatbot-container {
        right: 15px;
        bottom: 15px;
    }
    
    #knovista-chat-window {
        width: calc(100vw - 30px);
        height: 75vh;
        max-height: 600px;
        bottom: 70px;
    }
}
