/* Floating chat button */
#ta-chatbot-widget {
    position: fixed;
    bottom: 14px;
    /* right: 24px; */
    left: 47.5%;
    z-index: 9999;
}

/* The round chat icon */
#ta-chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #313166;
    color: #fff;
    border: none;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    font-size: 27px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: box-shadow 0.2s;
}
#ta-chatbot-toggle::before {
    content: "";
    display: inline-block;
    width: 30px;
    height: 30px;
    background-image: url('confused-face-icon-1200693-512.png');
    background-size: cover;
    filter: invert(1);
}
#ta-chatbot-widget.ta-chatbot-open #ta-chatbot-toggle::before {
    content: "";
    display: inline-block;
    width: 30px;
    height: 30px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='black' d='M18.3 5.71L12 12l6.3 6.29-1.41 1.42L12 13.41l-6.29 6.3-1.42-1.42L10.59 12 4.29 5.71 5.71 4.29 12 10.59l6.29-6.3z'/></svg>");
    background-size: cover;
}

/* Hide the popup by default */
#ta-chatbot-popup {
    display: none;
    flex-direction: column;
    position: fixed !important;
    right: 576px !important;
    bottom: 96px !important; /* Adjust this value to sit just above the toggle button */
    width: 350px;
    height: 460px;
    background: #fff;
    border-radius: 12px !important;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    overflow: hidden !important;
    z-index: 9999 !important;
    transition: width .15s ease-in-out !important;
}

/* Show popup when open, hide button */
#ta-chatbot-widget.ta-chatbot-open #ta-chatbot-popup {
    display: flex;
}

/* Header styles */
#ta-chatbot-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: #3b3663;
    color: #fff;
    padding: 16px;
    font-weight: bold;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    min-height: 40px;
}

#ta-chatbot-header > div:first-child {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

#ta-chatbot-title {
    font-size: 18px;
    font-weight: bold;
}
#ta-chatbot-status {
    font-size: 13px;
    color: #d1d1e0;
    margin-top: 2px;
}

/* Header buttons */
#ta-chatbot-header-buttons {
    display: flex;
    gap: 8px;
}

#ta-chatbot-header-buttons button {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: #fff;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ta-chatbot-header-buttons button:hover {
    background: rgba(255, 255, 255, 0.2);
}

#new-conversation-btn {
    font-size: 16px;
    font-weight: bold;
}

/* Messages area */
#ta-chatbot-messages {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    padding: 16px;
    background: #fff;
}

.ta-chatbot-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.ta-chatbot-message-bot {
    align-items: flex-start;
}

.ta-chatbot-bot-name {
    font-size: 12px;
    color: #2c2c6c;
    font-weight: bold;
    margin-bottom: 2px;
}

.ta-chatbot-bot-text {
    background: #23235b;
    color: #fff;
    border-radius: 12px 12px 12px 0;
    padding: 10px 14px;
    font-size: 15px;
}

.ta-chatbot-message-user {
    align-items: flex-end;
    margin-left: auto;
}

.ta-chatbot-user-text {
    background: #f1f1f1;
    color: #23235b;
    border-radius: 12px 12px 0 12px;
    padding: 10px 14px;
    font-size: 15px;
}

.ta-chatbot-date-separator {
    text-align: center;
    color: #888;
    font-size: 13px;
    margin: 16px 0 8px 0;
}

/* Form styles */
#ta-chatbot-form {
    display: flex;
    padding: 12px;
    background: #fff;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
}
#ta-chatbot-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 16px;
    outline: none;
    font-size: 15px;
}

/* Close button at bottom right of popup */
#ta-chatbot-close {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: #3b3663;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ta-chatbot-input-area {
    display: flex;
    align-items: center;
    border-top: 1px solid #eee;
    padding: 10px;
    background: #fff;
    border-radius: 0 0 12px 12px;
}

.ta-chatbot-input-area input[type="text"] {
    flex: 1;
    border: none;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 15px;
    outline: none;
    background: #f7f7fa;
    margin-right: 8px;
}

.ta-chatbot-input-area button {
    background: #23235b;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.ta-chatbot-input-area button:disabled {
    cursor: not-allowed;
    
}

/* Threads Modal */
.ta-chatbot-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    /* right: 576px; */
    bottom: 96px;
}

.ta-chatbot-modal-content {
    background-color: #fff;
    /* margin: 10% auto; */
    padding: 0;
    border-radius: 12px;
    /* width: 90%; */
    max-width: 400px;
    /* box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); */
    animation: modalSlideIn 0.3s ease-out;
    border: 3px solid #eee;

}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ta-chatbot-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 15px 20px;
    border-bottom: 3px solid #eee;
}

.ta-chatbot-modal-header h3 {
    margin: 0;
    color: #23235b;
    font-size: 18px;
    font-weight: 600;
}

.ta-chatbot-modal-close {
    border: none !important;
    font-size: 30px;
    color: #999;
    cursor: pointer;
    padding-bottom: 15px !important;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.ta-chatbot-modal-close:hover {
    background: #f5f5f5;
    color: #666;
}

.ta-chatbot-modal-body {
    padding: 15px 20px 20px 20px;
    max-height: 300px;
    overflow-y: auto;
}

#threads-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

#threads-list li {
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid transparent;
    margin-bottom: 8px;
}

