/* ==================================================
    STYLESHEET LENGKAP - VERSI FINAL DENGAN PERBAIKAN
    ================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* === 1. ROOT VARIABLES & GLOBAL STYLES === */
:root {
    --primary-color: #4a44d8;
    --background-primary: #1e293b; /* Sidebar */
    --background-secondary: #f1f5f9; /* Latar Belakang Konten */
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-secondary-light: #64748b;
    --text-on-primary: #ffffff;
    --border-color: #e2e8f0;
    --danger-color: #dc2626;
    --success-color: #16a34a;
    --warning-color: #f59e0b;
    --info-color: #2563eb;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--background-secondary);
    color: var(--text-primary);
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* Mencegah scroll di level body */
}

/* === 2. LAYOUT STRUCTURE (CONTAINER, SIDEBAR, MAIN CONTENT) === */
.dashboard-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    background-color: var(--background-primary);
    color: var(--text-on-primary);
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding-bottom: 20px;
    border-bottom: 1px solid #334155;
    margin-bottom: 20px;
}
.sidebar-header i {
    font-size: 28px;
    color: var(--primary-color);
}
.sidebar-header h2 {
    font-size: 22px;
    font-weight: 600;
}

.sidebar-nav ul {
    list-style: none;
}
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    margin: 4px 0;
    border-radius: 8px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.sidebar-nav .nav-link i {
    font-size: 18px;
    width: 24px;
    margin-right: 15px;
}
.sidebar-nav .nav-link:hover {
    background-color: #334155;
    color: var(--text-on-primary);
}
.sidebar-nav .nav-link.active {
    background-color: var(--primary-color);
    color: var(--text-on-primary);
    font-weight: 600;
}
.menu-badge {
    margin-left: auto;
    background-color: var(--danger-color);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
}

.main-content {
    flex-grow: 1;
    display: flex; /* Menggunakan flex untuk child section */
    flex-direction: column;
    overflow-y: auto; /* Scroll hanya di main content jika perlu */
}
.content-section {
    display: none;
    flex-direction: column;
    height: 100%;
}
.content-section.active {
    display: flex;
}
.content-header {
    padding: 20px 24px;
    background-color: var(--card-background);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.content-header h1 {
    font-size: 24px;
    font-weight: 700;
}

/* === 3. REUSABLE COMPONENTS (BUTTONS, CARDS, FORMS, MODALS, TOASTS) === */
.card {
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.btn {
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}
.btn-primary {
    background-color: var(--primary-color);
    color: var(--text-on-primary);
}
.btn-primary:hover {
    background-color: #3e38b4;
}
.btn-danger {
    background-color: var(--danger-color);
    color: var(--text-on-primary);
}
.btn-danger:hover {
    background-color: #b91c1c;
}
.btn-secondary {
    background-color: #e2e8f0;
    color: var(--text-secondary);
}
.btn-secondary:hover {
    background-color: #cbd5e1;
}

.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(74, 68, 216, 0.2);
}

.hidden-file-input {
    display: none;
}

.modal-overlay {
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
}
.modal-overlay.active {
    display: flex;
}
.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.modal-content .close-button {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
}
/* NEW: Image Zoom Modal Specific Styles */
.modal-content.image-zoom-content {
    background-color: transparent; /* Full transparency */
    padding: 0;
    box-shadow: none;
    width: 95%; /* Make it wider for images */
    height: 95%; /* Make it taller */
    max-width: none; /* Remove max-width constraint */
    display: flex; /* Use flex to center image */
    align-items: center;
    justify-content: center;
}
#zoomedImage {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Ensure image fits without cropping */
    display: block; /* Remove extra space below image */
}
.modal-content.image-zoom-content .close-button {
    position: absolute; /* Re-position for image zoom modal */
    background-color: rgba(0,0,0,0.5);
    color: white;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    right: 20px;
    top: 20px;
    z-index: 1002; /* Ensure it's above the image */
}


