/* --- STYLE.CSS (FINAL VERSION + TOGGLE) --- */

/* 1. RESET & BASIC LAYOUT */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: #e0e0e0;
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-color: #000;
}

/* BACKGROUND IMAGE */
body::before {
    content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background-image: url("image/background-05.jpg"); /* Pastikan path gambar benar */
    background-size: cover; background-position: center;
    filter: blur(10px); transform: scale(1.1); z-index: -2;
}

body::after {
    content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.6); z-index: -1; 
}

/* 2. KARTU UTAMA (LEBAR/WIDE) */
.card {
    width: 95vw; height: 92vh; max-width: 1800px;
    background-color: rgba(10, 10, 10, 0.85); border-radius: 16px; 
    border: 1px solid #333; display: flex; flex-direction: row; 
    overflow: hidden; box-shadow: 0 0 60px rgba(0, 0, 0, 0.6); 
    backdrop-filter: blur(10px); 
}

/* --- SIDEBAR STYLING --- */
.sidebar {
    width: 280px;
    background-color: rgba(0, 0, 0, 0.3);
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    
    /* ANIMASI TRANSISI */
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    overflow: hidden; 
    white-space: nowrap; 
}

/* CLASS SAAT SIDEBAR DITUTUP */
.sidebar.closed {
    width: 0;
    padding: 0;
    border-right: none;
    opacity: 0;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    color: #fff;
    border-bottom: 1px solid #222;
    min-height: 70px;
}

/* Tombol Icon (Toggle) */
.icon-btn {
    background: transparent; border: none; color: #888;
    cursor: pointer; padding: 5px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    transition: 0.2s;
}
.icon-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

.sidebar-title-text {
    flex: 1; text-align: center; font-size: 14px; letter-spacing: 1px;
}

