:root {
    --bg-primary: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --brand-blue: #2563eb;
    --brand-blue-hover: #1d4ed8;
    --border-color: #e2e8f0;
    --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-main);
    line-height: 1.5;
}

/* HEADER */
.app-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 22px 0;
    width: 100%;
}
.header-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 30px;
    width: 100%;
    display: flex;
    justify-content: space-between; /* Memisahkan info app di kiri & kampus di kanan */
    align-items: center;            /* Sejajar lurus secara vertikal */
    box-sizing: border-box;
}
.header-container h1 {
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}
.header-container p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.institution-badge {
    color: var(--brand-blue);
    font-weight: 600;
    background: #eff6ff; /* Warna background biru muda segar */
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 12px;
    display: inline-block;
    border: 1px solid #dbeafe;
}

/* ==========================================================================
   ANALYTICS CHART CARD STYLING
   ========================================================================== */

.chart-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    margin-bottom: 25px; /* Memberi jarak ke tabel di bawahnya */
    width: 100%;
}

.chart-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 20px;
    position: relative;
    padding-left: 12px;
}

/* Garis aksen vertikal kecil di samping tulisan judul grafik */
.chart-header h3::before {
    content: '';
    position: absolute;
    left: 0;
    top: 3px;
    bottom: 3px;
    width: 4px;
    background-color: var(--brand-blue);
    border-radius: 2px;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 220px; /* Tinggi ideal agar dasbor tidak terlalu penuh saat di-scroll */
}


/* Sisi Kiri */
.header-brand h1 {
    font-size: 24px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}
.app-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 3px;
}

/* Sisi Kanan: Blok Institusi yang Tegas & Elegan */
.institution-block {
    text-align: right; /* Rata kanan agar rapi di sudut layar */
    max-width: 50%;    /* Mencegah teks terlalu panjang merusak layout */
}

/* Label deskripsi kecil di atas nama kampus */
.institution-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.12em; /* Jeda antar huruf khas desain premium */
    margin-bottom: 2px;
}

/* Teks Utama Nama Kampus */
.institution-display {
    font-size: 22px;        /* Ukuran besar dan dominan */
    font-weight: 700;       /* Sangat tebal & tegas */
    color: #1e40af;         /* Warna Navy/Corporate Blue solid yang formal */
    letter-spacing: -0.02em;
    line-height: 1.2;
}

/* LAYOUT UTAMA */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 25px 30px;
}
.main-layout {
    display: grid;
    /* Menggunakan minmax(0, 1fr) agar kolom kanan bisa mengecil mengikuti sisa layar */
    grid-template-columns: 320px minmax(0, 1fr); 
    gap: 25px;
    align-items: start;
}

.main-content {
    min-width: 0; /* Memaksa konten di dalam grid tidak mendesak keluar container */
    width: 100%;
}

/* KOLOM KIRI (SIDEBAR FILTER JURNAL PROFESIONAL) */
.card-sidebar {
    background: #ffffff;
    border-radius: 14px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}
.card-sidebar h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}
.journal-filter-list {
    max-height: calc(100vh - 210px);
    overflow-y: auto;
    padding-right: 4px;
}
.journal-filter-list::-webkit-scrollbar {
    width: 6px;
}
.journal-filter-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Item Utama Jurnal */
.journal-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: 6px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.journal-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}
.journal-item.active {
    background: #eff6ff;
    border-color: #bfdbfe;
}
.j-name {
    font-size: 13.5px;
    font-weight: 500;
    color: #334155;
    line-height: 1.4;
    padding-right: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.journal-item.active .j-name {
    color: var(--brand-blue);
    font-weight: 600;
}
.j-count {
    background: #e2e8f0;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
    transition: all 0.2s ease;
}
.journal-item.active .j-count {
    background: var(--brand-blue);
    color: #ffffff;
}

/* PROGRESS BAR */
.progress-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
}
.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    font-weight: 500;
}
.badge-counter {
    font-size: 12px;
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 20px;
    color: #475569;
}
.progress-track {
    height: 10px;
    background: #e2e8f0;
    border-radius: 20px;
    overflow: hidden;
}
.progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--brand-blue), #10b981);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* TABEL DATA CARD */
.table-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    width: 100%;
    overflow-x: auto; 
}