#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 350px;
}
.toast {
    background-color: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 15px;
    border-left: 5px solid;
    animation: toast-in 0.5s forwards;
    opacity: 0;
}
.toast.fade-out {
    animation: toast-out 0.5s forwards;
}
.toast-icon {
    font-size: 20px;
}
.toast-content p {
    margin: 0;
    font-weight: 500;
    color: var(--text-primary);
}
.toast.info { border-color: var(--info-color); }
.toast.info .toast-icon { color: var(--info-color); }
.toast.success { border-color: var(--success-color); }
.toast.success .toast-icon { color: var(--success-color); }
.toast.error { border-color: var(--danger-color); }
.toast.error .toast-icon { color: var(--danger-color); }
.toast.warning { border-color: var(--warning-color); }
.toast.warning .toast-icon { color: var(--warning-color); }


/* === 4. WA INBOX SPECIFIC STYLES === */

.wa-container {
    display: flex;
    height: calc(100% - 73px); /* Full height minus header */
}

/* 4.1. WA Accounts Column */
.wa-accounts {
    width: 80px;
    border-right: 1px solid var(--border-color);
    padding: 15px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}
.wa-account {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.2s;
    background-size: cover;
    background-position: center;
}
.wa-account.active {
    border-color: var(--primary-color);
}
.wa-account.add-account {
    border: 2px dashed #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #9ca3af;
    background-image: none;
}
.wa-account.add-account:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.wa-account.add-account[disabled] {
    cursor: not-allowed;
    opacity: 0.5;
}

/* 4.2. WA Chat List Column */
.chat-list {
    width: 320px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.chat-list-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.chat-list-header h4 {
    font-size: 16px;
    font-weight: 600;
}
.btn-new-chat {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
}
.chat-list-container {
    overflow-y: auto;
    flex-grow: 1;
}
.chat-item {
    display: flex;
    padding: 15px 20px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
    align-items: center;
    gap: 15px;
}
.chat-item:hover {
    background-color: var(--background-secondary);
}
.chat-item.active {
    background-color: #f0f2f5;
    color: var(--text-primary);
}
.chat-item.active .chat-item-name,
.chat-item.active .chat-item-timestamp {
    color: var(--text-primary);
}
.chat-item.active .chat-item-preview p {
    color: var(--text-secondary-light);
}
.chat-item-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-item-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.chat-item-avatar-initial {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}
.chat-item-content {
    flex-grow: 1;
    overflow: hidden;
}
.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.chat-item-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-item-timestamp {
    font-size: 12px;
    color: var(--text-secondary-light);
    flex-shrink: 0;
    margin-left: 8px;
}
.chat-item-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary-light);
}
.chat-item-preview p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    flex-grow: 1;
}
.unread-badge {
    background-color: var(--success-color);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    flex-shrink: 0;
}
.chat-item.has-unread .chat-item-name, .chat-item.has-unread .chat-item-preview p {
    font-weight: 700;
    color: var(--text-primary);
}

/* 4.3. WA Chat Window */
.chat-window {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
#wa-welcome-screen {
    flex-grow: 1;
    display: flex; /* Menggunakan flexbox untuk penataan */
    align-items: center; /* Menengahkan secara vertikal */
    justify-content: center; /* Menengahkan secara horizontal */
    background-color: #f8fafc; /* Warna latar yang lebih bersih */
    padding: 40px;
    text-align: center; /* Memastikan teks di dalamnya rata tengah */
}

.welcome-content {
    max-width: 450px; /* Batasi lebar agar teks tidak terlalu panjang di layar besar */
}

.welcome-icon {
    font-size: 60px;          /* Perbesar ikon */
    color: #cbd5e1;           /* Warna ikon yang lembut dan tidak mencolok */
    margin-bottom: 24px;
    display: block;           /* Pastikan ikon berada di barisnya sendiri */
}

#wa-welcome-screen h3 {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px 0;
}

#wa-welcome-screen p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

