/* public_html/asset/css/sheet_manager.css */

/* --- Layout Umum --- */
/* Pastikan TIDAK ADA blok .bottom-sections di sini. */

.grafik-section,
.sheet-section {
    flex: 1; /* Membuat kedua bagian memiliki lebar yang sama dan mengisi sisa ruang */
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 15px; /* Padding di dalam setiap section (sekitar header dan konten) */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Pastikan konten tidak meluber */
    min-height: 0; /* Penting untuk flex items dalam column flex container */
    /* Opsional: Jika ingin membatasi tinggi total sheet-section, uncomment baris di bawah ini */
    /* max-height: 874px; */
}

.sheet-section .section-header {
    margin-bottom: 10px;
    flex-shrink: 0; /* Pastikan header section tidak menyusut */
}

.sheet-section .content-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Penting untuk flex items agar tidak melebihi ukuran konten */
}

/* Tabs Navigation */
.sheet-section .tabs-navigation {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 1px solid #ccc;
    background-color: #f8f8f8;
    border-radius: 5px 5px 0 0;
    flex-shrink: 0;
}

.sheet-section .tab-button {
    background-color: #e0e0e0;
    border: none;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.8em; /* Diperkecil dari 0.9em */
    font-weight: bold;
    color: #555;
    border-radius: 5px 5px 0 0;
    margin-right: 2px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.sheet-section .tab-button:hover {
    background-color: #d0d0d0;
}

.sheet-section .tab-button.active {
    border-bottom: 2px solid #0056b3;
    margin-bottom: -1px;
}

/* Tabs Content */
.sheet-section .tabs-content {
    flex-grow: 1;
    background-color: #fff;
    padding: 15px;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 5px 5px;
    position: relative;
    overflow: hidden;
    display: block;
    min-height: 0; /* Penting untuk flex items agar tidak melebihi ukuran konten */
    /* Jika Anda ingin membatasi tinggi konten tab dan mengaktifkan scroll vertikal,
       uncomment baris di bawah ini dan sesuaikan nilainya: */
    /* max-height: 784px; */
}

.sheet-section .tab-pane {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: none;
    overflow-y: auto; /* Pastikan scroll vertikal aktif jika konten melebihi tinggi */
    box-sizing: border-box;
}

.sheet-section .tab-pane.active {
    display: block;
}

/* Table Styling dalam tab-pane */
.sheet-section .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.6em; /* Disamakan dengan font-size header */
    white-space: nowrap;
}

/* --- Perubahan untuk memperkecil font header, mempertahankan tinggi baris, dan menghilangkan celah --- */
.sheet-section .data-table th,
.sheet-section .data-table td {
    border: 1px solid #ddd;
    padding: 6px 8px; /* Diperkecil dari 8px 10px */
    text-align: left; /* Default text-align untuk th */
    vertical-align: middle; /* Menengahkan konten secara vertikal */
    box-sizing: border-box; /* Memastikan padding dan border dihitung dalam total tinggi elemen */
}

/* Ukuran font untuk header */
.sheet-section .data-table th {
    font-size: 0.8em; /* Tetap 0.7em */
    background-color: #f2f2f2;
    font-weight: bold;
    position: sticky;
    z-index: 1;
}

/* Meratakan tengah header tabel Penerangan */
.sheet-section .data-table.penerangan-table th {
    text-align: center;
}

/* Meratakan tengah header tabel Pendingin */
.sheet-section .data-table.pendingin-table th {
    text-align: center;
}

/* Meratakan tengah header tabel Peralatan */
.sheet-section .data-table.peralatan-table th {
    text-align: center;
}

/* Meratakan tengah header tabel Jenis Alat */
.sheet-section .data-table.jenisalat-table th {
    text-align: center;
}

/* Meratakan tengah header tabel KiloWatt */
.sheet-section .data-table.kilowatt-table th {
    text-align: center;
}

/* Aturan ini akan meratakan tengah th dengan colspan di baris pertama,
   tapi aturan .peralatan-table th di atas akan lebih spesifik dan meratakan semua th di tabel tersebut */
.sheet-section .data-table thead tr:first-child th[colspan] {
    text-align: center;
}

/* Sticky header positions */
.sheet-section .data-table thead tr:first-child th {
    top: 0;
    z-index: 2;
}
.sheet-section .data-table thead tr:nth-child(2) th {
    top: 23px; /* Nilai top yang disesuaikan untuk menghilangkan celah */
    z-index: 2;
}

/* --- Rata tengah untuk data tabel (td), kecuali kolom pertama --- */
.sheet-section .data-table tbody td {
    text-align: center; /* Semua data di td rata tengah secara default */
}

.sheet-section .data-table tbody td:first-child {
    text-align: left; /* Kolom pertama (Nama Ruangan) kembali rata kiri */
}

/* --- Warna latar belakang baris yang berbeda untuk setiap tabel --- */

