.livechat-widget {
    position: fixed;
    bottom: 150px;
    right: 20px;
    z-index: 1000;
    font-family: "Sarabun", sans-serif;
}

body.backend .livechat-widget {
    position: fixed;
    bottom: 50px;
    right: 20px;
    z-index: 1000;
    font-family: "Sarabun", sans-serif;
}

.chat-bubble {
    position: absolute;
    bottom: 90px;
    right: 0;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    width: 380px;
    margin-bottom: 10px;
    opacity: 1;
    transform: translateY(0);
    transition: all 0.3s ease;
    pointer-events: all;
}

.chat-bubble .close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #f0f0f0;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    color: #666;
    transition: all 0.2s ease;
}

.chat-bubble .close-btn:hover {
    background: #e0e0e0;
}

.chat-message {
    color: #4c4e64;
    font-size: 18px;
    line-height: 1.6;
    margin-right: 25px;
}

.chat-message p {
    margin: 0 0 8px 0;
    word-wrap: break-word;
}

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

.robot-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(252, 128, 4, 0.3);
    transition: all 0.3s ease;
    overflow: hidden;
}

.robot-icon:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(252, 128, 4, 0.4);
}

/* Chat Modal Styles */
.chat-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chat-modal-overlay.show {
    display: block;
    opacity: 1;
}

.chat-modal {
    position: fixed;
    top: 0;
    right: 0;
    width: 40%;
    height: 100%;
    background: white;
    z-index: 2001;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.1);
}

.chat-modal.show {
    transform: translateX(0);
}

@media (max-width: 768px) {
    .chat-modal {
        width: 100%;
    }
}

.chat-header {
    background: white;
    color: #333;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.chat-bot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.chat-bot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.online-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: #22c55e;
    border-radius: 50%;
    border: 2px solid white;
}

.chat-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.chat-header .close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    color: #999;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    line-height: 1;
    transition: color 0.2s;
}

.chat-header .close-btn:hover {
    color: #666;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fafafa;
}

/* Initial message styling */
.chat-initial-message {
    text-align: center;
    padding: 20px;
    margin-bottom: 20px;
}

.chat-initial-message p {
    margin: 0;
    color: #666;
    font-size: 18px;
    line-height: 1.5;
}

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

.message.user {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

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

.message.ai .message-avatar {
    overflow: hidden;
}

.message.ai .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message.user .message-avatar {
    background: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.message-content-wrapper {
    max-width: 75%;
}

.message-content {
    padding: 12px 18px;
    border-radius: 16px;
    font-size: 18px;
    line-height: 1.6;
    word-wrap: break-word;
}

.message.ai .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message.user .message-content {
    background: #fc8004;
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 14px;
    color: #999;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

.message-time .checkmark {
    color: #22c55e;
}

.chat-input {
    padding: 16px;
    padding-bottom: 24px;
    border-top: 1px solid #f0f0f0;
    background: white;
    margin-bottom: 20px;
}

.chat-input-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    padding: 12px 20px;
    font-size: 16px;
    outline: none;
    background: #f8f8f8;
    transition: all 0.2s;
}

.chat-input input:focus {
    border-color: #fc8004;
    background: white;
}

.chat-send-btn {
    background: #fc8004;
    color: white;
    border: none;
    border-radius: 24px;
    padding: 12px 28px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.chat-send-btn:hover {
    background: #e67300;
    transform: translateY(-1px);
}

.chat-send-btn:active {
    transform: translateY(0);
}

.example-questions {
    margin-top: 20px;
    text-align: left;
}

.example-questions h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.example-questions ul {
    list-style: none;
    padding: 0;
}

.example-questions li {
    background: white;
    margin: 5px 0;
    padding: 10px 15px;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border: 1px solid #e0e0e0;
}

.example-questions li:hover {
    background: #f0f0f0;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: #555;
    border-radius: 50%;
    display: inline-block;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: 0s;
}
.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}