/* DATATABLE OVERRIDES & TYPOGRAPHY CELL */
table.dataTable {
    border-collapse: collapse !important;
    font-size: 13.5px;
    width: 100% !important; /* Memastikan tabel patuh pada batas card */
    table-layout: fixed;   /* Memaksa pembagian persentase kolom (width %) bekerja akurat */
}
table.dataTable thead th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
    padding: 12px 16px !important;
    border-bottom: 1px solid var(--border-color) !important;
}

table.dataTable tbody td {
    padding: 14px 16px !important;
    border-bottom: 1px solid #f1f5f9 !important;
    vertical-align: top;
    
    /* Kombinasi maut agar teks judul/penulis yang panjang otomatis turun ke bawah */
    white-space: normal !important; 
    word-break: break-word;         
    overflow-wrap: break-word;
}

.article-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.article-title-link {
    color: var(--text-main);
    font-weight: 600;
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.15s;
}
.article-title-link:hover {
    color: var(--brand-blue);
}
.article-doi {
    font-size: 11px;
    color: var(--brand-blue);
    background: #eff6ff;
    padding: 2px 6px;
    border-radius: 4px;
    width: fit-content;
    font-family: monospace;
}
.journal-text-cell {
    color: #475569;
    font-style: italic;
}

.badge-year {
    background: #f1f5f9;
    color: #334155;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 12px;
}
.badge-cite {
    background: #dcfce7;
    color: #15803d;
    padding: 4px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 12px;
    display: inline-block;
    text-align: center;
    min-width: 35px;
}
.no-cite {
    color: #cbd5e1;
}

.btn-detail {
    white-space: nowrap;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s;
}

.btn-detail:hover {
    background: var(--brand-blue);
    color: #ffffff;
    border-color: var(--brand-blue);
}

/* OVERLAY & SIDE PANEL */
#overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    z-index: 999;
    pointer-events: auto; /* Memastikan mouse tidak bisa menembus klik/scroll ke tabel */
}

#citationPanel {
    position: fixed;
    right: -100%;
    top: 0;
    width: 50vw;
    max-width: 800px;
    min-width: 450px;
    height: 100vh;
    background: #ffffff;
    z-index: 1000;
    transition: right 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 25px -5px rgba(0,0,0,0.1);
    overscroll-behavior: contain; /* Mengunci total internal scroll */    
}
#citationPanel.open {
    right: 0;
}
.panel-header {
    background: #0f172a;
    color: #ffffff;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.panel-header h2 {
    font-size: 18px;
    font-weight: 600;
}
.badge-count-panel {
    font-size: 12px;
    background: rgba(255,255,255,0.15);
    padding: 2px 8px;
    border-radius: 10px;
    margin-top: 4px;
    display: inline-block;
}
#closePanel {
    border: none;
    background: none;
    color: #94a3b8;
    font-size: 22px;
    cursor: pointer;
    transition: color 0.15s;
}
#closePanel:hover {
    color: #ffffff;
}
.panel-search {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: #f8fafc;
}
.panel-search input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13.5px;
    outline: none;
}
.panel-search input:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

#citationBody {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f8fafc;
}
.citation-card {
    background: #ffffff;
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}
.citation-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-main);
    margin-bottom: 8px;
    line-height: 1.4;
}
.citation-meta {
    color: var(--text-muted);
    font-size: 12.5px;
    line-height: 1.6;
}
.citation-doi {
    display: inline-block;
    margin-top: 10px;
    font-size: 12px;
    color: var(--brand-blue);
    text-decoration: none;
    font-weight: 500;
}
.citation-doi:hover {
    text-decoration: underline;
}

.loading, .loading-sidebar {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}
.no-data-panel {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 13.5px;
}

html.panel-open, 
body.panel-open {
    overflow: hidden !important;
    height: 100vh !important;
    width: 100% !important;
}


/* ==========================================================================
   BREAKPOINT LAYOUT MEDIUM (MAX-WIDTH: 1024px)
   ========================================================================== */
@media(max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr; /* Kolom kiri pindah ke atas, tabel di bawahnya */
    }
    .card-sidebar {
        margin-bottom: 10px;
    }
    .journal-filter-list {
        max-height: 200px; /* Batasi tinggi list jurnal di HP agar tidak terlalu panjang */
    }
}


/* ==========================================================================
   BREAKPOINT MOBILE (MAX-WIDTH: 768px)
   ========================================================================== */