.new-chat-btn {
    background: transparent; border: 1px solid #444; color: #fff;
    padding: 6px; border-radius: 6px; cursor: pointer; transition: 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.new-chat-btn:hover { background: #333; }

#historyList {
    flex: 1; overflow-y: auto; padding: 10px;
    display: flex; flex-direction: column; gap: 5px;
}

/* Sidebar Items */
.history-wrapper {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; border-radius: 8px; cursor: pointer; transition: all 0.2s;
}
.history-wrapper:hover { background-color: rgba(255, 255, 255, 0.05); }
.history-wrapper.active { background-color: rgba(255, 255, 255, 0.1); border-left: 3px solid #4caf50; }

.history-title {
    flex: 1; font-size: 14px; color: #aaa; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; background: transparent;
    border: none; text-align: left; cursor: pointer; margin-right: 5px;
}
.history-wrapper.active .history-title { color: #fff; font-weight: 500; }

.history-actions { display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.history-wrapper:hover .history-actions { opacity: 1; }

.action-btn {
    background: transparent; border: none; color: #666; cursor: pointer;
    padding: 4px; border-radius: 4px; display: flex; align-items: center; justify-content: center;
}
.action-btn:hover { background-color: rgba(255, 255, 255, 0.1); color: #fff; }
.delete-btn:hover { color: #ff5252; }

.sidebar-footer { padding: 15px; border-top: 1px solid #222; }
.clear-all-btn {
    width: 100%; background: transparent; border: 1px solid #722; color: #d88;
    padding: 10px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.clear-all-btn:hover { background: rgba(200,50,50,0.1); }

/* --- MAIN CHAT AREA --- */
.main-chat-area {
    flex: 1; display: flex; flex-direction: column; position: relative;
    transition: all 0.6s cubic-bezier(0.25, 0.8, 0.25, 1); 
}

/* Initial View */
.main-chat-area.initial-view { justify-content: center; align-items: center; }
.main-chat-area.initial-view .header, .main-chat-area.initial-view #chatHistory { display: none; }
.main-chat-area.initial-view .input-area {
    width: 700px; max-width: 90%; border-top: none; background: transparent;
    display: flex; flex-direction: column; align-items: center; gap: 30px; 
}
.main-chat-area.initial-view input {
    width: 100%; padding: 22px 30px; font-size: 20px; border-radius: 50px; text-align: center;
    background-color: rgba(0, 0, 0, 0.6); border: 2px solid rgba(255, 255, 255, 0.1); 
    box-shadow: 0 10px 40px rgba(0,0,0,0.4); color: #ffffff; backdrop-filter: blur(5px); transition: all 0.3s;
}
.main-chat-area.initial-view input:hover, .main-chat-area.initial-view input:focus {
    background-color: rgba(0, 0, 0, 0.8); border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 15px 50px rgba(0,0,0,0.6);
}
.main-chat-area.initial-view button { display: none; }

#welcomeText {
    font-size: 72px; font-weight: 700; color: #ffffff; margin-bottom: 20px; 
    text-align: center; letter-spacing: 1px; text-shadow: 0 4px 20px rgba(0,0,0,0.8); 
}

/* Active Header */
.header {
    padding: 15px 25px; background-color: rgba(10, 10, 10, 0.6);
    border-bottom: 1px solid #222; font-size: 16px; font-weight: 600;
    color: #888; display: flex; align-items: center; justify-content: space-between; 
}
.header-left { display: flex; align-items: center; gap: 15px; }
.status-dot {
    width: 8px; height: 8px; background-color: #4caf50; 
    border-radius: 50%; box-shadow: 0 0 10px rgba(76, 175, 80, 0.4);
}

/* Chat Area */
#chatHistory {
    flex: 1; padding: 40px; overflow-y: auto; background-color: transparent; 
    display: flex; flex-direction: column; gap: 20px; width: 100%;
}
#chatHistory::-webkit-scrollbar { width: 8px; }
#chatHistory::-webkit-scrollbar-track { background: rgba(10, 10, 10, 0.3); }
#chatHistory::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }

/* Bubbles */
.bubble {
    padding: 12px 18px; border-radius: 12px; max-width: 70%; font-size: 16px; 
    line-height: 1.6; word-wrap: break-word; animation: slideUp 0.4s ease;
}
.bot {
    background-color: transparent; color: #e0e0e0; align-self: flex-start;
    font-family: 'Consolas', monospace; text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
.user {
    background-color: rgba(40, 40, 40, 0.9); color: #ffffff; align-self: flex-end;
    border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

/* Active Input */
.main-chat-area.active-view .input-area {
    width: 100%; padding: 25px; background-color: rgba(10, 10, 10, 0.95);
    border-top: 1px solid #222; display: flex; align-items: center; gap: 15px;
}
.main-chat-area.active-view input {
    flex: 1; padding: 15px 20px; border-radius: 12px; border: 1px solid #333;
    background-color: rgba(30, 30, 30, 0.6); color: #ffffff; font-size: 16px;
    text-align: left; outline: none; transition: all 0.3s;
}
.main-chat-area.active-view input:focus { border-color: #666; background-color: rgba(40, 40, 40, 0.8); }

.input-area button {
    width: 50px; height: 50px; border-radius: 12px; border: 1px solid #333;
    background-color: rgba(30, 30, 30, 0.8); color: #aaa; font-size: 20px;
    cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center;
}
.input-area button:hover { background-color: #444; color: white; }

@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

/* --- CUSTOM MODAL STYLES --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.75); 
    backdrop-filter: blur(5px); display: flex; justify-content: center; align-items: center; z-index: 9999;
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }

.modal-box {
    background-color: #1a1a1a; width: 380px; max-width: 90%; padding: 25px;
    border-radius: 16px; border: 1px solid #333; box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    text-align: center; transform: scale(0.9); transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.modal-overlay.show .modal-box { transform: scale(1); }

.modal-box h3 { color: #fff; margin-bottom: 15px; font-size: 20px; }
.modal-box p { color: #aaa; margin-bottom: 25px; font-size: 14px; line-height: 1.5; }

#renameInput {
    width: 100%; padding: 12px 15px; background-color: #2a2a2a; border: 1px solid #444;
    border-radius: 8px; color: white; font-size: 16px; margin-bottom: 25px; outline: none; text-align: center;
}
#renameInput:focus { border-color: #4caf50; background-color: #333; }

.modal-buttons { display: flex; gap: 10px; justify-content: center; }
.modal-buttons button { flex: 1; padding: 12px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; transition: all 0.2s; }
.btn-cancel { background-color: transparent; border: 1px solid #444 !important; color: #aaa; }
.btn-cancel:hover { background-color: #333; color: #fff; }
.btn-save { background-color: #4caf50; color: #fff; }
.btn-save:hover { background-color: #43a047; }
.btn-delete-confirm { background-color: #d32f2f; color: white; }
.btn-delete-confirm:hover { background-color: #b71c1c; }

/* =======================================================
   RESPONSIVE MOBILE (Layar HP) - VERSI RAPI & KECIL
   Paste kode ini di baris paling bawah style.css
   ======================================================= */
@media screen and (max-width: 768px) {

    /* 1. Atur Wadah Utama Full Layar */
    .card {
        flex-direction: column;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        margin: 0;
        overflow: hidden; 
    }

    /* 2. Sidebar (Menu) Ramping */
    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        width: 70%;
        max-width: 260px; /* Sedikit diperkecil lagi biar pas */
        height: 100%;
        z-index: 1000;
        background-color: #000; /* Atau sesuaikan warna tema */
        box-shadow: 4px 0 15px rgba(0,0,0,0.5);
        border-right: 1px solid #333;
    }

    /* 3. Area Chat Utama */
    .main-chat-area {
        width: 100%;
        height: 100%;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }

    /* --- PERBAIKAN DI SINI (TEKS & KERAPIAN) --- */

    /* Header: Atur jarak pinggir biar simetris */
    .header {
        padding: 10px 20px; /* Jarak atas-bawah 10px, kiri-kanan 20px */
    }

    /* Munculkan Tombol Menu */
    #openSidebarBtn {
        display: flex !important;
        margin-right: 15px;
    }

    /* Area Pesan (Isi Chat): Beri jarak pinggir yang enak dilihat */
    #chatHistory {
        padding: 0 20px; /* Kiri-Kanan 20px (Sama dengan header biar lurus) */
        width: 100%;
        box-sizing: border-box; /* Mencegah scroll samping */
    }

    /* Perkecil Ukuran Huruf Chat */
    #chatHistory div, 
    #chatHistory p, 
    .message-content { 
        font-size: 14px !important; /* Huruf lebih kecil (Standar HP) */
        line-height: 1.5;           /* Jarak antar baris biar gak dempet */
    }

    /* Area Input Bawah */
    .input-area {
        padding: 15px 20px; /* Samakan padding kiri-kanan */
    }

    /* Perkecil Teks Input */
    input[type="text"] {
        font-size: 14px;
    }
}