<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nixcooll AI Chat</title>

<style>
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
        font-family: 'Inter', sans-serif;
        transition: 0.25s ease;
    }

    body {
        background: #ececec;
        display: flex;
        justify-content: center;
        padding: 20px;
    }

    .dark body {
        background: #1c1c1c;
    }

    .app-container {
        width: 100%;
        max-width: 780px;
        background: #fff;
        border-radius: 18px;
        height: 92vh;
        display: flex;
        flex-direction: column;
        box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        overflow: hidden;
    }

    .dark .app-container {
        background: #222;
        box-shadow: 0 10px 40px rgba(0,0,0,0.4);
    }

    /* HEADER */
    .header {
        padding: 20px;
        background: #ffffff;
        border-bottom: 1px solid #ddd;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .dark .header {
        background: #2b2b2b;
        border-color: #444;
    }

    .title {
        font-size: 26px;
        font-weight: 700;
        color: #000;
    }

    .dark .title {
        color: #fff;
    }

    .owner {
        margin-top: 4px;
        font-size: 14px;
        opacity: 0.7;
        color: #111;
    }

    .dark .owner {
        color: #ddd;
    }

    /* TOGGLE BUTTON */
    .toggle-btn {
        cursor: pointer;
        background: #e2e2e2;
        padding: 10px 16px;
        border-radius: 12px;
        font-size: 14px;
        font-weight: 600;
        color: #333;
    }

    .dark .toggle-btn {
        background: #444;
        color: #fff;
    }

    /* CHAT AREA */
    .chat-area {
        flex: 1;
        padding: 20px;
        overflow-y: auto;
        background: #f7f7f7;
    }

    .dark .chat-area {
        background: #1f1f1f;
    }

    /* Bubbles */
    .message {
        max-width: 80%;
        padding: 12px 16px;
        border-radius: 16px;
        margin: 12px 0;
        font-size: 15px;
        line-height: 1.4;
        animation: fadeIn .2s ease-in-out;
    }

    .user {
        background: #0d6efd;
        color: white;
        margin-left: auto;
        border-bottom-right-radius: 4px;
    }

    .ai {
        background: #e8e8e8;
        color: #111;
        margin-right: auto;
        border-bottom-left-radius: 4px;
    }

    .dark .ai {
        background: #333;
        color: #fff;
    }

    /* TYPING */
    .typing-indicator {
        display: none;
        background: #ddd;
        padding: 10px 14px;
        border-radius: 12px;
        width: fit-content;
        margin: 10px 0;
    }

    .dark .typing-indicator {
        background: #444;
        color: #fff;
    }

    /* INPUT AREA */
    .input-area {
        padding: 15px;
        display: flex;
        gap: 10px;
        background: #fff;
        border-top: 1px solid #ddd;
    }

    .dark .input-area {
        background: #2c2c2c;
        border-color: #444;
    }

    .input-area input {
        flex: 1;
        padding: 14px;
        border-radius: 12px;
        border: 1px solid #bbb;
        font-size: 16px;
        background: #fff;
        color: #111;
    }

    .dark .input-area input {
        background: #3a3a3a;
        border-color: #555;
        color: #fff;
    }

    .input-area button {
        background: #0d6efd;
        border: none;
        padding: 14px 18px;
        border-radius: 12px;
        color: white;
        cursor: pointer;
        font-size: 18px;
    }

    @keyframes fadeIn {
        from {opacity: 0; transform: translateY(5px);}
        to {opacity: 1; transform: translateY(0);}
    }
</style>

</head>
<body>

<div class="app-container">

    <!-- HEADER -->
    <div class="header">
        <div>
            <div class="title">Nixcooll AI</div>
            <div class="owner">☾ Owner: Nixcooll</div>
        </div>

        <div id="themeToggle" class="toggle-btn">🌙 Dark</div>
    </div>

    <!-- CHAT -->
    <div id="chatArea" class="chat-area"></div>
    <div id="typing" class="typing-indicator">Nixx sedang mengetik...</div>

    <!-- INPUT -->
    <div class="input-area">
        <input type="text" id="userInput" placeholder="Ketik pesan...">
        <button onclick="sendMessage()">➤</button>
    </div>

</div>

<script>
    const chatArea = document.getElementById("chatArea");
    const userInput = document.getElementById("userInput");
    const typing = document.getElementById("typing");
    const toggleBtn = document.getElementById("themeToggle");

    let darkMode = false;

    // Toggle Dark / Light
    toggleBtn.onclick = () => {
        darkMode = !darkMode;
        document.documentElement.classList.toggle("dark");

        toggleBtn.textContent = darkMode ? "☀ Light" : "🌙 Dark";
    };

    // Auto scroll
    function scrollToBottom() {
        chatArea.scrollTop = chatArea.scrollHeight;
    }

    function addMessage(text, sender) {
        const div = document.createElement("div");
        div.className = "message " + sender;
        div.textContent = text;
        chatArea.appendChild(div);
        scrollToBottom();
    }

    async function sendMessage() {
        let message = userInput.value.trim();
        if (!message) return;

        // User bubble
        addMessage(message, "user");
        userInput.value = "";

        // Show typing
        typing.style.display = "block";
        scrollToBottom();

        setTimeout(() => {
            typing.style.display = "none";
            addMessage("Ini jawaban dari Nixx AI 🤖✨\nKamu barusan kirim: " + message, "ai");
        }, 800);
    }
</script>

</body>
</html>