/* Default untuk semua tabel, baris ganjil tetap putih */
.sheet-section .data-table tbody tr:nth-child(odd) {
    background-color: #ffffff; /* Putih */
}

/* Penerangan: Merah muda/pastel */
.sheet-section .data-table.penerangan-table tbody tr:nth-child(even) {
    background-color: #FFEBEE; /* Light Pink */
}

/* Pendingin: Biru muda/pastel */
.sheet-section .data-table.pendingin-table tbody tr:nth-child(even) {
    background-color: #E3F2FD; /* Light Blue */
}

/* Peralatan: Kuning muda/pastel */
.sheet-section .data-table.peralatan-table tbody tr:nth-child(even) {
    background-color: #FFFDE7; /* Very Light Yellow */
}

/* Jenis Alat: Oranye muda/pastel */
.sheet-section .data-table.jenisalat-table tbody tr:nth-child(even) {
    background-color: #FFF3E0; /* Light Orange */
}

/* KiloWatt: Ungu muda/pastel */
.sheet-section .data-table.kilowatt-table tbody tr:nth-child(even) {
    background-color: #F3E5F5; /* Light Purple */
}

/* Aturan hover untuk semua tabel */
.sheet-section .data-table tr:hover {
    background-color: #f1f1f1; /* Warna abu-abu terang saat di-hover */
}

/* ToR: Cyan muda/pastel untuk baris genap */
.sheet-section .data-table.tor-table tbody tr:nth-child(even) {
    background-color: #E0F7FA; /* Light Cyan, warna yang sama dengan background tab ToR */
}

/* Meratakan tengah header tabel ToR (tanpa mengubah warna background atau teksnya) */
.sheet-section .data-table.tor-table th {
    text-align: center;
}


/* =================================================================================================
   CSS BARU UNTUK FUNGSI ZOOM GRAFIK (FINAL REVISI UNTUK TAMPILAN)
   ================================================================================================= */

/* Gaya untuk header bagian grafik */
.grafik-section .section-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between; /* <-- PERUBAHAN: Ini akan mendorong header-left-group ke kiri dan chart-controls-wrapper ke kanan */
}

/* NEW: Gaya untuk grup kiri (icon + H2 + tombol zoom) */
.grafik-section .section-header .header-left-group {
    display: flex;
    align-items: center;
    gap: 15px; /* Jarak antara icon dan H2 */
    /* margin-right: auto; <-- DIHAPUS, karena justify-content: space-between sudah menangani */
}

/* Gaya untuk kontainer tombol kontrol grafik (radio buttons) */
.grafik-section .section-header .radio-group {
    display: flex;
    gap: 20px; /* Jarak antara radio button */
    align-items: center;
}

/* Gaya untuk label radio button */
.grafik-section .section-header .radio-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.8em;
    color: #333;
    position: relative; /* Diperlukan untuk penempatan radio kustom */
    padding-left: 20px; /* Ruang untuk radio button kustom */
    user-select: none; /* Mencegah seleksi teks */
}

/* Sembunyikan radio button bawaan browser */
.grafik-section .section-header .radio-label input[type="radio"].chart-radio,
.grafik-section .section-header .radio-label input[type="radio"].chart-radio-main {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Gaya untuk tampilan radio button kustom (lingkaran luar) */
.grafik-section .section-header .radio-custom {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 12px; /* Ukuran lingkaran luar */
    width: 12px; /* Ukuran lingkaran luar */
    background-color: #eee;
    border-radius: 50%; /* Membuat lingkaran sempurna */
    border: 2px solid #ccc;
    transition: all 0.2s ease;
}

/* Saat label di-hover, ubah warna latar belakang lingkaran luar */
.grafik-section .section-header .radio-label:hover input[type="radio"].chart-radio ~ .radio-custom,
.grafik-section .section-section .header-left-group .radio-label:hover input[type="radio"].chart-radio-main ~ .radio-custom {
    background-color: #ccc;
}

/* Saat radio button terpilih, ubah warna lingkaran luar menjadi biru */
.grafik-section .section-header .radio-label input[type="radio"].chart-radio:checked ~ .radio-custom,
.grafik-section .section-header .radio-label input[type="radio"].chart-radio-main:checked ~ .radio-custom {
    background-color: #2196F3; /* Biru */
    border-color: #2196F3;
}

/* Buat lingkaran dalam (indikator) */
.grafik-section .section-header .radio-custom:after {
    content: "";
    position: absolute;
    display: none; /* Sembunyikan secara default */
}

/* Tampilkan indikator (titik) saat radio button terpilih */
.grafik-section .section-header .radio-label input[type="radio"].chart-radio:checked ~ .radio-custom:after,
.grafik-section .section-header .radio-label input[type="radio"].chart-radio-main:checked ~ .radio-custom:after {
    display: block;
}

/* Gaya untuk indikator (titik dalam) */
.grafik-section .section-header .radio-custom:after {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Pusatkan titik */
    width: 8px; /* Ukuran titik */
    height: 8px; /* Ukuran titik */
    border-radius: 50%;
    background: white; /* Warna titik */
}

/* Memastikan kontainer grafik mengambil lebar penuh dan tinggi yang sesuai */
.grafik-section .content-area > div { /* Target the wrapper divs for charts */
    width: 100%;
    height: 450px; /* Tinggi tetap untuk grafik */
    margin-bottom: 20px; /* Jarak antar grafik jika keduanya terlihat (meskipun hanya satu yang akan terlihat) */
}

/* Gaya untuk tombol zoom/unzoom */
#zoomChartButton {
    padding: 5px 8px; /* Padding untuk tombol ikon */
    font-size: 1.1em; /* Ukuran ikon */
    border-radius: 4px;
    margin-left: 10px; /* <-- PERUBAHAN: Jarak antara teks GRAFIK dan tombol */
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    color: #555;
    cursor: pointer;
    display: inline-flex; /* Untuk menengahkan ikon di dalam tombol */
    align-items: center;
    justify-content: center;
}

