<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>KURT AI</title>

<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;600;800&display=swap" rel="stylesheet">

<style>
body {
    margin: 0;
    font-family: 'Orbitron', sans-serif;
    background: black;
    color: white;
    overflow: hidden;
}

/* 🔥 ARKA PLAN */
body::before {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    background: url("bg.png") no-repeat center top;
    background-size: contain;
    opacity: 0.25;
    filter: brightness(1.2) contrast(1.3);
    pointer-events: none; /* 💥 FIX */
}

body::after {
    content: "";
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(0,255,255,0.08), transparent);
    pointer-events: none; /* 💥 FIX */
}

/* CHAT */
.chat-container {
    position: relative;
    z-index: 10; /* 💥 FIX */
    width: 95%;
    max-width: 1100px;
    margin: auto;
    top: 80px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    background: rgba(10,10,20,0.7);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    box-shadow: 0 0 50px rgba(0,255,255,0.2);
}

/* HEADER */
.header {
    text-align: center;
    padding: 20px;
    font-size: 28px;
    color: #00f7ff;
    text-shadow: 0 0 20px #00f7ff;
}

.powered {
    font-size: 12px;
    text-align: center;
    color: #aaa;
}

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

/* MESAJ */
.msg {
    margin: 10px 0;
    padding: 12px 15px;
    border-radius: 12px;
    max-width: 75%;
    animation: fade 0.2s ease;
}

.user {
    background: linear-gradient(90deg, #00f7ff, #0055ff);
    margin-left: auto;
}

.ai {
    background: linear-gradient(90deg, #ff00cc, #6600ff);
}

/* INPUT */
.input-area {
    display: flex;
    padding: 15px;
}

.input-area input {
    flex: 1;
    padding: 14px;
    border-radius: 10px;
    border: none;
    background: rgba(255,255,255,0.05);
    color: white;
    outline: none;
}

button {
    margin-left: 10px;
    padding: 12px 16px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: bold;
}

.send {
    background: linear-gradient(90deg, #00f7ff, #ff00cc);
}

.net {
    background: #ff00cc;
}

/* ANIM */
@keyframes fade {
    from {opacity:0; transform:translateY(10px);}
    to {opacity:1;}
}
</style>
</head>

<body>

<div class="chat-container">

    <div class="header">KURT AI</div>
    <div class="powered">⚡ Powered by Özcan Gönülal</div>

    <div id="chat"></div>

    <div class="input-area">
        <input id="input" placeholder="Sorunu yaz...">
        <button class="send" onclick="send()">➤</button>
        <button class="net" onclick="toggleNet()">🌐</button>
    </div>

</div>

<script>
let net = false;

function toggleNet(){
    net = !net;
    alert(net ? "🌐 İnternet Açık" : "⚡ Local AI");
}

/* CACHE */
let cache = {};

async function send(){

    let input = document.getElementById("input");
    let chat = document.getElementById("chat");

    let text = input.value.trim();
    if(!text) return;

    chat.innerHTML += `<div class="msg user">${text}</div>`;
    input.value = "";

    let id = "m"+Date.now();
    chat.innerHTML += `<div class="msg ai" id="${id}">⚡ düşünüyor...</div>`;

    if(cache[text]){
        document.getElementById(id).innerHTML = cache[text];
        return;
    }

    try{

        let url = "/kurt/api.php?q=" + encodeURIComponent(text);
        if(net) url += "&mode=net";

        let res = await fetch(url);
        let data = await res.text();

        cache[text] = data;

        document.getElementById(id).innerHTML = data;

    }catch(e){
        document.getElementById(id).innerHTML = "❌ AI veya bağlantı hatası";
    }

    chat.scrollTop = chat.scrollHeight;
}
</script>

</body>
</html>