:root {
    /* SEAMLESS CLEAN WHITE THEME - MONOCHROME */
    --bg-page: #ffffff;
    --bg-sidebar: #ffffff; 
    --bg-input: #f4f4f4; 
    --bg-input-hover: #ebebeb;
    --text-title: #000000; 
    --text-body: #3c4043; 
    --text-muted: #5f6368; 
    --border: #f1f3f4; 
    --user-bubble: #f4f4f4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body, html {
    height: 100%; width: 100%; 
    background-color: var(--bg-page);
    font-family: 'Inter', 'Plus Jakarta Sans', -apple-system, sans-serif; 
    color: var(--text-body);
    -webkit-font-smoothing: antialiased;
}

/* ================= LAYOUT UTAMA ================= */
.app-layout { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

/* ================= SIDEBAR (Seamless Monochrome) ================= */
.sidebar {
    width: 260px; background-color: var(--bg-sidebar); 
    border-right: 1px solid var(--border); 
    display: flex; flex-direction: column; transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden; flex-shrink: 0; padding: 12px; z-index: 50;
}
.sidebar.collapsed { width: 68px; padding: 12px 8px; }

.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 8px 12px; margin-bottom: 24px; }
.brand-icon { width: 22px; height: 22px; flex-shrink: 0; color: var(--text-title); }
.brand-text { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 600; font-size: 15px; color: var(--text-title); white-space: nowrap; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 8px 0; }
.sidebar.collapsed .brand-text { display: none; }

.sidebar-toggle-wrap { margin-bottom: 4px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }

/* === MENU KIRI === */
.nav-item { 
    display: flex; align-items: center; justify-content: flex-start; 
    background: transparent !important;
    border: none; cursor: pointer; color: var(--text-body); font-size: 13px; font-weight: 500; 
    padding: 10px 14px; border-radius: 8px; transition: all 0.2s; white-space: nowrap; width: 100%; 
}
.nav-item svg { width: 18px; height: 18px; margin-right: 14px; flex-shrink: 0; stroke-width: 1.5; color: var(--text-muted); transition: 0.2s;}