#zoomChartButton:hover {
    background-color: #e0e0e0;
    border-color: #bbb;
}


/* Kelas untuk kontainer grafik saat di-zoom */
.chart-fullscreen-mode {
    position: fixed;
    top: 60px; /* <-- PERUBAHAN: Dimulai di bawah header fixed (asumsi tinggi header 60px) */
    left: 0;
    width: 100vw;
    height: calc(100vh - 60px); /* <-- PERUBAHAN: Mengambil sisa tinggi viewport */
    background-color: rgba(255, 255, 255, 0.98);
    z-index: 1000;
    display: flex;
    justify-content: center; /* <-- PERUBAHAN: Menengahkan grafik secara horizontal */
    align-items: center;     /* <-- PERUBAHAN: Menengahkan grafik secara vertikal */
    padding: 20px; /* Memberikan padding di sekitar grafik yang sudah di tengah */
    box-sizing: border-box;
    overflow: auto;
}

/* Atur ulang ukuran elemen chart di dalam mode fullscreen */
.chart-fullscreen-mode > canvas,
.chart-fullscreen-mode > div > canvas {
    /* <-- PERUBAHAN: Hapus width: 95% !important; dan height: 95% !important; */
    max-width: 100%; /* <-- PERUBAHAN: Jangan melebihi lebar kontainer */
    max-height: 100%; /* <-- PERUBAHAN: Jangan melebihi tinggi kontainer */
    width: auto;    /* <-- PERUBAHAN: Biarkan Chart.js menentukan lebar optimal */
    height: auto;   /* <-- PERUBAHAN: Biarkan Chart.js menentukan tinggi optimal */
    display: block;
    /* max-width: 1200px; */ /* Anda bisa mempertahankan ini jika ingin batasan ukuran absolut */
    /* max-height: 800px; */ /* Anda bisa mempertahankan ini jika ingin batasan ukuran absolut */
}

/* Jika Anda ingin menyembunyikan sidebar atau header saat zoom */
body.chart-zoomed .sidebar,
body.chart-zoomed .header,
body.chart-zoomed .bottom-sections .sheet-section {
    display: none !important;
}

/* Pastikan section-header tetap terlihat saat zoom untuk tombol unzoom */
body.chart-zoomed .grafik-section .section-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #f8f9fa;
    padding: 10px 20px;
    z-index: 1001;
    display: flex;
    justify-content: flex-end; /* <-- PERUBAHAN: Dorong tombol ke kanan */
    align-items: center;
    border-bottom: 1px solid #eee;
}

/* Ketika di-zoom, pastikan hanya tombol zoom (yang sekarang berfungsi sebagai unzoom) yang terlihat di header fixed */
body.chart-zoomed .grafik-section .section-header #zoomChartButton {
    display: inline-flex !important; /* Pastikan tombol terlihat */
    margin-left: auto !important; /* <-- PERUBAHAN: Dorong tombol ke kanan */
    /* Sesuaikan gaya jika tombol unzoom di header fixed ingin terlihat berbeda */
    padding: 8px 12px;
    font-size: 1.2em;
}

/* Sembunyikan elemen lain di header grafik saat di-zoom */
body.chart-zoomed .grafik-section .section-header .header-left-group {
    display: none !important; /* <-- PERUBAHAN: Ini akan menyembunyikan judul "GRAFIK" */
}

body.chart-zoomed .grafik-section .section-header .chart-controls-wrapper {
    display: none !important; /* <-- PERUBAHAN: Ini akan menyembunyikan radio buttons */
}

/* Sesuaikan padding body agar konten tidak tersembunyi di bawah header fixed */
body.chart-zoomed {
    padding-top: 60px; /* <-- PERUBAHAN: Sesuaikan dengan tinggi header fixed Anda */
    overflow: hidden; /* Mencegah scroll pada body utama */
}
