
#chat-toggle-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    animation: pulse 2s infinite;

    width: 40px;
    height: 40px;
    font-size: 18px;
    right: -7px;
    border-radius: 50% 0 0 50%;
    padding-top: 4px;
}

/* Pulsing Animation */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* Chat Container */
.chat-container {
    display: none;
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 350px;
    min-width: 200px;
    max-width: 800px;
    max-height: 500px;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    flex-direction: column;
    background-color: #fff;
    z-index: 999;
}

/* Slide In Animation */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Slide Out Animation */
@keyframes slideOutDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

/* Chat Header */
#chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 15px;
    text-align: center;
    position: relative;
    cursor: move; /* Indicate draggable area */
    user-select: none; /* Prevent text selection during drag */
}

#chat-header h2 {
    margin: 0;
    font-size: 18px;
}

/* Close Button */
#close-chat, #saved-messages-button, #new-chat, .chatgpt_dbchat {
    position: absolute;
    top: 10px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

#close-chat {
    right: 15px;
}
#new-chat {
    right: 35px;
}
.chatgpt_dbchat {
    right: 70px;
}
.chatgpt_dbchat img {
    height: 20px;
}

/* Saved Messages Button */
#saved-messages-button {
    left: 15px;
}

/* Resizer Handle */
#chat-resizer {
    position: absolute;
    left: 0;
    top: 0;
    width: 5px;
    height: 100%;
    cursor: ew-resize;
    z-index: 1000;
}

/* Chat Window */
#chat-window {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f0f2f5;
}

.chat-container .session_break {
    border-top: 1px dashed;
    margin: 30px 0;
    position: relative;
}
.chat-container .session_break span {
    display: inline-block;
    background: #f0f2f5;
    position: absolute;
    top: -11px;
    left: 50%;
    transform: translate(-50%, 0);
    padding: 1px 4px;
}

.chat-container .message {
    display: flex;
    margin-bottom: 10px;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
    position: relative;
}

.chat-container .message.user {
    justify-content: flex-end;
}

.chat-container .message.bot {
    justify-content: flex-start;
}

.chat-container .message .bubble {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 20px;
    position: relative;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
    display: inline-block;
    white-space: pre-wrap; /* Preserve line breaks */
}

.chat-container .message.user .bubble {
    background: #667eea;
    color: #fff;
    border-bottom-right-radius: 5px;
    padding-right: 35px; /* Increased right padding */
}

.chat-container .message.bot .bubble {
    background: #e5e7eb;
    color: #333;
    border-bottom-left-radius: 5px;
    padding-left: 35px; /* Increased left padding */
}

/* Heart Icon Inside Bubble */
.chat-container .bubble .heart-icon {
    position: absolute;
    top: 10px;
    font-size: 16px;
    opacity: 0.7;
    transition: opacity 0.2s;
    cursor: pointer;
}

.chat-container .message.user .bubble .heart-icon {
    right: 10px;
}

.chat-container .message.bot .bubble .heart-icon {
    left: 10px;
}

.chat-container .heart-icon.saved {
    color: red;
    opacity: 1;
}

.chat-container .heart-icon:hover {
    opacity: 1;
}

/* Timestamp Styles */
.chat-container .timestamp,
#saved-messages-modal .timestamp {
    display: block;
    font-size: 10px;
    color: #999;
    margin-top: 5px;
    text-align: right;
}

/* Adjust timestamp alignment for bot messages */
.chat-container .message.bot .timestamp,
#saved-messages-modal .message.bot .timestamp {
    text-align: left;
}

/* RTL Support */
.chat-container .rtl,
#saved-messages-modal .rtl {
    direction: rtl;
    text-align: right;
}

/* Message Fade In Animation */
@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.chat-container .input-area {
    display: flex;
    align-items: center;
    padding: 10px;
    border-top: 1px solid #ddd;
    background-color: #fff;
}

.chat-container #user-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 25px;
    font-size: 14px;
    outline: none;
    resize: none; /* Prevent resizing */
    overflow-y: auto;
    max-height: 100px; /* Limit the height */
}

.chat-container #emoji-button {
    background: transparent;
    border: none;
    font-size: 24px;
    margin-right: 5px;
    cursor: pointer;
}

.chat-container #send-button {
    background: #667eea;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    margin-left: 5px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-container #send-button:hover {
    background: #764ba2;
}

/* Send Button Icon */
.chat-container #send-icon {
    fill: #fff;
    width: 20px;
    height: 20px;
}

/* Emoji Picker */
.chat-container #emoji-picker {
    position: absolute;
    bottom: 60px;
    left: 10px;
    background: #fff;
    border: 1px solid #ccc;
    padding: 5px;
    border-radius: 10px;
    display: none;
    flex-wrap: wrap;
    max-width: 200px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1001;
}

.chat-container #emoji-picker span {
    font-size: 24px;
    padding: 5px;
    cursor: pointer;
}

.chat-container #emoji-picker span:hover {
    background-color: #f0f0f0;
    border-radius: 5px;
}

/* Typing Indicator */
.chat-container .typing-indicator {
    display: inline-block;
    width: 50px;
    height: 10px;
}

.chat-container .typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: #333;
    border-radius: 50%;
    opacity: 0.3;
    animation: typingIndicator 1s infinite;
}

.chat-container .typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.chat-container .typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-container .typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingIndicator {
    0%, 60%, 100% {
        opacity: 0.3;
    }
    30% {
        opacity: 1;
    }
}

/* Modal Styles */
#saved-messages-modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1002; /* Above other elements */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

#saved-messages-content {
    background-color: #fff;
    margin: 50px auto;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 80%;
    overflow: hidden;
}

/* Modal Header */
#saved-messages-modal #modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 15px;
    text-align: center;
    position: relative;
}

#saved-messages-modal #modal-header h2 {
    margin: 0;
    font-size: 18px;
}

#saved-messages-modal #close-saved-messages-modal {
    position: absolute;
    right: 15px;
    top: 15px;
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #fff;
}

/* Modal Body */
#saved-messages-modal #modal-body {
    padding: 15px;
    overflow-y: auto;
    background-color: #f0f2f5;
    flex: 1;
}

#saved-messages-modal .saved-message {
    background-color: #fff;
    padding: 10px 25px 10px 15px;
    border-radius: 15px;
    margin-bottom: 10px;
    position: relative;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    word-wrap: break-word;
    white-space: pre-wrap; /* Preserve line breaks */
}

#saved-messages-modal .saved-message .timestamp {
    font-size: 10px;
    color: #999;
    margin-top: 5px;
    text-align: right;
}

/* Delete Icon */
#saved-messages-modal .delete-icon {
    position: absolute;
    top: 10px;
    right: 2px;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.7;
}

#saved-messages-modal .delete-icon:hover {
    opacity: 1;
}

@media screen and (max-width: 600px) {
    #chat-toggle-button {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 24px;
    }

    .chat-container {
        bottom: 80px;
        right: 20px;
        width: 300px;
        max-height: 400px;
    }

    .chat-container #emoji-picker {
        bottom: 60px;
    }

    #saved-messages-modal #saved-messages-content {
        width: 95%;
        margin: 30px auto;
    }
}