/* KODE HEADER CHAT YANG DIPERBAIKI */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px; /* Padding yang lebih standar */
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background-color: #f0f2f5; /* Warna header seperti WA */
}
.chat-header-info {
    display: flex;
    flex-direction: column;
}
.chat-header-title {
    font-size: 16px;
    font-weight: 600;
}
.chat-header-status {
    font-size: 13px;
    color: var(--text-secondary-light);
    margin-top: 2px;
}
.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 15px; /* Jarak antar tombol */
}
.btn-header-action {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px; /* Padding agar area klik lebih besar */
    border-radius: 50%; /* Membuat tombol bulat */
    transition: background-color 0.2s, color 0.2s;
}
.btn-header-action:hover {
    background-color: #e9e9e9; /* Efek hover */
}
/* NEW: Style for active pin button */
.btn-header-action.active {
    color: var(--primary-color);
}


.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px; /* Jarak antar bubble sedikit dikurangi */
    background-color: #e9ebee; /* Latar belakang chat seperti WA */
}
.chat-loader {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary-light);
    font-style: italic;
    margin: auto;
}
.message-wrapper {
    display: flex;
    max-width: 75%;
    position: relative; /* PENAMBAHAN: Untuk menu edit/delete */
}
.message-wrapper.sent {
    align-self: flex-end;
}
.message-wrapper.received {
    align-self: flex-start;
}

/* --- Message Bubbles --- */
.message-body {
    padding: 8px 12px; /* Padding bubble dikecilkan */
    border-radius: 12px; /* Sudut lebih smooth */
    position: relative;
    padding-bottom: 25px;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
}
.message-body p {
    line-height: 1.5;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    margin: 0;
    padding-right: 45px; /* Beri ruang untuk timestamp */
}

.message-wrapper.sent .message-body {
    background-color: #dcf8c6; /* Warna bubble hijau WA */
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}
.message-wrapper.received .message-body {
    background-color: var(--card-background);
    border-bottom-left-radius: 4px;
}

/* --- Media within Message Bubbles --- */
.message-media-container {
    max-width: 100%;
    overflow: hidden;
    border-radius: 8px;
    margin-bottom: 5px;
    display: block;
}

/* PERBAIKAN: Ukuran gambar pesan dibatasi */
.message-media-container img,
.message-media-container video {
    max-width: 350px; /* Batasi lebar maksimum media */
    width: 100%;      /* Tetap responsif jika bubble lebih kecil */
    height: auto;
    display: block;
    border-radius: inherit;
    cursor: pointer; /* NEW: Add cursor for zoomable images */
}

/* Style for media caption */
.message-caption {
    font-size: 14px;
    color: inherit;
    line-height: 1.4;
    padding-right: 30px;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    margin-top: 5px;
}


/* --- Message Metadata (Timestamp & Ack Icon) --- */
.message-meta {
    display: flex;
    align-items: center;
    gap: 5px;
    position: absolute;
    font-size: 11px;
    opacity: 0.8;
}

.message-wrapper.sent .message-meta {
    bottom: 5px;
    right: 8px;
    color: #6a7175; /* Warna timestamp di bubble hijau */
}

.message-wrapper.received .message-meta {
    bottom: 5px;
    right: 8px; /* Timestamp diterima juga di kanan bawah */
    color: #9ca3af;
}

.ack-icon {
    font-size: 14px; /* Ukuran ikon ceklis */
    margin-left: 3px;
}
.ack-icon.read {
    color: #4fc3f7; /* Biru untuk read */
}

