#wpiko-chatbot-container {
    max-width: var(--chatbot-width);
    width: 100%;
    border-radius: 20px;
    margin: 0 auto;
    position: relative;
    padding-bottom: 8px;
    background: var(--chatbot-background-color);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
}

/* Chatbot Header */
#chatbot-header {
    position: relative;
    display: flex;
    align-items: center;
    padding: 18px;
    background: var(--chatbot-header-color);
    border-bottom: 1px solid var(--chatbot-border-color);
    border-radius: 20px 20px 0 0;
    z-index: 901;
}

#chatbot-header::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -12px;
    height: 12px;
    background: linear-gradient(to bottom, rgba(212,212,212,0.1), transparent);
    pointer-events: none;
}

#chatbot-image {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 10px;
}

#chatbot-info {
    display: flex;
    flex-direction: column;
}

#chatbot-name {
    font-size: 16px;
    font-weight: bold;
    color: var(--chatbot-name-color);
}

#chatbot-status {
    font-size: 14px;
}

#chatbot-status.online {
    color: #00A878;
}

#chatbot-status.offline {
    color: #FF3B3B;
}

/* Chatbot Menu */
#chatbot-menu {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 1001;
}

#chatbot-menu-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: var(--icon-color);
}

#chatbot-menu-dropdown {
    position: absolute;
    top: 100%; 
    right: 0;
    background: var(--chatbot-background-color);
    color: var(--bot-text-color);
    border: 1px solid var(--chatbot-border-color);
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    min-width: 150px; 
    font-size: 14px;
    z-index: 1000;
}

#chatbot-menu-dropdown ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

#chatbot-menu-dropdown li {
    padding: 10px 15px;
    cursor: pointer;
    white-space: nowrap; 
    border-bottom: 1px solid var(--chatbot-border-color);
}

#chatbot-menu-dropdown li:last-child {
    border-bottom: none; 
}

#chatbot-menu-dropdown li:hover {
    background-color: var(--bot-background-color);
}


/* Chatbot Message */
#chatbot-messages {
    height: var(--chatbot-height);
    overflow-y: auto;
    margin-bottom: 15px;
    padding: 15px;
    font-size: 14px;
    letter-spacing: 0.1px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
    border-bottom: 1px solid var(--chatbot-border-color);
    position: relative;
}

#chatbot-messages::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 12px;
    background: linear-gradient(to top, rgba(212,212,212,0.05), transparent);
    pointer-events: none;
}

#chatbot-messages .message-container {
    display: flex;
    flex-direction: column;
    padding-bottom: 8px;
}

#chatbot-messages .user-message {
    background: var(--user-background-color);
    color: var(--user-text-color);
    border: 1px var(--user-border-style) var(--user-text-color);
    text-align: left;
    align-self: flex-end;
    padding: 8px 12px;
    border-radius: 10px 10px 0 10px;
    white-space: pre-wrap;
    word-break: break-word;
    font-weight: 500;
    display: inline-block;
    max-width: 70%;
    margin-left: auto;
}

#chatbot-messages .bot-message {
    text-align: left;
    padding: 8px 12px;
    background: var(--bot-background-color);
    color: var(--bot-text-color);
    border-radius: 10px 10px 10px 0;
    display: inline-block;
    max-width: 100%;
}

.bot-message {
    position: relative;
}

.bot-message a {
    color: var(--bot-text-color);
    text-decoration: underline;
}

.bot-message a:hover {
    color: color-mix(in srgb, var(--bot-text-color) 85%, black);
}

/* Avatar Style */
.message-wrapper {
    display: flex;
    align-items: flex-end;
    margin-bottom: 10px;
}

.user-message-wrapper {
    justify-content: flex-end;
}

.message-avatar {
    width: 29px;
    height: 29px;
    border-radius: 50%;
    flex-shrink: 0;
}

.bot-message-wrapper .message-avatar {
    margin-right: 8px;
}

.user-message-wrapper .message-avatar {
    background: var(--user-background-color);
    margin-left: 7px;
    order: 1;
}

.user-avatar-svg {
    width: 100%;
    height: 100%;
    color: var(--user-text-color);
}

.message-avatar.user-avatar {
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px var(--user-border-style) var(--user-text-color);
    padding: 2px;
    max-height: 20px;
    max-width: 20px;
}

/* Markdown Styles */
.bot-message h1 {
    font-size: 22px;
    margin: 0px;
    font-weight: 600;
    color: var(--bot-text-color);
}

.bot-message h2 {
    font-size: 18px;
    margin: 0px;
    font-weight: 600;
    color: var(--bot-text-color);
}

