/* Custom styles for WhatsApp-like UI and general website elements */
body {
    font-family: 'Inter', sans-serif;
    background-color: #f0f2f5; /* Warna latar belakang abu-abu terang default untuk halaman umum */
    margin: 0;
    overflow-x: hidden; /* Mencegah scroll horizontal */
}

/* Gaya dasar untuk tombol */
.btn-primary {
    background-color: #8B5CF6; /* Ungu-600 */
    color: white;
    padding: 12px 24px;
    border-radius: 9999px; /* Sangat bulat */
    font-weight: 600;
    transition: background-color 0.3s ease;
    text-decoration: none;
    display: inline-block; /* Agar padding dan margin berfungsi dengan baik */
}

.btn-primary:hover {
    background-color: #7C3AED; /* Ungu-700 */
}

.btn-secondary {
    background-color: transparent;
    color: #8B5CF6; /* Ungu-600 */
    border: 2px solid #8B5CF6;
    padding: 10px 22px;
    border-radius: 9999px; /* Sangat bulat */
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block; /* Agar padding dan margin berfungsi dengan baik */
}

.btn-secondary:hover {
    background-color: #8B5CF6;
    color: white;
}

/* Tautan navigasi */
.nav-link {
    color: #4B5563; /* Abu-abu-600 */
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 0.375rem; /* Sudut membulat */
    transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-link:hover {
    color: #8B5CF6; /* Ungu-600 */
    background-color: #F3F4F6; /* Abu-abu-100 */
}

/* Gradien Bagian Hero */
.hero-gradient {
    background: linear-gradient(to right, #8B5CF6, #6D28D9); /* Ungu-600 ke Ungu-800 */
}

/* Kartu Fitur (juga digunakan untuk kartu bot di dashboard admin) */
.feature-card {
    background-color: white;
    padding: 2rem;
    border-radius: 0.75rem; /* Rounded-xl */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.15), 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Gaya spesifik untuk wadah chat WhatsApp */
.whatsapp-container {
    width: 95vw; /* Lebar hampir penuh viewport untuk desktop */
    max-width: 1400px; /* Lebar maksimum untuk layar yang lebih besar */
    height: 95vh; /* Tinggi hampir penuh viewport */
    display: flex;
    background-color: #f0f2f5; /* Latar belakang untuk celah antara sidebar dan area chat */
    border-radius: 8px;
    box-shadow: 0 1px 1px 0 rgba(0,0,0,.06), 0 2px 5px 0 rgba(0,0,0,.2);
    overflow: hidden; /* Memastikan konten tetap dalam sudut membulat */
    /* Pemusatan untuk wadah whatsapp, spesifik untuk penggunaannya */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Sidebar Kiri */
.sidebar {
    width: 35%; /* Sesuaikan lebar sidebar */
    min-width: 280px; /* Lebar minimum untuk sidebar */
    max-width: 450px; /* Lebar maksimum untuk sidebar */
    background-color: #ffffff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    background-color: #ededed; /* Header abu-abu terang */
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Perbaikan untuk memastikan bulatan dan dimensi yang konsisten pada wadah avatar */
.user-avatar,
.chat-avatar {
    width: 40px;
    min-width: 40px; /* Memastikan tidak menyusut pada tata letak flex */
    height: 40px;
    border-radius: 50%; /* Terapkan bulatan pada wadah */
    overflow: hidden; /* Klip konten di luar lingkaran */
    display: flex; /* Untuk pemusatan konten di dalamnya */
    align-items: center; /* Untuk pemusatan vertikal */
    justify-content: center; /* Untuk pemusatan horizontal */
    flex-shrink: 0; /* Mencegah wadah menyusut */
}

/* Gaya untuk gambar di dalam wadah avatar */
.user-avatar img,
.chat-avatar img {
    width: 100%; /* Isi wadah induk */
    height: 100%; /* Isi wadah induk */
    object-fit: cover; /* Pertahankan rasio aspek dan tutupi wadah */
    border-radius: 50%; /* Tetap terapkan untuk keamanan, meskipun wadah sudah bulat */
}

.sidebar-icons {
    display: flex;
    align-items: center;
}
.sidebar-icons i {
    color: #515151; /* Abu-abu lebih gelap untuk ikon */
    font-size: 1.25rem;
    margin-left: 24px; /* Spasi antar ikon */
    cursor: pointer;
    transition: color 0.2s;
}
.sidebar-icons i:hover {
    color: #075e54;
}

.search-bar {
    background-color: #f6f6f6; /* Abu-abu lebih terang untuk latar belakang bilah pencarian */
    padding: 8px 12px;
    display: flex;
    align-items: center;
}

.search-bar i {
    color: #888;
    margin-right: 8px;
}

.search-bar input {
    flex-grow: 1;
    border: none;
    outline: none;
    background: #ffffff;
    padding: 6px 12px;
    border-radius: 18px; /* Input pencarian membulat */
    font-size: 0.9rem;
}

.chat-list {
    flex-grow: 1;
    overflow-y: auto; /* Memungkinkan pengguliran untuk daftar chat */
    background-color: #ffffff;
}

/* Kartu kontak chat individual di sidebar */
.contact-card {
    display: flex;
    padding: 12px 16px;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid #f2f2f2; /* Pemisah antar kontak */
    transition: background-color 0.2s;
}

.contact-card:hover {
    background-color: #f5f5f5;
}

.contact-card.active {
    background-color: #ebebeb; /* Sorotan untuk chat aktif */
}

.contact-details {
    flex-grow: 1;
    margin-left: 12px;
}

.contact-name {
    font-weight: 500;
    color: #111;
    margin-bottom: 4px;
}

.last-message {
    font-size: 0.85rem;
    color: #666;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis; /* Elipsis untuk pesan panjang */
}

.contact-card .time {
    font-size: 0.75rem;
    color: #888;
    white-space: nowrap;
    margin-left: 10px;
}

/* Area Chat Utama */
.chat-area {
    flex-grow: 1; /* Mengambil sisa ruang */
    display: flex;
    flex-direction: column;
    background-color: #ece5dd; /* Latar belakang chat default */
}

.chat-area .chat-header { /* Khusus untuk header area chat */
    background-color: #ededed;
    color: #515151; /* Warna teks untuk header chat */
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 0; /* Hapus border-radius spesifik karena itu bagian dari chat-area */
    box-shadow: none; /* Hapus shadow agar tidak duplikat dengan wadah chat-area */
}

.chat-header-info {
    display: flex;
    align-items: center;
}

.chat-header-info .chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
}

.chat-header-info .contact-name {
    font-weight: 500;
    font-size: 1.1rem;
    color: #111;
}

.chat-header-info .contact-status {
    font-size: 0.8rem;
    color: #666;
}

.chat-header-icons i {
    color: #515151;
    font-size: 1.25rem;
    margin: 0 12px;
    cursor: pointer;
    transition: color 0.2s;
}
.chat-header-icons i:hover {
    color: #075e54;
}

.chat-messages {
    flex-grow: 1;
    padding: 20px 40px; /* Mengurangi padding horizontal untuk memberikan ruang pada gelembung yang lebih lebar */
    overflow-y: auto;
    background-color: #ece5dd; /* Latar belakang chat WhatsApp */
    display: flex;
    flex-direction: column;
}

.welcome-message {
    text-align: center;
    color: #888;
    padding: 20px;
    font-size: 0.9rem;
}

.message-bubble {
    max-width: 80%; /* Gelembung lebih lebar untuk keterbacaan yang lebih baik */
    padding: 8px 12px;
    border-radius: 7.5px; /* Sudut lebih lembut */
    margin-bottom: 8px;
    word-wrap: break-word;
    font-size: 0.95rem;
    position: relative; /* Untuk ekor gelembung bicara potensial */
}

.incoming-message {
    background-color: #ffffff;
    align-self: flex-start;
    border-bottom-left-radius: 2px; /* Tepi datar kecil untuk ekor halus */
}

.outgoing-message {
    background-color: #dcf8c6;
    align-self: flex-end;
    border-bottom-right-radius: 2px; /* Tepi datar kecil untuk ekor halus */
}

.message-time {
    font-size: 0.7rem;
    color: #888;
    margin-top: 4px;
    text-align: right;
}

.chat-footer {
    background-color: #f0f0f0; /* Latar belakang area input */
    padding: 8px 16px;
    display: flex;
    align-items: center;
}

.chat-footer i {
    font-size: 1.5rem;
    color: #515151; /* Ikon lebih gelap */
    margin: 0 8px;
    cursor: pointer;
    transition: color 0.2s;
}
.chat-footer i:hover {
    color: #075e54;
}

.chat-footer input {
    flex-grow: 1;
    padding: 10px 15px;
    border: none;
    outline: none;
    border-radius: 18px; /* Bidang input membulat */
    background-color: #ffffff;
    margin-right: 8px;
    font-size: 0.95rem;
}

/* Gaya tambahan untuk admin.php */
body.admin-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f0f2f5;
    padding: 20px;
    box-sizing: border-box;
}

body.dashboard-body {
    display: block;
    background-color: #f0f2f5;
    padding: 20px;
    box-sizing: border-box;
}

.admin-container {
    background-color: white;
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 500px;
}

.dashboard-container {
    width: 100%;
    max-width: 900px;
    background-color: white;
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
    margin: 20px auto;
}

#show-register, #show-login {
    cursor: pointer;
    z-index: 10;
    position: relative;
    display: inline-block;
}

/* Gaya untuk kartu bot di dashboard admin */
.bot-card {
    background-color: white;
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.bot-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#bot-profile-image-preview {
    max-width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 50%;
    margin-top: 10px;
    border: 1px solid #e0e0e0;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

#bot-info-modal {
    transition: opacity 0.3s ease;
}
#bot-info-modal.hidden {
    opacity: 0;
    pointer-events: none;
}
#bot-info-modal .rounded-lg {
    max-height: 90vh;
    overflow-y: auto;
}


/* Gaya untuk modal pop-up konten sensitif yang baru */
#sensitive-content-modal {
    transition: opacity 0.3s ease;
}
#sensitive-content-modal.hidden {
    opacity: 0;
    pointer-events: none;
}


/* Penyesuaian Responsif */
@media (max-width: 768px) {
    .whatsapp-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        box-shadow: none;
        position: static;
        transform: none;
    }

    .sidebar {
        width: 100%;
        max-width: none;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }
    .chat-area {
        width: 100%;
        height: auto;
    }

    .whatsapp-container.show-chat-area .sidebar {
        display: none;
    }
    .whatsapp-container.show-chat-area .chat-area {
        display: flex;
    }

    .admin-container,
    .dashboard-container {
        margin: 20px auto;
        padding: 1.5rem;
        width: calc(100% - 40px);
        box-sizing: border-box;
    }

    #bot-list {
        grid-template-columns: 1fr;
    }

    .chat-messages {
        padding: 10px;
    }

    .message-bubble {
        max-width: 95%;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .dashboard-container {
        max-width: 760px;
    }
    #bot-list {
        grid-template-columns: repeat(2, 1fr);
    }
}