/* --- PERBAIKAN TOTAL AREA INPUT PESAN --- */
.chat-input {
    flex-shrink: 0;
    padding: 10px 16px;
    background-color: #f0f2f5; /* Samakan dengan background header */
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: flex-end; /* Item rata bawah agar sejajar saat textarea membesar */
    gap: 10px;
    position: relative;
    flex-wrap: wrap; /* Untuk attachment preview */
}
.chat-input-wrapper {
    flex-grow: 1;
    display: flex;
    align-items: center;
    background-color: var(--card-background);
    border-radius: 22px; /* Bubble membulat */
    padding: 5px 15px;
}
.chat-input #wa-message-input {
    flex-grow: 1;
    border: none;
    background-color: transparent;
    font-size: 15px;
    padding: 8px 0;
    outline: none;
    color: var(--text-primary);
    resize: none; /* Matikan resize manual */
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.5;
}
.chat-input .attach-btn,
.chat-input .emoji-btn {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s;
    align-self: center; /* Jaga agar ikon tetap di tengah */
}
.chat-input .attach-btn:hover,
.chat-input .emoji-btn:hover {
    color: var(--primary-color);
}
#wa-send-btn {
    flex-shrink: 0;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 18px;
    align-self: center; /* Jaga agar tombol tetap di tengah */
}
emoji-picker {
    position: absolute;
    bottom: 75px;
    right: 20px;
    z-index: 10;
}

/* === 5. WA BLASTING & SETTINGS SPECIFIC STYLES === */
.blasting-page-container {
    padding: 24px;
    height: calc(100% - 73px);
    display: flex;
    flex-direction: column;
}
.blasting-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
    flex-shrink: 0;
}
.blasting-tab-link {
    padding: 12px 20px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    position: relative;
    border: none;
    background: none;
    font-size: 16px;
}
.blasting-tab-link.active {
    color: var(--primary-color);
    font-weight: 600;
}
.blasting-tab-link.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--primary-color);
    border-radius: 3px 3px 0 0;
}
.blasting-tab-content {
    display: none;
    flex-grow: 1; /* Allow content to fill space */
    overflow-y: auto;
}
.blasting-tab-content.active {
    display: flex;
}
#blasting-tab-panel {
    gap: 24px;
}
#accounts-tab-panel {
    flex-direction: column;
}
.blasting-container {
    display: flex;
    gap: 24px;
    width: 100%;
}
.blasting-form-panel, .blasting-log-panel {
    flex: 1;
    padding: 24px;
    display: flex;
    flex-direction: column;
}
.blasting-form-panel h3, .blasting-log-panel h3, .settings-form-panel h3, .settings-list-panel h3 {
    margin: 0 0 24px 0;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.blasting-form-panel textarea {
    resize: vertical;
    min-height: 120px;
}
.blasting-form-panel small {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: var(--text-secondary-light);
}
.custom-file-input {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}
.custom-file-input:hover {
    border-color: var(--primary-color);
    background-color: #f7f7fe;
}
.custom-file-input .file-input-label {
    color: var(--text-secondary);
}
.custom-file-input i {
    font-size: 24px;
    color: var(--primary-color);
    display: block;
    margin-bottom: 10px;
}
.btn-full {
    width: 100%;
    padding: 15px;
    font-size: 16px;
}
.progress-container {
    margin-bottom: 20px;
}
.progress-bar-bg {
    width: 100%;
    height: 10px;
    background-color: var(--background-secondary);
    border-radius: 5px;
    overflow: hidden;
    margin-top: 8px;
}
.progress-bar {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 5px;
    transition: width 0.3s ease-in-out;
}
.log-box {
    flex-grow: 1;
    background-color: #0d1117;
    color: #c9d1d9;
    font-family: 'SF Mono', 'Courier New', monospace;
    font-size: 13px;
    padding: 15px;
    border-radius: 8px;
    overflow-y: auto;
    border: 1px solid #30363d;
    white-space: pre-wrap;
}
.log-entry {
    margin: 0 0 6px 0;
    line-height: 1.6;
    display: flex;
    gap: 10px;
}
.log-entry span { color: #8b949e; }
.log-placeholder {
    color: #8b949e;
    font-style: italic;
    font-family: 'Inter', sans-serif;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.log-success { color: #56d364; }
.log-error { color: #f85149; }
.log-warn, .log-warning { color: #e3b341; } /* Added .log-warning */
.log-info { color: #c9d1d9; }

.accounts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0 24px 0;
}
#blasting-accounts-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}
.account-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.account-card-main {
    display: flex;
    align-items: center;
    gap: 15px;
}
.account-card-main img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
}
.account-card-info h4 { font-weight: 600; }
.account-card-info small { color: var(--text-secondary-light); }
.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.status-online { background-color: #dcfce7; color: #16a34a; }
.status-offline { background-color: #fee2e2; color: #b91c1c; }


/* === 6. QR CODE & LOADING OVERLAY === */
#wa-loading-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(30, 41, 59, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999 !important;
    display: none; /* Hidden by default */
    align-items: center;
    justify-content: center;
}
#wa-loading-overlay .loading-content {
    background-color: var(--card-background);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
}
#wa-loading-overlay h3 {
    margin: 0 0 15px 0;
    color: var(--text-primary);
}
.spinner-area .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--background-secondary);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 10px auto 20px auto;
}
.spinner-area p {
    color: var(--text-secondary);
}
#wa-qr-section {
    display: flex;
    flex-direction: column;  /* PENTING: Menumpuk elemen ke bawah */
    align-items: center;     /* Menengahkan semua elemen secara horizontal */
    width: 100%;
    padding: 0;              /* Hapus padding jika ada, agar rapi */
}
#wa-qr-container {
    margin-bottom: 15px;
}
#wa-qr-instruction {
    text-align: center;
    margin-bottom: 25px;     /* Beri jarak yang cukup ke tombol di bawahnya */
    color: var(--text-secondary);
    line-height: 1.5;
}
.qr-action-buttons {
    display: flex;           /* Membuat tombol bersebelahan */
    gap: 12px;               /* Jarak antar tombol */
    justify-content: center; /* Menengahkan grup tombol */
    width: 100%;
}


