/* Import Google font - Poppins */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Poppins", sans-serif;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #d4a5a5, #a5c8d4);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #333;
}

/* Gaya Modal Riwayat */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    width: 80%;
    max-width: 400px;
    position: relative;
}

.close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 18px;
    cursor: pointer;
    color: #724ae8;
}

#historyList {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

#historyList li {
    background: #f9f9f9;
    margin-bottom: 5px;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid #ddd;
}


.chatbot-toggler {
    position: fixed;
    right: 40px;
    bottom: 35px;
    height: 50px;
    width: 50px;
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    cursor: pointer;
    background: #724ae8;
    border-radius: 50%;
    transition: all 0.2s ease;
}
.show-chatbot .chatbot-toggler{
    transform: rotate(90deg);
}
.chatbot-toggler span {
    position: absolute;
}

.show-chatbot .chatbot-toggler span:first-child,
.chatbot-toggler span:last-child {
    opacity: 0;
}

.show-chatbot .chatbot-toggler span:last-child {
    opacity: 1;
}

header button#view-history {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgb(0, 0, 0);
    font-size: 1.2rem;
    cursor: pointer;
}


.chatbot {
    display: flex;
    justify-content: center; 
    align-items: center; 
    flex-direction: row;
    right: 300px;
    bottom: 100px;
    width: 930px;
    transform: scale(0.5);
    opacity: 0;
    pointer-events: none; 
    overflow: block;
    background: rgb(255, 255, 255);
    border-radius: 15px;
    transform-origin: bottom right;
    box-shadow: 0 0 128px 0 rgba(0, 0, 0, 0.1),
                0 32px 64px -48px rgba(0, 0, 0, 0.5);
    transition: all 0.2s ease;
}

.show-chatbot .chatbot {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto; 
    display: block;
}

.chatbot header {
    background: #ffffff;
    padding: 16px 0;
    text-align: center;
    position: relative;
}

.chatbot header h2 {
    background: #ffffff;
    font-size: 1.4rem;
}

.chatbot header span {
    position: absolute;
    right: 20px;
    top: 50%;
    color: #fff;
    cursor: pointer;
    display: none;
    transform: translateY(-50%);
}

.chatbot .chatbox {
    height: 510px;
    overflow-y: auto;
    padding: 30px 20px 100px; 
}

.chatbox .chat {
    display: flex;
}

.chatbox .incoming span {
    height: 32px;
    width: 32px;
    color: rgb(0, 0, 0);
    align-self: flex-end;
    background: #ffffff;
    text-align: center;
    line-height: 32px;
    border-radius: 4px;
    margin: 0 10px 7px 0;
}
.chatbox .chat p.error {
    color: #721c24;
    background: #f8d7da;
}
.chatbox .outgoing {
    margin: 20px 0;
    justify-content: flex-end;
}

.chatbox .chat p {
    color: #fff;
    max-width: 75%;
    white-space: pre-wrap;
    font-size: 0.95rem;
    padding: 12px 16px;
    border-radius: 10px 10px 0 10px;
    background: #724ae8;
}

.chatbox .incoming p {
    color: #000;
    background: #f2f2f2;
    border-radius: 10px 10px 10px 0;
}

.chatbot .chat-input {
    position: absolute;
    bottom: 0;
    width: 100%;
    display: flex;
    gap: 5px;
    background: #fff;
    padding: 5px 20px;
    border-top: 1px solid #ccc;
}

.chat-input textarea {
    height: 55px;
    width: 100%;
    border: none;
    outline: none;
    font-size: 0.95rem;
    resize: none;
    padding: 16px 15px 16px 0;
}

.chat-history-sidebar {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100%;
    background: #fff;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.chat-history-sidebar.show-history {
    right: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #724ae8;
    color: #fff;
}

.history-header h3 {
    margin: 0;
}

.history-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
}

.history-item {
    background: #f4f4f4;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:hover {
    background: #e4e4e4;
}

.history-timestamp {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 5px;
}

.history-actions {
    padding: 15px;
    border-top: 1px solid #ddd;
}

#clear-history {
    width: 100%;
    padding: 10px;
    background: #724ae8;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

#view-history {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

#close-history {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
}

/* Fix visibility and interaction for the send button */
.chat-input span {
    align-self: flex-end;
    height: 55px;
    line-height: 55px;
    color: #724ae8;
    font-size: 1.35rem;
    cursor: pointer;
    visibility: hidden; /* Hidden by default */
}

/* Make the send button visible when there is text input */
.chat-input textarea:valid ~ span {
    visibility: visible;
}

@media(max-width: 490px) {
    .chatbot {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
    .chatbot .chatbox {
        height: 90%;
    }
    .chatbot header span {
        display: block;
    }
}