@media (max-width: 768px) {
    /* Header Kampus/Institusi */
    .header-container {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .institution-block {
        text-align: left;
        border-left: 3px solid var(--brand-blue);
        padding-left: 12px;
        max-width: 100%;
    }

    /* --- SISTEM FILTER DAFTAR JURNAL MOBILE --- */
    .journal-item {
        flex-direction: column;
        align-items: flex-start; /* Mengatur susunan vertikal rata kiri */
        gap: 6px;
        padding: 12px 14px;
    }
    .j-name {
        width: 100%;
        padding-right: 0;
        font-size: 13px;
        white-space: normal; /* Biarkan teks nama jurnal turun jika terlalu panjang */
        overflow: visible;
        text-overflow: clip;
    }
    .j-count {
        align-self: flex-start; /* Memaksa badge angka diletakkan tepat di bawah teks */
        margin-top: 2px;
        background: #f1f5f9;
        border: 1px solid #e2e8f0;
        font-size: 10.5px;
        padding: 2px 8px;
    }
    .journal-item.active .j-count {
        background: var(--brand-blue);
        border-color: var(--brand-blue);
        color: #ffffff;
    }

    /* --- RESPONSIVE CARD-BASED DATATABLE --- */
    /* Sembunyikan Header Tabel Asli */
    table.dataTable thead {
        display: none !important;
    }

    /* Paksa elemen tabel menjadi tumpukan block */
    table.dataTable, 
    table.dataTable tbody, 
    table.dataTable tr, 
    table.dataTable td {
        display: block !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    /* Ubah Baris Tabel (TR) Menjadi Struktur Card */
    table.dataTable tbody tr {
        background: #ffffff !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 12px !important;
        padding: 16px !important;
        margin-bottom: 16px !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.02);
        position: relative;
        display: flex !important;
        flex-direction: column;
    }

    /* Atur Ulang Kolom (TD) di dalam Card */
    table.dataTable tbody td {
        border-bottom: none !important;
        padding: 6px 0 !important;
        font-size: 13px !important;
    }

    /* Penataan & Pengurutan Baris Data di Mobile */
    /* 1. Baris Judul & DOI */
    table.dataTable tbody td:nth-child(2) {
        order: 1;
    }
    
    /* 2. Baris Penulis */
    table.dataTable tbody td:nth-child(3) {
        order: 2;
        color: #475569;
        margin-bottom: 4px;
    }
    table.dataTable tbody td:nth-child(3)::before {
        content: "Penulis: ";
        font-weight: 600;
        color: var(--text-muted);
    }

    /* 3. Baris Jurnal */
    table.dataTable tbody td:nth-child(4) {
        order: 3;
        margin-bottom: 12px;
    }
    table.dataTable tbody td:nth-child(4)::before {
        content: "Jurnal: ";
        font-weight: 600;
        color: var(--text-muted);
        font-style: normal;
    }

    /* 4. Baris Tahun & Sitasi (Dibuat Sebaris Berdampingan) */
    table.dataTable tbody td:nth-child(1) {
        order: 4;
        display: inline-block !important;
        width: auto !important;
        margin-right: 8px;
    }
    table.dataTable tbody td:nth-child(5) {
        order: 5;
        display: inline-block !important;
        width: auto !important;
    }
    table.dataTable tbody td:nth-child(5)::before {
        content: "Sitasi: ";
        font-weight: 600;
        font-size: 12px;
        color: var(--text-muted);
        margin-right: 4px;
    }

    /* 5. Tombol Aksi */
    table.dataTable tbody td:nth-child(6) {
        order: 6;
        display: block !important;
        padding-top: 12px !important;
        border-top: 1px dashed var(--border-color) !important;
        margin-top: 10px;
    }
    .btn-detail {
        width: 100%;
        text-align: center;
        padding: 10px !important;
        font-size: 13px;
    }

    /* Penyesuaian Sisi Panel Detail Citasi */
    #citationPanel {
        width: 100vw !important;
        min-width: 100vw !important;
        max-width: 100vw !important;
    }
}


/* ==========================================================================
   TOMBOL SORTING ACTIONS KUSTOM (ZONA ATAS TABLE)
   ========================================================================== */
.mobile-sort-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.sort-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-sort {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: #475569;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sort:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.btn-sort.active {
    background: var(--brand-blue);
    color: #ffffff;
    border-color: var(--brand-blue);
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn-sort.active[data-order="desc"]::after {
    content: " ↓";
}
.btn-sort.active[data-order="asc"]::after {
    content: " ↑";
}