.bot-message h3 {
    font-size: 16px;
    margin: 0px;
    font-weight: 600;
    color: var(--bot-text-color);
}

.bot-message strong {
    font-weight: 600;
    margin: 0px;
    color: var(--bot-text-color);
}

.bot-message em {
    font-style: italic;
    color: var(--bot-text-color);
}



/* Error Messages */
.error-message {
    padding: 10px;
    border-radius: 5px;
    margin: 10px 0;
    font-style: italic;
}

.error-message {
    background-color: #ffebee;
    color: #c62828;
}

.error-message.config_error {
    background-color: #fff3e0;
    color: #e65100;
}

/* Loading Dots */
.loading-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 0;
}

.loading-dots .dot {
    width: 8px;
    height: 8px;
    margin: 0 4px;
    border-radius: 50%;
    background-color: var(--bot-text-color);
    animation: dotPulse 1.4s infinite;
}

.loading-dots .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dots .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotPulse {
    0%, 100% {
        transform: scale(0.3);
    }
    50% {
        transform: scale(1);
    }
}

.message-container.loading {
    width: auto;
    max-width: 50%;
}

.message-container.loading .bot-message {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    min-width: 60px;
}

/* Pre-made Questions */
#pre-made-questions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 17px;
    padding: 8px;
    position: relative;
}

.pre-made-question {
    background: var(--user-background-color);
    color: var(--user-text-color);
    border: 1px var(--user-border-style) var(--user-text-color);
    margin: 5px;
    border-radius: 30px 30px 1px 30px;
    padding: 10px 16px !important;
    cursor: pointer;
    font-size: 14px;
    text-align: center;
    display: inline-block;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.pre-made-question::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        120deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transition: all 0.4s;
}

.pre-made-question:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    background: var(--user-background-color);
    border: 1px var(--user-border-style) var(--user-text-color);
}

.pre-made-question:hover::before {
    left: 100%;
}

/* Chatbot Input */
#input-container {
     padding: 0 8px 8px 8px;
     z-index: 902;
}

#chatbot-input-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--input-background-color);
    border-radius: 30px;
    padding: 10px;
}

#chatbot-input {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 30px;
    box-sizing: border-box;
    font-size: 14px;
    background: var(--input-background-color);
    outline: none;
    resize: none;
    height: 50px;
    overflow-y: auto;
    line-height: 1.5;
    letter-spacing: 1px;
}

#chatbot-send {
    background: var(--primary-color);
    color: var(--primary-text-color);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    padding: 0;
    flex-shrink: 0;
    transition: background-color 0.3s;
}

#chatbot-send:hover {
    background: color-mix(in srgb, var(--primary-color) 85%, black);
    transition: background-color 0.3s;
}

#chatbot-send svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Chatbot Scrollbar */
#chatbot-messages::-webkit-scrollbar {
    width: 8px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: white;
    border-radius: 10px;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: #f1f1f1;
    border-radius: 10px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #e1e1e1;
}

/* Floating Chatbot */
#wpiko-chatbot-floating-icon {
    position: fixed;
    bottom: 20px;
    right: var(--floating-position-right, 20px);
    left: var(--floating-position-left, auto);
    width: 60px;
    height: 60px;
    background-color: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 9998;
    transition: transform 0.3s ease;
}

#wpiko-chatbot-floating-icon::before,
#wpiko-chatbot-floating-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#wpiko-chatbot-floating-icon::before {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    background-color: var(--primary-text-color);
    mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z"/></svg>') no-repeat center;
    -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z"/></svg>') no-repeat center;
    background-size: contain;
    transform: translate(-50%, -50%);
}

#wpiko-chatbot-floating-icon::after {
    content: '';
    display: block;
    width: 24px;
    height: 24px;
    background-color: var(--primary-text-color);
    mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>') no-repeat center;
    -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>') no-repeat center;
    background-size: contain;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
}

#wpiko-chatbot-floating-icon.open::before {
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
}

#wpiko-chatbot-floating-icon.open::after {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

#wpiko-chatbot-floating-icon:hover {
    transform: scale(1.1);
}

#wpiko-chatbot-floating-wrapper {
    position: fixed;
    bottom: 30px;
    right: var(--floating-wrapper-right, 80px);
    left: var(--floating-wrapper-left, auto);
    display: flex;
    align-items: center;
    cursor: pointer;
    z-index: 9998;
    transition: all 0.3s ease;
}

