/* General Body and Main Layout */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- HEADER STYLES --- */
/* Target elemen <header> dengan kelas .navbar untuk spesifisitas tinggi */
header.navbar {
    background-color: #002D62 !important;
    color: white !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2) !important;
    width: 100% !important;
    position: relative !important;
    z-index: 1000 !important;
    padding: 10px 0 !important;
    
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    align-items: center !important;
    min-height: auto !important;
    height: auto !important;
    border-bottom: none !important;
}

/* Target container di dalam navbar dengan selektor yang SANGAT spesifik */
header.navbar > .nav-container { /* Selektor ini menargetkan anak langsung dari header.navbar */
    max-width: 1850px !important;
    width: 100% !important; /* INI KUNCI UNTUK MEMBUATNYA TERSEBAR */
    margin: 0 auto !important;
    padding: 0 1.5rem !important;
    
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important; /* Logo kiri, navigasi kanan */
    align-items: center !important;
    flex-wrap: nowrap !important;

    background-color: transparent !important;
    box-sizing: border-box !important;
    /* HAPUS INI: border: 3px dashed blue !important; */ /* Debugging border dihapus */
}

/* Target logo wrapper untuk menghilangkan kotak putih */
.logo-wrapper {
    background-color: white !important; /* Mengubah background menjadi putih */
    padding: 5px 10px !important; /* Menambah padding di sekitar logo */
    border-radius: 6px !important; /* Menambahkan sedikit sudut membulat */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important; /* Menambah sedikit bayangan */
    margin: 0 !important;

    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-shrink: 0 !important;
    height: auto !important;
}

/* Gaya untuk gambar logo */
.logo-img {
    height: 40px !important;
    width: auto !important;
    margin-right: 0 !important;
}

/* Gaya untuk teks di dalam logo wrapper (span) */
.logo-wrapper span { /* TARGET SPAN SECARA LANGSUNG */
    font-size: 1.5em !important;
    font-weight: bold !important;
    color: #333 !important; /* Mengubah warna teks menjadi hitam/gelap */
    line-height: normal !important;
    vertical-align: middle !important;
    margin: 0 !important;
}

/* Navigasi */
nav {
    display: flex !important;
    flex-direction: row !important;
    flex-grow: 1 !important;
    justify-content: flex-end !important;
    align-items: center !important;
}

nav ul {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 20px !important;
    justify-content: flex-end !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
}

nav a {
    color: white !important;
    text-decoration: none !important;
    font-weight: 500 !important;
    padding: 5px 10px !important;
    border-radius: 6px !important;
    transition: color 0.3s ease, background-color 0.3s ease !important;
    font-size: 1rem !important;
}

nav a:hover {
    background-color: rgba(255,255,255,0.2) !important;
    color: #007bff !important;
}

nav a.active {
    background-color: #ffffff !important;
    color: #002147 !important;
    font-weight: bold !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1) !important;
}
/* --- END HEADER STYLES --- */



.main-content-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden; /* Prevent main content from overflowing */
}

/* Sidebar Left - Explorer Panel */
.sidebar-left {
    width: 300px; /* Lebar sidebar */
    background-color: #2c3e50; /* Warna gelap untuk sidebar */
    color: #ecf0f1;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    flex-shrink: 0; /* Prevent sidebar from shrinking */
    overflow-y: auto; /* Allow scrolling within the sidebar */
}

.sidebar-left h2 {
    color: #ecf0f1;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.sidebar-left hr {
    border-color: #34495e;
    margin-bottom: 20px;
}

.explorer-nav {
    list-style: none;
    padding: 0;
    margin-bottom: 20px;
}

.explorer-nav li a {
    color: #ecf0f1;
    text-decoration: none;
    padding: 10px 0;
    display: block;
    transition: background-color 0.3s ease;
}

.explorer-nav li a:hover {
    background-color: #34495e;
    border-radius: 4px;
}

.explorer-nav li a i {
    margin-right: 10px;
    width: 20px; /* Ensure consistent icon spacing */
    text-align: center;
}

/* Tree View Styling */
.tree-wrapper {
    margin-top: 20px;
    flex-grow: 1; /* Allow tree to take available space */
    overflow-y: auto; /* Scroll for tree content */
    padding-right: 5px; /* Space for scrollbar */
}

.folder-tree {
    list-style-type: none;
    padding-left: 20px; /* Indent for nested items */
    margin: 0;
}

.folder-tree li {
    line-height: 1.5;
    position: relative;
    cursor: pointer;
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden;
    text-overflow: ellipsis; /* Show ellipsis for overflowed text */
}

.folder-tree li.selected > .folder-label-clickable,
.folder-tree li.selected > .item-name {
    background-color: #007bff; /* Highlight color for selected item */
    color: white;
    border-radius: 3px;
}