/* === 7. TEMPLATES / SETTINGS PAGE === */

.settings-container {
    padding: 24px;
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 24px;
    height: calc(100% - 73px);
}
.settings-form-panel, .settings-list-panel {
    padding: 24px;
    display: flex;
    flex-direction: column;
}
.settings-list-panel {
    overflow-y: auto;
}
#template-form textarea {
    resize: vertical;
    min-height: 150px;
}
.template-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 15px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.template-item:hover {
    border-color: #d1d5db;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.template-item-content {
    flex-grow: 1;
    margin-right: 15px;
}
.template-item-keyword {
    font-weight: 600;
    font-size: 15px;
    color: var(--primary-color);
    margin-bottom: 8px;
}
.template-item-message {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: break-word; /* Ensure long words break within the container */
}
.template-item-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}
.template-item-actions .btn {
    padding: 6px 10px;
    background-color: var(--background-secondary);
    color: var(--text-secondary);
}
.template-item-actions .btn:hover {
    background-color: var(--border-color);
}
.template-item-actions .btn.btn-danger {
    background-color: #fee2e2;
    color: var(--danger-color);
}
.template-item-actions .btn.btn-danger:hover {
    background-color: var(--danger-color);
    color: white;
}
.placeholder-text {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary-light);
    font-style: italic;
}


/* === 8. ANIMATIONS === */

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes toast-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.chat-list-search {
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 15px;
    background-color: #f8fafc;
}
.chat-list-search i {
    color: var(--text-secondary-light);
}
.chat-list-search input {
    border: none;
    background: none;
    outline: none;
    width: 100%;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
}

/* 2. Styling untuk Tabs */
.chat-list-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.tab-link {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}
.tab-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* 3. Styling untuk Daftar Kontak */
.contact-list-container {
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}
.sync-contacts-wrapper {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}
.sync-contacts-wrapper .btn {
    width: 100%;
}
.contact-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}
.contact-item:hover {
    background-color: var(--background-secondary);
}
.contact-item-info {
    display: flex;
    flex-direction: column;
}
.contact-item-name {
    font-weight: 600;
    font-size: 15px;
}
.contact-item-number {
    font-size: 13px;
    color: var(--text-secondary-light);
}

