/* --- Global Styling (Reset & Fonts) --- */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f2f5; /* Light grey background */
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Start from the top */
    min-height: 100vh;
}

/* --- Chat Container (index.html) --- */
.chat-container {
    width: 100%;
    max-width: 400px;
    margin-top: 20px;
    margin-bottom: 20px;
    height: 90vh; /* Make it tall for better chat simulation */
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
}

/* --- Chat Header --- */
.chat-header {
    background-color: #075E54; /* WhatsApp-like green */
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.bot-info {
    display: flex;
    align-items: center;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #25D366; /* Lighter green for avatar */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    font-weight: bold;
    margin-right: 10px;
    /* Styling untuk gambar avatar base64 */
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    color: white; 
}

.status h3 {
    margin: 0;
    font-size: 16px;
    line-height: 1.2;
}

.status p {
    margin: 0;
    font-size: 12px;
    opacity: 0.8;
}

/* Tombol Admin di Chat Header (Telah Dihapus di index.html, tapi ini stylenya) */
.admin-link {
    color: white;
    text-decoration: none;
    font-size: 14px;
    padding: 5px 10px;
    border: 1px solid white;
    border-radius: 5px;
    transition: background-color 0.3s;
}

/* --- Chat Body (Pesan) --- */
.chat-body {
    flex-grow: 1;
    padding: 10px;
    overflow-y: auto;
    background-color: #ECE5DD; /* Light canvas background */
}

/* Base Message Style */
.message {
    display: flex;
    margin-bottom: 15px;
}

.message-bubble {
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 80%;
    position: relative;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word; /* Ensure long words break */
    min-width: 60px; /* Agar timestamp punya ruang */
}

/* User Message */
.user-message {
    justify-content: flex-end;
}

.user-message .message-bubble {
    background-color: #DCF8C6; /* Light green/blue for user */
    color: #121212;
    border-bottom-right-radius: 0;
}

/* Bot Message */
.bot-message {
    justify-content: flex-start;
}

.bot-message .message-bubble {
    background-color: white;
    color: #121212;
    border-bottom-left-radius: 0;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

/* Timestamp */
.timestamp {
    display: block;
    margin-top: 5px;
    font-size: 10px;
    color: #8c8c8c;
    text-align: right;
    line-height: 1;
}

/* --- Typing Indicator --- */
.typing-indicator .message-bubble {
    display: flex;
    align-items: center;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: #8c8c8c;
    border-radius: 50%;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator .dot:nth-child(2) { animation-delay: -0.16s; }
.typing-indicator .dot:nth-child(3) { animation-delay: 0s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* --- Chat Input --- */
.chat-input {
    display: flex;
    padding: 10px;
    border-top: 1px solid #ddd;
    background-color: #f7f7f7;
}

.chat-input input[type="text"] {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 20px;
    margin-right: 10px;
    font-size: 14px;
}

.chat-input button {
    background-color: #075E54;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}

.chat-input button:hover {
    background-color: #054a41;
}

/* ================================================= */
/* --- Styling Khusus Admin Dashboard (admin.html) --- */
/* ================================================= */

.admin-container {
    background-color: white;
    padding: 30px;
    margin: 30px 0;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    max-width: 800px;
    width: 95%;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.admin-header h1 {
    margin: 0;
    color: #075E54;
    font-size: 24px;
}

/* Perbaikan Tombol "Kembali ke Chat" */
.admin-container .admin-header .admin-link {
    background-color: #075E54; /* Hijau Khas Chatbot agar terlihat */
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    transition: opacity 0.3s;
}

.admin-container .admin-header .admin-link:hover {
    opacity: 0.8;
}

/* Heading & Forms */
.admin-container h2 {
    color: #333;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 5px;
    margin-top: 25px;
    font-size: 20px;
}

.rule-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 5px;
}

.rule-form input[type="text"],
.rule-form input[type="file"],
.rule-form textarea {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
}

.rule-form input[type="text"],
.rule-form textarea,
.rule-form input[type="file"] {
    width: 100%;
    box-sizing: border-box;
}

.rule-form button {
    background-color: #25D366; /* Hijau Terang untuk Aksi */
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
}

.rule-form button:hover {
    background-color: #1fad53;
}

#cancel-edit {
    background-color: #f44336; /* Warna merah untuk tombol batal */
}

#cancel-edit:hover {
    background-color: #d32f2f;
}

/* --- Rules Table --- */
.rules-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.rules-table th, .rules-table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
    font-size: 14px;
}

.rules-table th {
    background-color: #f7f7f7;
    font-weight: bold;
    color: #333;
}

.action-button {
    padding: 5px 10px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    margin-right: 5px;
    font-size: 12px;
}

.edit-btn {
    background-color: #2196F3;
    color: white;
}

.delete-btn {
    background-color: #f44336;
    color: white;
}

/* --- Simulation Chat --- */
#chat-simulation {
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 15px;
    background-color: #f9f9f9;
}

#simulation-output {
    height: 200px;
    overflow-y: auto;
    border-bottom: 1px solid #eee;
    margin-bottom: 10px;
    padding-bottom: 10px;
}

.sim-message {
    margin: 5px 0;
    padding: 5px;
    border-radius: 4px;
    font-size: 14px;
}

.sim-user {
    background-color: #DCF8C6;
    text-align: right;
}

.sim-bot {
    background-color: white;
    text-align: left;
    border: 1px solid #f0f0f0;
}

.sim-input-group {
    display: flex;
    gap: 10px;
}

.sim-input-group input {
    flex-grow: 1;
    border-radius: 5px;
}