#threads-list li:hover {
    background: #f8f9fa;
    border-color: #e9ecef;
}

#threads-list li:last-child {
    margin-bottom: 0;
}

#threads-list .no-threads {
    text-align: center;
    color: #999;
    font-style: italic;
    cursor: default;
}

#threads-list .no-threads:hover {
    background: none;
    border-color: transparent;
}

.thread-title {
    display: block;
    font-weight: 500;
    color: #23235b;
    margin-bottom: 4px;
    font-size: 14px;
}

.thread-date {
    display: block;
    font-size: 12px;
    color: #999;
}


/* Loading state */
.ta-chatbot-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-style: italic;
}

.ta-chatbot-loading::before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top: 2px solid #23235b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Welcome popup styles */
#ta-chatbot-welcome-popup {
    position: fixed;
    bottom: 96px;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ta-chatbot-welcome-card {
    background: #3b3663;
    border-radius: 18px;
    /* box-shadow: 0 4px 24px rgba(0,0,0,0.15); */
    padding: 32px 24px 24px 24px;
    color: #fff;
    width: 100%;
    max-width: 350px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.ta-chatbot-welcome-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}
.ta-chatbot-welcome-icon {
    font-size: 2.5rem;
    font-weight: 900;
    color: #fff;
    margin-right: 4px;
}
.ta-chatbot-welcome-hi {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
}
.ta-chatbot-wave {
    font-size: 1.7rem;
    margin-left: 2px;
}
.ta-chatbot-welcome-text {
    font-size: 1.05rem;
    color: #fff;
    margin-bottom: 22px;
    text-align: center;
    line-height: 1.5;
}
.ta-chatbot-welcome-convo-box {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    padding: 20px 18px 16px 18px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.ta-chatbot-welcome-avatars {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
    gap: 0.2rem;
}
.ta-chatbot-welcome-avatars img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #fff;
    object-fit: cover;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-right: -8px;
}
.ta-chatbot-welcome-convo-text {
    text-align: center;
    margin-bottom: 12px;
}
.ta-chatbot-welcome-convo-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #23235b;
}
.ta-chatbot-welcome-convo-desc {
    font-size: 0.95rem;
    color: #888;
    margin-top: 2px;
}
.ta-chatbot-welcome-new-btn {
    background: #ffffff;
    color: #3b3663 !important;
    border: none;
    border-radius: 22px;
    padding: 10px 28px;
    font-size: 1rem;
    font-weight: 600;
    margin: 12px 0 6px 0;
    cursor: pointer;
    /* box-shadow: 0 2px 8px rgba(247,37,133,0.08); */
    transition: background 0.2s, box-shadow 0.2s;
    outline: none;
}
.ta-chatbot-welcome-new-btn:hover {
    background: #3b3663;
    color: #fff !important;
    /* box-shadow: 0 4px 16px rgba(181,23,158,0.12); */
}
.ta-chatbot-welcome-see-prev {
    margin-top: 2px;
    text-align: center;
}
.ta-chatbot-welcome-see-prev a {
    color: #000000 !important;
    font-size: 0.98rem;
    text-decoration: none !important;
    cursor: pointer;
    font-weight: 500 !important;
}
.ta-chatbot-welcome-see-prev a:hover {
    color: #3b3663 !important;
}

/* --------------- Responsive --------------- */

@media (max-width: 480px) {
    #ta-chatbot-welcome-popup {
        width: 100%;
        right: 0 !important;      
    }
    #ta-chatbot-popup {
        width: calc(100% - 50%);
        left: 22% !important;
    }
    
    .ta-chatbot-modal-content {
        width: 95%;
    }
    .ta-chatbot-modal {
        /* width: 100%; */
        left: 25% !important;
    }
}


@media (min-width: 480px) and (max-width: 700px) {
    .ta-chatbot-modal {
        /* width: 100%; */
        left: 26.5% !important;
    }
    #ta-chatbot-popup {
        width: calc(100% - 30%);
        left: 15% !important; 
    }
    #ta-chatbot-welcome-popup {
        width: 100%;
        right: 0 !important;      
    }
}



@media (min-width: 700px) and (max-width: 1000px) {
    .ta-chatbot-modal {
        /* width: 100%; */
        left: 26.5% !important;
    }
    #ta-chatbot-popup {
        width: calc(100% - 30%);
        left: 15% !important; 
    }
    #ta-chatbot-welcome-popup {
        width: 100%;
        right: 0 !important;      
    }
}



@media (min-width: 1000px) and (max-width: 1200px) {
    .ta-chatbot-modal {
        width: 100%;
        left: 31.5% !important;
    }
    #ta-chatbot-popup {
        width: calc(100% - 60%);
        left: 30% !important; 
    }
    #ta-chatbot-welcome-popup {
        width: 100%;
        right: 0 !important;      
    }
}


@media (min-width: 1200px) {
    .ta-chatbot-modal {
        /* width: 100%; */
        left: 38.5% !important;
    }
    #ta-chatbot-popup {
        width: calc(100% - 70%);
        left: 34% !important; 
    }
    #ta-chatbot-welcome-popup {
        width: 100%;
        right: 1% !important;      
    }
}