.folder-tree li:hover > .folder-label-clickable,
.folder-tree li:hover > .item-name {
    background-color: rgba(255, 255, 255, 0.1); /* Subtle hover for tree items */
    border-radius: 3px;
}

.folder-tree ul {
    list-style-type: none;
    padding-left: 20px; /* Indent for sub-folders */
    margin: 0;
}

.folder-tree ul.hidden {
    display: none;
}

.folder-toggle > .toggle-icon {
    margin-right: 5px;
    transition: transform 0.2s ease-in-out;
    display: inline-block;
    width: 15px; /* Fixed width for icon */
    text-align: center;
}

.folder-toggle.expanded > .toggle-icon {
    transform: rotate(90deg);
}

.folder-label-clickable, .item-name {
    display: inline-block;
    padding: 2px 5px;
    border-radius: 3px;
    margin-right: 5px; /* Space for context menu icon */
}

.file-item .item-name {
    cursor: pointer; /* Indicate it's clickable */
}

/* Context Menu Styling (if re-added for other purposes) */
.context-menu {
    position: absolute;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    list-style: none;
    padding: 5px 0;
    min-width: 150px;
}

.context-menu li {
    padding: 8px 15px;
    cursor: pointer;
    color: #333;
    white-space: nowrap;
}

.context-menu li:hover {
    background-color: #f0f0f0;
}

.context-menu li i {
    margin-right: 10px;
}

/* Sidebar Buttons */
.sidebar-buttons {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #34495e;
}

.sidebar-buttons .btn {
    font-size: 0.9rem;
    padding: 8px 15px;
}

/* Main Report Content Area */
.main-report-content-area {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin: 20px;
    overflow-y: auto; /* Allow scrolling within the main content */
}

.main-report-content-area h1 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 2rem;
}

.report-section {
    margin-bottom: 40px;
}

.report-section h2 {
    color: #34495e;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-size: 1.6rem;
}

/* Table Styling */
.evaluation-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.evaluation-table th,
.evaluation-table td {
    border: 1px solid #dee2e6;
    padding: 8px 12px;
    text-align: left;
    vertical-align: middle;
    font-size: 0.7rem; /* Ukuran font diperkecil untuk semua sel data dan header */
}

.evaluation-table thead th {
    background-color: #e9ecef;
    font-weight: bold;
    color: #495057;
    white-space: nowrap; /* Prevent header text from wrapping */
}

.evaluation-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.evaluation-table tbody tr:hover {
    background-color: #e2f2ff;
}

/* Specific cell styling for status and values */
/* --- PERUBAHAN DI SINI: Meningkatkan spesifisitas CSS --- */
.evaluation-table .status-ok {
    color: #28a745; /* Hijau */
    font-weight: bold;
}

.evaluation-table .status-not-ok {
    color: #dc3545; /* Merah */
    font-weight: bold;
}
/* --- AKHIR PERUBAHAN --- */

.ave-value-cell.not-ok-value {
    color: #dc3545; /* Merah */
    font-weight: bold;
}

/* Table Responsive and Vertical Scroll */
.table-responsive {
    overflow-x: auto; /* Horizontal scroll for the entire table if needed */
}

.table-vertical-scroll {
    max-height: 400px; /* Ketinggian maksimum untuk scroll vertikal */
    overflow-y: auto;
    border: 1px solid #dee2e6; /* Border agar terlihat seperti bagian dari tabel */
}

/* Ensure table headers are sticky if you want them to stay visible during vertical scroll */
.table-vertical-scroll table thead th {
    position: sticky;
    top: 0;
    background-color: #e9ecef; /* Match header background */
    z-index: 1; /* Ensure header stays above scrolling content */
}


/* Tab Styling */
.tab-headers-container {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 15px;
    padding-left: 0; /* Remove default padding */
}

.tab-button {
    background-color: #e9ecef;
    border: 1px solid #dee2e6;
    border-bottom: none;
    padding: 8px 15px;
    cursor: pointer;
    margin-right: 5px;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px; /* Space between text and close button */
}

.tab-button:hover {
    background-color: #d6eaff;
    color: #0056b3;
}

.tab-button.active {
    background-color: #fff;
    border-color: #007bff;
    border-bottom-color: #fff;
    color: #007bff;
    font-weight: bold;
}

.tab-close-button {
    background: none;
    border: none;
    color: #6c757d;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    transition: color 0.2s ease;
}

.tab-close-button:hover {
    color: #dc3545;
}