.attachment-preview {
    width: 100%; /* Lebar penuh */
    padding: 10px;
    margin-bottom: 10px;
    background-color: #f0f2f5;
    border-radius: 8px;
    position: relative;
    display: flex;
    align-items: center;
    order: -1;
}

#attachment-preview-content img {
    max-height: 80px;
    max-width: 80px;
    border-radius: 6px;
    object-fit: cover;
}

.cancel-attachment {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    font-size: 14px;
}

/* PENAMBAHAN BARU: Menu Aksi pada Pesan (Edit/Delete) */
/* .message-actions { Removed, now handled by context menu } */
/* No more hover display, only via context menu */

.sidebar-footer {
    margin-top: auto; /* Mendorong ke bagian bawah */
    padding-top: 20px;
    border-top: 1px solid #334155;
}

/* Style khusus untuk tombol logout */
.logout-btn {
    background-color: #334155;
}
.logout-btn:hover {
    background-color: var(--danger-color) !important;
    color: white !important;
}

/* Wrapper untuk ikon akun WA di kolom kiri */
.wa-account-wrapper {
    position: relative;
    margin-bottom: 10px;
}
.wa-account-wrapper.active .wa-account {
    border-color: var(--primary-color);
}

/* Tombol logout kecil per sesi WA */
.btn-logout-wa-icon {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 22px;
    height: 22px;
    background-color: var(--danger-color);
    color: white;
    border: 2px solid var(--background-primary);
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 18px;
    text-align: center;
    font-weight: bold;
    display: none; /* Sembunyi secara default */
    z-index: 10;
}

/* Tampilkan tombol logout kecil saat hover */
.wa-account-wrapper:hover .btn-logout-wa-icon {
    display: block;
}

/* NEW: Message Reactions Display */
.message-reactions {
    position: absolute;
    bottom: -12px; /* Position below the message bubble */
    left: 5px; /* Adjust as needed */
    display: flex;
    gap: 3px;
    background-color: rgba(255, 255, 255, 0.9); /* Slight background for visibility */
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 10px; /* Rounded pill shape */
    padding: 2px 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    font-size: 14px;
    z-index: 2; /* Above the message bubble */
}
.message-wrapper.sent .message-reactions {
    left: auto;
    right: 5px; /* On the right for sent messages */
}
.reaction-emoji {
    display: inline-block;
    cursor: default;
}


/* NEW: Context Menu (for both chat list and messages) */
.context-menu {
    position: fixed;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1001; /* Higher than modal overlay for some cases */
    padding: 8px 0;
}
.context-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.context-menu li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: background-color 0.2s;
}
.context-menu li i {
    width: 20px;
    text-align: center;
    color: var(--text-secondary-light);
}
.context-menu li:hover {
    background-color: #f0f2f5;
}

/* NEW: Reaction Emoji Picker inside Message Context Menu */
#message-react-option {
    position: relative; /* Allow child emoji picker to be positioned */
}
.reaction-emoji-picker {
    position: absolute;
    left: 100%; /* To the right of the "Reaksi" option */
    top: 0;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 8px;
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    z-index: 1002; /* Even higher */
    width: max-content;
    border: 1px solid var(--border-color);
}
.reaction-emoji-picker .emoji-option {
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s;
}
.reaction-emoji-picker .emoji-option:hover {
    background-color: #e9e9e9;
}

/* --- Login Page Specific Styles (Added to style.css) --- */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--background-secondary); /* Latar belakang sama dengan dashboard */
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.login-container {
    width: 100%;
    max-width: 400px; /* Batasi lebar container login */
}

.login-card {
    padding: 30px;
    text-align: center;
}

.login-header {
    margin-bottom: 30px;
}

.login-icon {
    font-size: 50px; /* Ukuran ikon */
    color: var(--primary-color);
    margin-bottom: 15px;
}

.login-header h2 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
}

.error-message {
    color: var(--danger-color);
    font-size: 14px;
    margin-top: -10px; /* Sesuaikan jarak ke input/tombol di atasnya */
    margin-bottom: 15px;
}