.nav-item:hover, .nav-item.active { background-color: transparent !important; color: #000000 !important; }
.nav-item:hover svg, .nav-item.active svg { color: #000000 !important; }

.sidebar.collapsed .nav-item { width: 44px; height: 44px; padding: 0; justify-content: center; }
.sidebar.collapsed .nav-item svg { margin-right: 0; }
.sidebar.collapsed .nav-text { display: none; }

.sidebar-footer { padding-top: 8px; margin-top: auto;}
.btn-link { background: none; border: none; color: var(--text-muted); text-decoration: none; font-size: 11px; cursor: pointer; width: 100%; text-align: left; padding: 8px 12px; font-weight: 500; transition: color 0.2s;}
.btn-link:hover { color: var(--text-title); text-decoration: underline;}
.sidebar.collapsed .btn-link { display: none; }

/* Form Input Admin */
.admin-input { width: 100%; padding: 10px 12px; font-size: 13px; border: 1px solid var(--border); border-radius: 8px; background: #ffffff; color: var(--text-title); outline: none; cursor: pointer; font-weight: 500;}
.admin-input:focus { border-color: #000000; }
.admin-input-file { font-size: 12px; padding: 12px; border: 2px dashed #dadce0; background: #ffffff; border-radius: 8px; cursor: pointer; color: var(--text-title); font-weight: 500; width: 100%; text-align: center;}
.admin-input-file:hover { background: #f8f9fa; border-color: #000000;}

.btn-primary { width: 100%; padding: 12px; font-size: 13px; font-weight: 600; color: #ffffff; background: #000000; border: none; border-radius: 8px; cursor: pointer; transition: 0.2s; text-align: center; }
.btn-primary:hover { background: #333333; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.btn-danger { padding: 10px 16px; font-size: 12px; font-weight: 600; color: #d93025; background: #fce8e6; border: none; border-radius: 8px; cursor: pointer; transition: 0.2s; }
.btn-danger:hover { background: #f8d8d6; }
.status-msg { font-size: 12px; color: #000000; font-weight: 600; margin-top: 10px; text-align: center;}

/* ================= MAIN WORKSPACE ================= */
.main-workspace { flex: 1; display: block; position: relative; overflow: hidden; background: var(--bg-page); height: 100%; width: 100%;}

/* Tab Pane absolute */
.tab-pane { 
    display: none !important; 
    width: 100%; height: 100%; 
    flex-direction: column; 
    position: absolute; top: 0; left: 0;
    background: var(--bg-page);
    animation: fadeIn 0.2s ease-out; 
}
.tab-pane.active { display: flex !important; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.panel-heading { margin-bottom: 24px; }
.panel-heading h2 { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 1.25rem; font-weight: 600; color: var(--text-title); margin-bottom: 6px;}
.panel-heading p { font-size: 0.9rem; color: var(--text-muted); font-weight: 400; }

/* ================= TAB 1: UPLOAD & BACA ================= */
.split-layout { display: flex; height: 100%; width: 100%; overflow: hidden; }
.split-left { width: 350px; padding: 40px; border-right: 1px solid var(--border); overflow-y: auto; background: var(--bg-page); }
.split-right { flex: 1; padding: 40px; overflow-y: auto; background: var(--bg-page); }

.form-box { display: flex; flex-direction: column; background: #ffffff; border: 1px solid var(--border); border-radius: 12px; padding: 24px; }
.section-label { font-size: 12px; font-weight: 600; color: var(--text-title); margin-bottom: 8px; display: block;}

.viewer-box { border: 1px solid var(--border); border-radius: 12px; padding: 32px; min-height: 400px; background: #ffffff;}
.empty-state { text-align: center; color: var(--text-muted); font-size: 0.95rem; margin-top: 60px;}

.para-card { background: #ffffff; border: 1px solid var(--border); padding: 20px; border-radius: 12px; margin-bottom: 16px; }
.para-num { font-size: 11px; font-weight: 700; color: var(--text-title); margin-bottom: 8px; letter-spacing: 0.5px;}
.para-text { font-size: 14px; color: var(--text-body); line-height: 1.6; }

/* ================= TAB 2: CHAT AREA ================= */
.chat-layout { display: flex; flex-direction: column; height: 100%; width: 100%; }

.chat-wrapper { flex: 1; display: flex; flex-direction: column; width: 100%; align-items: center; overflow: hidden;}
.chat-wrapper.is-empty, .chat-pane.is-empty { justify-content: center; }

/* Hero Container */
.hero-container { 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    padding: 16px; text-align: center; width: 100%; max-width: 560px; 
    margin: auto; 
}
.hero-image-wrapper { 
    margin-bottom: 16px; display: flex; justify-content: center; align-items: center; width: 100%; 
}
.hero-img { 
    width: 250%; max-width: 300px; height: auto; object-fit: contain; display: block; 
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%); 
    mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 70%, rgba(0,0,0,0) 100%); 
}
.hero-title { 
    font-family: 'Plus Jakarta Sans', sans-serif; font-size: 1.5rem; 
    font-weight: 400; color: var(--text-title); margin: 0; line-height: 1.4; text-align: center; 
}

/* Chat Stream */
.chat-stream { flex: 1; width: 100%; overflow-y: auto; padding: 24px 16px; display: none; flex-direction: column; gap: 32px; scroll-behavior: smooth; }
.message-node { max-width: 560px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; animation: messageFadeIn 0.25s ease-out; }

.message-node.user { align-items: flex-end; }
.message-node.user .bubble { background-color: var(--user-bubble); color: var(--text-title); padding: 12px 20px; border-radius: 20px; font-size: 15px; line-height: 1.5; max-width: 80%; word-break: break-word; font-weight: 400;}

.message-node.ai-response { align-items: flex-start; }
.ai-answer-card { width: 100%; background: transparent; border: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ai-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.ai-card-identity { display: flex; align-items: center; gap: 12px; }
.ai-avatar-sparkle { font-size: 15px; width: 30px; height: 30px; background: #000000; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.ai-name-label, .engine-pill { display: none; } 

.btn-copy-ans { background: transparent; border: none; color: var(--text-muted); font-size: 12px; cursor: pointer; font-weight: 500; display: flex; align-items: center; gap: 6px;}
.btn-copy-ans:hover { color: var(--text-title); text-decoration: underline;}

.ai-answer-content { font-size: 15px; line-height: 1.7; color: var(--text-title); padding-left: 42px; font-weight: 400;}
.ai-answer-content p { margin-bottom: 14px; }
.ai-answer-content strong { font-weight: 600; }
.ai-answer-content ul { list-style: disc; margin: 12px 0 16px 20px; padding: 0; }

.sources-container { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); padding-left: 42px;}
.sources-toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 12px; }
.sources-chips-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.ref-link-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--bg-input); border: none; border-radius: 16px; cursor: pointer; font-size: 12px; color: var(--text-title); font-weight: 500; transition: background 0.2s;}
.ref-link-chip:hover { background: var(--bg-input-hover); color: #000000;}

/* === KOTAK INPUT BAWAH === */
.chat-footer { 
    padding: 10px 20px 20px; 
    width: 100%; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    background: var(--bg-page);
}

.input-wrapper { 
    max-width: 560px; 
    width: 100%; 
    position: relative; 
}

.voice-status { 
    font-size: 11px; color: #000000; margin-bottom: 6px; 
    font-weight: 600; height: 14px; padding-left: 16px;
}

.chat-input-bar { 
    display: flex; align-items: flex-end; 
    background: var(--bg-input); 
    border-radius: 28px;
    padding: 12px 14px 12px 20px;
    border: 1px solid transparent;
    transition: all 0.2s ease; 
    width: 100%;
}
.chat-input-bar:focus-within { background: #ffffff; border-color: #dadce0; box-shadow: 0 1px 6px rgba(32,33,36,0.1); }

.chat-input-bar textarea { 
    flex: 1; border: none; outline: none; background: transparent; 
    font-size: 14.5px; font-family: 'Inter', sans-serif; color: var(--text-title); 
    resize: none; max-height: 160px; min-height: 24px; 
    padding: 4px 0; line-height: 1.5; overflow-y: auto; font-weight: 400;
}
.chat-input-bar textarea::placeholder { color: #80868b; font-weight: 400;}

/* Mic & Send Buttons */
.btn-icon { 
    background: transparent; border: none; color: #5f6368; width: 32px; height: 32px; 
    border-radius: 50%; display: flex; align-items: center; justify-content: center; 
    cursor: pointer; margin-left: 4px; transition: 0.2s; flex-shrink: 0;
}
.btn-icon svg { width: 18px; height: 18px; stroke-width: 1.5;}
.btn-icon:hover { background: rgba(0,0,0,0.05); color: #000000; }
.btn-icon.recording { color: #d93025; animation: pulse 1.5s infinite; }

.btn-send { 
    background: #d1d5db; color: white; border: none; outline: none; 
    width: 32px; height: 32px; border-radius: 50%; 
    display: flex; align-items: center; justify-content: center; 
    cursor: pointer; transition: all 0.2s ease; margin-left: 4px; margin-bottom: 2px; flex-shrink: 0; 
}
.btn-send svg { width: 16px; height: 16px; }

.chat-input-bar textarea:not(:placeholder-shown) ~ .btn-send { color: #ffffff; background: #000000; }
.chat-input-bar textarea:not(:placeholder-shown) ~ .btn-send:hover { background: #333333; }

.branding-text { text-align: center; font-size: 11px; color: #80868b; margin-top: 12px; font-weight: 400;}

/* ================= TAB 3: REPOSITORI ================= */
.repo-layout { padding: 40px; max-width: 1000px; margin: 0 auto; width: 100%; overflow-y: auto; height: 100%;}
.repo-content-box { background: #ffffff; border: 1px solid var(--border); border-radius: 12px; padding: 24px; min-height: 400px;}
.repo-list-container { display: flex; flex-direction: column; gap: 8px; }
.doc-list-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; background: var(--bg-page); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--text-title); cursor: pointer; transition: 0.2s;}
.doc-list-item:hover { background: #f8f9fa; border-color: #000000; }

/* ================= OVERRIDE BADGES & LABELS ================= */
#paragraphContainer h1, #paragraphContainer h2, #paragraphContainer h3, #paragraphContainer p, .para-text, .doc-title {
    color: #000000 !important; font-weight: 400;
}
.level-badge { padding: 4px 10px; border-radius: 12px; font-size: 10px; font-weight: 700; text-transform: uppercase; background: #e8eaed; color: #000000 !important; display: inline-block;}
.level-badge.umum { background: #e0f2fe; color: #0369a1 !important; }
.level-badge.internal { background: #fef3c7; color: #b45309 !important; }
.level-badge.pimpinan { background: #fee2e2; color: #b91c1c !important; }

.tag-badge { display: inline-block; background-color: #ffffff; border: 1px solid #dadce0; color: #000000 !important; padding: 4px 12px; border-radius: 16px; font-size: 11px; font-weight: 500; margin-right: 6px; margin-top: 8px; margin-bottom: 8px;}

/* =========================================================
   MODAL VIEWER DOKUMEN & HIGHLIGHT PARAGRAF (RAPI & MODERN)
   ========================================================= */

/* Backdrop Gelap Transparan */
.custom-modal-overlay { 
    display: none; 
    position: fixed; 
    inset: 0; 
    align-items: center; 
    justify-content: center; 
    z-index: 99999; 
}

.custom-modal-backdrop { 
    position: absolute; 
    inset: 0; 
    background: rgba(15, 23, 42, 0.55); 
    backdrop-filter: blur(4px); 
}

/* Kotak Dialog Dasar */
.custom-modal-content { 
    position: relative; 
    background: #ffffff; 
    border: none; 
    width: 90%; 
    max-width: 600px; 
    border-radius: 20px; 
    padding: 24px; 
    z-index: 10; 
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.2);
    animation: modalPopIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Modifikasi Ukuran Khusus Modal Referensi Dokumen */
.custom-modal-content.doc-viewer-dialog { 
    max-width: 820px; 
    height: 85vh; 
    max-height: 800px;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@keyframes modalPopIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Header Modal */
.custom-modal-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start; 
    padding: 20px 24px; 
    background: #ffffff;
    border-bottom: 1px solid #eef0f2;
    flex-shrink: 0;
}

.modal-title-wrap {
    flex: 1;
    min-width: 0;
    padding-right: 16px;
}

.modal-doc-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.file-type-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 6px;
    background: #f1f3f4;
    color: #3c4043;
}

.modal-doc-filename { 
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.15rem; 
    font-weight: 700; 
    color: #111827 !important; /* Memastikan teks judul selalu hitam tajam */
    margin: 0 0 8px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.modal-tag-chip {
    display: inline-block;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569 !important;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

/* Tombol Tutup Bulat */
.modal-close-btn { 
    background: #f1f3f4; 
    border: none; 
    font-size: 1.4rem; 
    line-height: 1;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer; 
    color: #5f6368;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.modal-close-btn:hover { 
    background: #e2e8f0; 
    color: #000000; 
}

/* Area Isi Dokumen (Scrollable Body) */
.custom-modal-body { 
    flex: 1; 
    padding: 24px; 
    overflow-y: auto; 
    background: #fcfcfd;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Scrollbar Halus */
.custom-modal-body::-webkit-scrollbar {
    width: 6px;
}
.custom-modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Box Tiap Paragraf */
.modal-para-box { 
    background: #ffffff; 
    border: 1px solid #e2e8f0; 
    border-radius: 12px; 
    padding: 16px 20px; 
    transition: all 0.25s ease;
}

.modal-para-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.modal-para-badge, .modal-para-num { 
    font-size: 11px; 
    font-weight: 700; 
    letter-spacing: 0.5px;
    color: #64748b; 
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-block;
}

/* Highlight Paragraf yang Terpilih / Dikutip AI */
.modal-para-box.highlight-target,
.modal-para-box.highlight-yellow { 
    background: #fffbeb !important; /* Kuning Amber Lembut */
    border: 1.5px solid #f59e0b !important; /* Border Amber */
    box-shadow: 0 4px 18px rgba(245, 158, 11, 0.15) !important;
}

.modal-para-badge-target,
.highlight-num {
    font-size: 11px;
    font-weight: 700;
    color: #b45309 !important;
    background: #fde68a !important;
    padding: 3px 10px;
    border-radius: 12px;
}

/* Teks Paragraf */
.modal-para-text { 
    font-size: 14px; 
    line-height: 1.7; 
    color: #1e293b !important; /* Teks gelap tajam, anti-transparan/putih */
    word-break: break-word;
}

.modal-para-text p {
    margin-bottom: 8px;
}
.modal-para-text p:last-child {
    margin-bottom: 0;
}

.modal-para-text.highlight-text { 
    color: #0f172a !important; 
    font-weight: 500;
}