.tab-contents-container {
    border: 1px solid #dee2e6;
    border-top: none;
    padding: 15px;
    min-height: 200px;
    background-color: #fff;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.preview-excel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.preview-excel-table th,
.preview-excel-table td {
    border: 1px solid #e9ecef;
    padding: 6px 10px;
    text-align: left;
    white-space: nowrap; /* Keep cells in one line */
    overflow: hidden;
    text-overflow: ellipsis; /* Show ellipsis for overflowed text */
    max-width: 150px; /* Limit cell width */
}

.preview-excel-table thead th {
    background-color: #f8f9fa;
    font-weight: bold;
    color: #495057;
    position: sticky; /* Make headers sticky for horizontal scroll */
    top: 0;
    z-index: 1;
}

/* Chart Container */
.chart-container {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 5px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #6c757d;
    font-style: italic;
}

/* Notification Styling */
.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 10px 20px;
    border-radius: 5px;
    z-index: 1050; /* Above modals */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 250px;
    text-align: center;
}

.notification.show {
    opacity: 1;
    visibility: visible;
}

.notification.success { background-color: #28a745; }
.notification.error { background-color: #dc3545; }
.notification.warning { background-color: #ffc107; color: #333; }
.notification.info { background-color: #17a2b8; }

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1040; /* Below notification, above content */
    display: none; /* Hidden by default */
    flex-direction: column;
    color: #fff;
    font-size: 1.2rem;
}

.loading-spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Confirmation Dialog */
.confirmation-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1030;
    display: none; /* Hidden by default */
}

.confirmation-overlay.show {
    display: flex;
}

.confirmation-dialog {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.confirmation-dialog h3 {
    color: #34495e;
    margin-bottom: 20px;
}

.confirmation-dialog p {
    margin-bottom: 30px;
    color: #555;
}

.confirmation-buttons button {
    margin: 0 10px;
    min-width: 80px;
}

/* Utility Classes */
.text-muted {
    color: #6c757d !important;
}

.text-info {
    color: #17a2b8 !important;
}

.error {
    color: #dc3545;
    font-weight: bold;
}

/* FOOTER */
footer {
  background-color: #002147;
  color: white;
  text-align: right;
  padding: 0.4rem 1.2rem; /* Padding lebih kecil */
  font-size: 0.85rem; /* Ukuran font lebih kecil */
  box-shadow: 0 -1px 4px rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.footer-container {
  max-width: 1850px;
  margin: 0 auto;
  text-align: right;
}
/* --- END: CSS untuk Footer --- */
/* --- CSS UNTUK GRID 9 CHART --- */
.charts-grid-layout {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    width: 100%;
    margin-top: 20px;
}

.chart-card-report {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 10px;
    height: 300px;
    display: flex;
    flex-direction: column;
}

.chart-canvas-wrapper {
    flex-grow: 1;
    position: relative;
    min-height: 0;
}

@media (max-width: 1200px) { .charts-grid-layout { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 768px) { .charts-grid-layout { grid-template-columns: 1fr; } }
/* ============================================================
   CSS KHUSUS PRINT PDF - ABSOLUTE PAGE BREAK
   ============================================================ */

body.is-printing {
    background: #ffffff !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden !important;
}

/* Sembunyikan UI */
body.is-printing .sidebar-left,
body.is-printing header,
body.is-printing footer,
body.is-printing .tab-headers-container,
body.is-printing #resetZoomButton,
body.is-printing .nav-tabs {
    display: none !important;
}

/* --- SEMBUNYIKAN LOADING OVERLAY SAAT MENCETAK --- */
body.is-printing .loading-overlay, /* Contoh jika classnya 'loading-overlay' */
body.is-printing #loadingOverlay,  /* Contoh jika id-nya 'loadingOverlay' */
body.is-printing .your-specific-loading-element-class-or-id { /* Ganti ini dengan selector yang tepat */
    display: none !important;
}
/* --- AKHIR TAMBAHAN --- */


/* KONTROL AREA UTAMA */
body.is-printing .main-report-content-area {
    width: 100% !important;
    margin: 0 auto !important;
    padding: 0 !important;
    display: block !important;
    position: relative !important;
    background: #fff !important;
}

/* --- FORCE PAGE BREAK CLASS --- */
body.is-printing .pdf-page-break {
    page-break-before: always !important;
    break-before: page !important;
    display: block !important;
    clear: both !important;
    padding-top: 10mm !important; /* Jarak dari pinggir atas kertas baru */
}

body.is-printing .report-section {
    display: block !important;
    width: 100% !important;
    clear: both !important;
    padding: 0 5mm !important; /* Padding untuk memberi ruang pada konten */
    box-sizing: border-box !important;
}

/* Mencegah Judul Terpisah */
body.is-printing h3,
body.is-printing .section-title {
    page-break-after: avoid !important;
    margin-top: 0 !important;
    margin-bottom: 20px !important;
    display: block !important;
    clear: both !important;
}

/* --- OPTIMASI TABEL (ANTI-OVERLAP) --- */
body.is-printing .table-responsive {
    display: block !important;
    width: 100% !important;
    overflow: visible !important; /* Memaksa tabel mendorong elemen di bawahnya */
    height: auto !important;
    max-height: none !important;
    clear: both !important;
}

body.is-printing .preview-excel-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-bottom: 30px !important;
    table-layout: fixed !important; /* Tetap fixed untuk tabel pertama */
}

body.is-printing .preview-excel-table th,
body.is-printing .preview-excel-table td {
    font-size: 5pt !important; /* Mengurangi ukuran font lebih lanjut */
    padding: 1px 0.5px !important; /* Mengurangi padding sel lebih lanjut */
    border: 0.5pt solid #ccc !important;
    word-break: break-all !important; /* Memastikan teks panjang tidak keluar dari sel */
}

/* --- OPTIMASI TABEL EVALUASI (TABEL KEDUA) --- */
body.is-printing .evaluation-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-bottom: 15px !important; /* Diubah: Mengurangi margin bawah */
    table-layout: auto !important; /* <--- DIUBAH: Kolom menyesuaikan konten */
}

body.is-printing .evaluation-table th,
body.is-printing .evaluation-table td {
    font-size: 7.5pt !important; /* Diubah: Sedikit mengurangi ukuran font (dari 8pt) */
    padding: 5px !important; /* Diubah: Sedikit mengurangi padding (dari 8px) */
    border: 0.5pt solid #ccc !important;
    vertical-align: top !important; /* Pastikan konten sel rata atas */
    word-wrap: break-word !important; /* Memastikan teks panjang di sel bisa pecah baris */
}


/* --- OPTIMASI GRAFIK (MENJADI 1 KOLOM) --- */
body.is-printing .charts-grid-layout {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    clear: both !important;
}

body.is-printing .chart-card-report {
    display: block !important;
    width: 96% !important;
    margin: 2% auto 20px auto !important;
    page-break-inside: avoid !important;
    border: 0.1pt solid #eee !important;
    background: #fff !important;
    vertical-align: top !important;
    box-sizing: border-box !important;
}

body.is-printing .chart-canvas-wrapper {
    height: auto !important;
    min-height: 250px !important;
    width: 100% !important;
}

body.is-printing canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 400px !important;
}
/* Styling untuk header laporan dengan logo (Judul Utama) */
.report-header-with-logo {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Tetap space-between untuk memisahkan judul dan logo */
    margin-bottom: 1rem;
}

.report-header-with-logo h1 {
    margin-bottom: 0;
    flex-grow: 1; /* Memungkinkan judul mengambil ruang yang tersedia */
}

.report-logo {
    max-height: 45px; /* Tinggi logo utama */
    width: auto;
    margin-left: 10px; /* <--- Diperkecil: Kurangi jarak dari judul */
    margin-right: 10px; /* <--- Ditambahkan: Memberi buffer dari sisi kanan container flex */
}

/* Styling untuk header sub-bagian dengan logo */
.subsection-header-with-logo {
    display: flex;
    align-items: center;
    justify-content: space-between; /* Tetap space-between */
    margin-bottom: 1rem;
}

.subsection-header-with-logo h2 {
    margin-bottom: 0;
    flex-grow: 1;
}

.subsection-logo {
    max-height: 40px; /* Tinggi logo untuk sub-bagian */
    width: auto;
    margin-left: 10px; /* <--- Diperkecil: Kurangi jarak dari judul */
    margin-right: 10px; /* <--- Ditambahkan: Memberi buffer dari sisi kanan container flex */
}

/* Tambahan: Tambahkan padding di bagian atas area konten utama */
.main-report-content-area {
    padding-top: 20px !important; /* Memberi ruang di bagian atas */
}

/* Penyesuaian khusus untuk cetak (download PDF) */
@media print {
    .report-logo {
        max-height: 40px; /* Sedikit lebih kecil untuk tampilan cetak */
        margin-right: 8px; /* Sesuaikan margin kanan untuk cetak */
    }
    .subsection-logo {
        max-height: 30px; /* Sedikit lebih kecil untuk tampilan cetak */
        margin-right: 8px; /* Sesuaikan margin kanan untuk cetak */
    }
    .main-report-content-area {
        padding-top: 15px !important; /* Sesuaikan padding atas untuk cetak */
        padding-right: 30px !important; /* <--- PENTING: Tambah padding kanan untuk print */
        padding-left: 20px !important; /* Sesuaikan padding kiri juga jika perlu */
    }
}