#wpiko-chatbot-floating-text {
    background-color: var(--chatbot-background-color);
    color: var(--chatbot-name-color);
    padding: 8px 12px;
    border-radius: 20px;
    margin-right: var(--floating-wrapper-text-right, 10px);
    margin-left: var(--floating-wrapper-text-left, 10px);
    font-size: 14px;
    letter-spacing: 0.2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#wpiko-chatbot-floating-wrapper.open #wpiko-chatbot-floating-icon::before {
    opacity: 0;
    transform: scale(0);
}

#wpiko-chatbot-floating-wrapper.open #wpiko-chatbot-floating-icon::after {
    opacity: 1;
    transform: scale(1);
}

#wpiko-chatbot-floating-wrapper.open #wpiko-chatbot-floating-text {
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
}

#wpiko-chatbot-floating-wrapper:hover #wpiko-chatbot-floating-icon {
    transform: scale(1.1);
}

#wpiko-chatbot-floating-wrapper.open #wpiko-chatbot-floating-icon::after {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Floating Chatbot */
#wpiko-chatbot-floating-container {
    position: fixed;
    display: flex;
    bottom: 100px;
    right: var(--floating-container-right, 20px);
    left: var(--floating-container-left, auto);
    width: var(--chatbot-floating-width);
    height: var(--chatbot-floating-height);
    z-index: 9999;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    border-radius: 20px;
    overflow: hidden;
}

#wpiko-chatbot-floating-container #wpiko-chatbot-container {
    display: flex;
    width: 100%;
    flex-direction: column;
    height: 100%;
    max-width: 100%;
    border-radius: 0;
    margin: 0;
    padding: 0;
}

#wpiko-chatbot-floating-container #chatbot-messages {
    height: calc(100% - 170px);
}

#wpiko-chatbot-floating-container #input-container {
     padding: 0 10px 15px 10px;
}

#wpiko-chatbot-floating-container #pre-made-questions {
    margin-bottom: 16px;
}

/* Mobile close button */
#wpiko-chatbot-mobile-close {
    display: none;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    border: none;
    border-radius: 0 0 4px 4px;
    padding: 2px 20px;
    cursor: pointer;
    z-index: 9999;
    text-align: center;
    min-width: 60px;
    transition: all 0.3s ease;
}

#wpiko-chatbot-mobile-close::before {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    background-color: var(--primary-text-color);
    mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"/></svg>') no-repeat center;
    -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6-6 6z"/></svg>') no-repeat center;
    background-size: contain;
    vertical-align: middle;
    transform: rotate(180deg);
    transition: transform 0.3s ease;
}

/* Hover effects */
#wpiko-chatbot-mobile-close:hover {
    padding: 4px 25px;
}

#wpiko-chatbot-mobile-close:hover::before {
    transform: rotate(180deg) scale(1.1);
}

/* Active/Click effect */
#wpiko-chatbot-mobile-close:active {
    transform: translateX(-50%) scale(0.95);
}

/* Floating Chatbot - Responsive design for mobile devices */
@media screen and (max-width: 767px) {
    #wpiko-chatbot-floating-container {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
        z-index: 9997;
    }

    #wpiko-chatbot-floating-container #wpiko-chatbot-container {
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    /* Hide the floating icon only when chatbot is open */
    #wpiko-chatbot-floating-wrapper.open #wpiko-chatbot-floating-icon {
        display: none;
    }

    /* Show mobile close button when chatbot is open */
    #wpiko-chatbot-mobile-close {
        display: block;
    }

    /* Header for mobile */
    #chatbot-header {
        padding-top: 30px;
        border-radius: 0;
    }

    /* Floating icon position for mobile */
    #wpiko-chatbot-floating-icon {
        bottom: 15px;
        right: 15px;
        width: 50px;
        height: 50px;
    }

    /* Hide floating text on mobile */
    #wpiko-chatbot-floating-text {
        display: none;
    }

    /* Menu button adjustments */
    #chatbot-menu {
        top: 30px;
    }
    
    /* Remove padding-top from shortcode version */
    #wpiko-chatbot-container:not(#wpiko-chatbot-floating-container #wpiko-chatbot-container) #chatbot-header {
        padding-top: 18px;
    }
    
    /* isolate */
    #chatbot-input {
        font-size: 16px;
        -webkit-text-size-adjust: none;
        touch-action: manipulation;
    }
    
    #wpiko-chatbot-floating-container {
        isolation: isolate;
        touch-action: none;
    }
    
    #chatbot-messages {
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
    }
    
    body.chatbot-open,
    html.chatbot-open {
        overflow: hidden !important;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}
