/* Pengaturan Dasar */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #d1d7db;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh; /* Fallback untuk browser lawas */
    height: 100dvh; /* KUNCI 1: Dynamic Viewport agar tidak tertutup header pencarian HP */
    margin: 0;
    overflow: hidden; /* Mencegah layar laptop ikut ter-scroll saat chat penuh */
}

/* Kotak Utama / Frame (Responsif Default untuk HP) */
.container {
    width: 100%;
    height: 100vh; /* Fallback */
    height: 100dvh; /* KUNCI 2: Mengikuti tinggi dinamis layar HP murni */
    background-color: #fff;
    display: flex;
    flex-direction: column;
    border-radius: 0;
    box-shadow: none;
}

/* ================= HALAMAN LOGIN ================= */
#login-page {
    padding: 30px 25px;
    background-color: #f5f5f5;
    overflow-y: auto;
}

.login-header {
    text-align: center;
    margin-bottom: 25px;
    color: #075e54;
}

.login-header h2 { font-size: 22px; margin-bottom: 5px; }
.login-header p { font-size: 14px; color: #555; }

.form-group {
    max-width: 400px; /* Menjaga agar form input tidak melar di layar laptop */
    margin: 0 auto;   /* Menengahkan area input */
}

.form-group input, .form-group select {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: 0.3s;
}

.form-group input:focus, .form-group select:focus {
    border-color: #128C7E;
}

.form-group button {
    width: 100%;
    padding: 14px;
    background-color: #128C7E;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}

.form-group button:hover {
    background-color: #075e54;
}

.btn-secondary {
    background-color: #6c757d !important;
}

.btn-secondary:hover {
    background-color: #5a6268 !important;
}

.text-center { 
    text-align: center; 
    margin-bottom: 15px; 
    font-size: 14px; 
    color: #666; 
}


/* ================= HALAMAN CHAT (WA STYLE) ================= */
.chat-header {
    background-color: #075e54;
    color: white;
    /* KUNCI 3: Area aman agar header tidak tertimpa poni/notch kamera HP */
    padding: max(12px, env(safe-area-inset-top)) 15px 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    z-index: 2;
}

.chat-header .avatar {
    font-size: 22px;
    background: #e5ddd5;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 15px;
}

.chat-title h3 { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.chat-title span { font-size: 12px; color: #dcf8c6; }

.header-icons {
    display: flex;
    gap: 18px;
    align-items: center;
}

.header-icons a {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: opacity 0.2s;
}

.header-icons a:hover {
    opacity: 0.7;
}

/* Area Obrolan */
.chat-body {
    flex: 1;
    background-color: #e5ddd5;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    padding: 20px 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Desain Bubble Chat */
.message {
    display: flex;
    width: 100%;
}

.message.left { justify-content: flex-start; }
.message.right { justify-content: flex-end; }

.bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    position: relative;
    word-wrap: break-word;
}

/* Bubble Soal (Kiri - Putih) */
.message.left .bubble {
    background-color: #ffffff;
    border-top-left-radius: 0;
}

/* Bubble Jawaban (Kanan - Hijau Terang) */
.message.right .bubble {
    background-color: #dcf8c6;
    border-top-right-radius: 0;
}

/* Area Input Bawah */
.chat-footer {
    background-color: #f0f0f0;
    /* KUNCI 4: Menjaga area bawah agar tidak tertutup garis gesture navigasi iPhone/Android */
    padding: 10px 15px max(10px, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-footer textarea {
    flex: 1;
    padding: 12px 15px;
    border: none;
    border-radius: 24px;
    resize: none;
    outline: none;
    font-size: 14px;
    line-height: 1.5; /* Jarak antar baris */
    min-height: 45px; /* Tinggi standar untuk 1 baris */
    max-height: 170px; /* Batas maksimal sekitar 8 baris */
    overflow-y: auto; /* Munculkan scrollbar jika teks melebihi max-height */
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    font-family: inherit;
}

.chat-footer button {
    background-color: #128C7E;
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transition: 0.2s;
}

.chat-footer button:hover {
    background-color: #075e54;
}

/* ========================================================= */
/* PENGATURAN KHUSUS LAYAR BESAR (LAPTOP/KOMPUTER)           */
/* ========================================================= */
@media (min-width: 768px) {
    body {
        /* Aksen hijau di atas latar belakang seperti WhatsApp Web asli */
        background: linear-gradient(to bottom, #00a884 0%, #00a884 130px, #d1d7db 130px, #d1d7db 100%);
    }

    .container {
        width: 90%; 
        max-width: 1200px; 
        height: 90vh; /* Di laptop tetap menggunakan 90vh agar proporsional melayang di tengah */
        border-radius: 12px; 
        box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    }

    .bubble {
        max-width: 65%; /* Bubble chat dibatasi agar tidak terlalu panjang merentang di laptop */
    }
    
    .chat-footer textarea {
        font-size: 16px; 
    }
}

/* ========================================================= */
/* PENGATURAN KHUSUS LAYAR KECIL (HANDPHONE)                 */
/* ========================================================= */
@media (max-width: 767px) {
    .bubble {
        max-width: 85%; /* Di HP, bubble diberikan ruang maksimal */
    }
}