/* --- Global & Layout --- */
html, body {
    height: 100%; 
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    background-color: #f4f6f9; 
    color: #34495e; 
    position: relative; /* Make body a positioning context for its absolute children */
    width: 100vw;
    overflow: hidden; /* Mencegah scrolling pada body di desktop/tablet */
    font-size: 14px; /* Default font size for desktop */
}

.app-layout {
    display: flex; /* Keep flex for internal layout (sidebar + main content) */
    width: 100%;
    height: 100%;
    position: absolute; /* Position absolutely within body */
    top: 0;
    left: 0;
    /* transition: opacity 0.3s ease; */ /* Optional: for fading between views */
}

/* --- Sidebar (Navigasi TAB) --- */
.sidebar {
    width: 240px;
    background-color: #2c3e50; 
    color: #ecf0f1; 
    display: flex; /* Default: terlihat di desktop */
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0; 
    height: 100%; 
    position: relative; 
}

.sidebar-header {
    padding: 0 20px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.sidebar-header .logo {
    width: 40px;
    height: 40px;
}

.sidebar-header .title-group {
    display: flex;
    flex-direction: column;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 18px; /* Default size for h3 in sidebar header */
    font-weight: 600;
}

.credit {
    font-size: 12px; /* Default size for credit */
    color: #e84393; 
    font-weight: bold;
    margin: 4px 0 0;
}

.tab-navigation {
    display: flex;
    flex-direction: column;
    gap: 5px; 
    flex-grow: 0; /* DIUBAH: Mengatur flex-grow ke 0 agar tidak mengambil ruang ekstra */
}

/* Penyesuaian pada .tab-button */
.tab-button {
    background-color: transparent;
    border: none;
    color: #bdc3c7; 
    padding: 15px 25px;
    text-align: left;
    font-size: 15px; /* Default size for tab buttons */
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 4px solid transparent; /* TETAPKAN border-left untuk desktop sidebar */
    display: block; 
    width: 100%; 
    box-sizing: border-box; 
    text-decoration: none; 
}

.tab-button:hover {
    background-color: #34495e; 
    color: #ffffff;
}

.tab-button.active {
    background-color: #34495e;
    color: #ffffff;
    border-left: 4px solid #e84393; /* TETAPKAN border-left untuk desktop sidebar */
}

/* Posisi Tombol Generate Desktop */
.sidebar-action {
    padding: 20px;
    margin-top: 20px; /* Menambahkan margin bawah untuk jarak dari tombol generate */
    flex-shrink: 0; 
    position: relative; 
    bottom: auto; 
    left: auto; 
    right: auto; 
    display: block; /* Pastikan terlihat di desktop */
}


/* Untuk memastikan ada ruang di sidebar untuk tombol absolut */
.sidebar {
    padding-bottom: 20px; /* Kembali ke padding-bottom awal */
}


.sidebar-footer {
    /* Dikosongkan karena kredit dipindah ke atas */
}

/* --- Main Content --- */
.main-content {
    flex: 1; /* Pastikan mengambil ruang yang tersedia */
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Allow scrolling within main content */
    background-color: #f4f6f9; /* Background untuk melihat area main-content */
}

.content-wrapper {
    flex: 1; /* Pastikan mengambil ruang yang tersedia */
    padding: 0; /* Changed from 25px to 0 */
    overflow-y: auto; /* Pastikan ini ada untuk scrolling konten */
    flex-grow: 1; 
    position: relative; 
    display: block; 
}

/* Header baru untuk mobile/tablet */
.main-header {
    display: none; /* DEFAULT GLOBAL: tersembunyi */
    padding: 15px 25px;
    background-color: #2c3e50;
    color: #ecf0f1;
    text-align: center; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    align-items: center; 
    justify-content: center; 
    flex-direction: column; 
    gap: 5px; 
    width: 100%; 
    box-sizing: border-box; 
    flex-shrink: 0; 
}

.main-header .title-group {
    width: 100%; 
    text-align: center; 
}


.main-header .title-group h3 {
    margin: 0;
    font-size: 18px; /* Default size for h3 in mobile header */
    font-weight: 600;
}

.main-header .credit {
    font-size: 12px; /* Default size for credit in mobile header */
    color: #e84393;
    font-weight: bold;
    margin: 0;
}

/* KOREKSI PADA TAB CONTENT */
.tab-content {
    display: none; 
    width: 100%; 
    box-sizing: border-box; 
    position: relative; /* <-- DIUBAH dari unset ke relative */
    height: auto; 
    min-height: 0; 
    padding: 0; 
    overflow-y: visible; 
}

.tab-content.active {
    display: block !important; /* <-- Pastikan ini selalu tampil */
    position: relative; /* <-- DIUBAH dari unset ke relative */
    height: auto;
    min-height: 0; 
}


.card {
    background-color: #ffffff;
    border-radius: 8px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    margin-bottom: 25px;
}

.card h2 {
    font-size: 20px; /* Default size for h2 */
    color: #2c3e50;
    margin-top: 0;
    margin-bottom: 25px;
    border-bottom: 1px solid #ecf0f1;
    padding-bottom: 15px;
}

/* --- Form & Input Elements --- */
.input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.input-group { margin-bottom: 20px; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 8px; color: #34495e; }
input[type="text"], input[type="number"], input[type="date"], input[type="time"], textarea {
    width: 100%; box-sizing: border-box; padding: 12px;
    border: 1px solid #bdc3c7; border-radius: 6px; font-size: 14px; font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
}
input[type="text"]:focus, input[type="number"]:focus, input[type="date"]:focus, input[type="time"]:focus, textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}
input[type="file"] { margin-top: 5px; font-size: 14px; /* Default size for file input */ }

/* --- Tanda Tangan --- */
.signature-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 40px; justify-content: center; max-width: 600px; margin: 0 auto; }
.signature-box { display: flex; flex-direction: column; text-align: center; }
.signature-pad { border: 2px dashed #bdc3c7; border-radius: 6px; cursor: crosshair; height: 120px; }
.btn-clear {
    background-color: #ecf0f1; border: 1px solid #bdc3c7; border-radius: 4px; color: #34495e;
    cursor: pointer; font-size: 12px; /* Default size for clear button */ padding: 4px 8px; margin-top: 8px; width: 80px; align-self: center;
}
.btn-clear:hover { background-color: #bdc3c7; }

/* --- Tombol Generate --- */
.btn-generate {
    width: 100%;
    padding: 12px 20px;
    font-size: 15px; /* Default size for generate button */
    font-weight: bold;
    color: #fff;
    background: linear-gradient(45deg, #e84393, #d63031);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(232, 67, 147, 0.4);
    box-sizing: border-box;
}
.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(232, 67, 147, 0.5);
}

/* --- Custom Alert Modal Styles --- */
/* Ini adalah modal yang sudah ada di dashboard.js */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999; /* Ditingkatkan jauh lebih tinggi */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    width: 90%; /* Responsive width */
    max-width: 400px; /* Max width for desktop */
    transform: translateY(0); /* DIUBAH: Defaultnya sudah di posisi akhir */
    opacity: 0; /* DEFAULT: Tersembunyi */
    transition: transform 0.3s ease, opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Ensures rounded corners are visible */
    z-index: 10000; /* Ditingkatkan lebih tinggi dari backdrop */
}

.modal-backdrop.active .modal-content {
    transform: translateY(0); /* Pastikan tidak ada transform awal yang menyembunyikannya */
    opacity: 1; /* Pastikan opacity menjadi 1 (terlihat) */
}

.modal-header {
    background: linear-gradient(45deg, #e84393, #d63031);
    color: white;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.modal-title {
    font-size: 18px; /* Default size for modal title */
    font-weight: 700;
    margin: 0;
}

.modal-close-button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: transform 0.2s ease;
}

.modal-close-button:hover {
    transform: rotate(90deg);
}

.modal-body {
    padding: 20px;
    font-size: 14px; /* Default size for modal body text */
    color: #34495e;
    line-height: 1.6;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #ecf0f1;
    text-align: right;
    background-color: #f9f9f9;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    display: flex; /* Use flexbox for buttons */
    justify-content: flex-end; /* Align buttons to the right */
    gap: 10px; /* Space between buttons */
}

.modal-ok-button {
    background-color: #2ecc71; /* Green color for OK */
    color: white;
    border: none;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 15px; /* Default size for modal buttons */
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.modal-ok-button:hover {
    background-color: #27ae60;
    transform: translateY(-1px);
}


/* --- BOTTOM NAVIGATION BAR (MOBILE) --- */
.bottom-nav {
    display: none; /* DEFAULT GLOBAL: tersembunyi */
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px; /* Tinggi navigasi bawah */
    background-color: #2c3e50;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
    z-index: 999;
    align-items: center;
    justify-content: center; /* Menggunakan justify-content: center untuk memusatkan item */
    display: grid;
    /* Menentukan 5 kolom: 2 item, 1 tombol tengah, 2 item */
    grid-template-columns: 1fr 1fr auto 1fr 1fr; 
    gap: 0px; 
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1; /* Setiap item mengambil ruang yang sama */
    height: 100%;
    color: #bdc3c7;
    font-size: 10px; /* Default size for nav items */
    cursor: pointer;
    transition: color 0.3s ease, background-color 0.3s ease;
    text-decoration: none; /* Hapus underline jika menggunakan <a> */
    border: none;
    background: none;
    padding: 0; /* Reset padding default button */
}

.nav-item:hover {
    background-color: #34495e;
    color: #ffffff;
}

.nav-item.active {
    color: #e84393; /* Warna aktif */
    /* border-top: 4px solid #e84393; DIHAPUS, akan diatur di media query mobile */
}

/* Ikon Font Awesome */
.nav-item i {
    font-size: 22px; /* Ukuran ikon */
    margin-bottom: 4px;
    display: inline-block !important; /* Memastikan ikon terlihat */
}

/* Tombol generate di mobile: di tengah dan menonjol */
.bottom-nav .generate-btn-mobile {
    background: linear-gradient(45deg, #e84393, #d63031); /* Warna gradien seperti tombol generate desktop */
    color: white;
    height: 70px; /* Lebih tinggi dari item nav lain */
    width: 70px; /* Sama dengan tinggi untuk efek lingkaran/persegi */
    border-radius: 50%; /* Membuat lingkaran */
    transform: translateY(-20px); /* Menonjol ke atas */
    box-shadow: 0 4px 15px rgba(232, 67, 147, 0.4); /* Bayangan */
    flex-shrink: 0; 
    margin: 0; /* Reset margin */
    display: flex; /* Pastikan flex untuk ikon/teks di dalamnya */
    align-items: center;
    justify-content: center;
    position: relative; /* Menjadi konteks untuk positioning, overriding flex:1 */
    z-index: 1000; /* Pastikan di atas elemen lain di bottom nav */
    grid-column: 3; /* Menempatkannya di kolom ke-3 (tengah) dari grid */
    justify-self: center; /* Memusatkan di dalam kolom gridnya */
    align-self: center; /* Memusatkan secara vertikal di dalam kolom gridnya */
}

.bottom-nav .generate-btn-mobile:hover {
    transform: translateY(-22px); /* Sedikit lebih menonjol saat hover */
    box-shadow: 0 6px 18px rgba(232, 67, 147, 0.5);
    background: linear-gradient(45deg, #d63031, #e84393); /* Ubah gradien sedikit saat hover */
}

.bottom-nav .generate-btn-mobile i {
    font-size: 28px; /* Ukuran ikon lebih besar */
    margin-bottom: 0; /* Hapus margin bawah ikon */
}

.bottom-nav .generate-btn-mobile span {
    display: none; /* Sembunyikan teks "PDF" di tombol generate mobile */
}


/* --- MEDIA QUERIES --- */

/* Desktop View (MIN-WIDTH: 768px - mencakup tablet dan desktop besar) */
@media (min-width: 768px) {
    /* Tampilkan elemen desktop */
    .sidebar {
        display: flex !important; /* Sidebar terlihat */
    }
    .sidebar-action {
        display: block !important; /* Tombol generate desktop terlihat */
    }
    .sidebar-header {
        display: flex !important; /* Header sidebar terlihat */
    }
    .tab-navigation {
        display: flex !important; /* Navigasi tab sidebar terlihat */
    }
    /* Pastikan border-left untuk desktop sidebar */
    .tab-button.active {
        border-left: 4px solid #e84393 !important; 
        border-top: none !important; /* Pastikan border-top tidak muncul di desktop */
    }


    /* Sembunyikan elemen mobile */
    .main-header {
        display: none !important; /* Header utama mobile tersembunyi */
    }
    .bottom-nav {
        display: none !important; /* Bottom nav mobile tersembunyi */
    }

    /* Penyesuaian untuk tablet (768px - 1023px) */
    @media (max-width: 1023px) {
        body {
            font-size: 13px; /* Font size for tablet */
        }
        .sidebar {
            width: 180px; 
            padding: 15px 0;
        }

        .tab-button {
            padding: 12px 15px; 
            font-size: 15px; /* Tetap default */
        }

        .sidebar-header {
            padding: 0 15px;
            margin-bottom: 20px;
        }

        .sidebar-header .logo {
            width: 35px;
            height: 35px;
        }

        .sidebar-header h3 {
            font-size: 18px; /* Tetap default */
        }

        .content-wrapper {
            padding: 0; /* Changed from 15px to 0 */
        }

        .card {
            padding: 15px;
            margin-bottom: 15px;
        }

        /* Grid layouts bisa tetap 2 kolom atau jadi 1 kolom tergantung kebutuhan */
        .input-grid, .denomination-grid, .note-tables-grid, .upload-grid, .signature-grid {
            gap: 15px; 
            grid-template-columns: 1fr; 
        }

        /* Sesuaikan ukuran font untuk elemen form di tablet */
        label, input[type="text"], input[type="number"], input[type="date"], input[type="time"], textarea {
            font-size: 13px; /* Font size for tablet */
            padding: 10px;
        }

        .currency-prefix {
            font-size: 13px; /* Font size for tablet */
        }

        .btn-generate {
            font-size: 15px; /* Tetap default */
            padding: 10px 15px;
        }

        .note-table th, .note-table td {
            font-size: 12px; /* Font size for tablet */
            padding: 6px;
        }

        .denomination-table th, .denomination-table td {
            font-size: 12px; /* Font size for tablet */
        }

        .denomination-table input {
            font-size: 12px; /* Font size for tablet */
        }

        .result-row {
            font-size: 14px; /* Slightly smaller for tablet results */
        }

        .bold-result {
            font-size: 15px; /* Slightly smaller for tablet bold results */
        }
    }
}

/* Mobile View (Max-width: 767px) */
@media (max-width: 767px) {
    /* Sembunyikan elemen desktop */
    .desktop-only {
        display: none !important; 
    }

    /* Tampilkan elemen mobile */
    .main-header {
        display: flex !important; /* Tampilkan header utama di mobile */
        position: fixed; 
        top: 0;
        left: 0;
        width: 100%;
        z-index: 100; 
        padding-top: 15px; 
        padding-bottom: 15px;
    }

    .bottom-nav {
        display: grid !important; /* Tampilkan bottom nav di mobile */
        position: fixed; 
        bottom: 0;
        left: 0;
        width: 100%;
        height: 60px;
        z-index: 999;
    }

    body {
        flex-direction: column; 
        height: 100%; 
        overflow: hidden; 
        font-size: 12px; /* Font size for mobile */
    }

    .app-layout {
        flex-direction: column;
        height: 100%; 
    }

    /* Sidebar dan Tombol Generate Desktop tersembunyi di Mobile */
    .sidebar {
        display: none; 
    }
    .sidebar-action {
        display: none; 
    }
    .sidebar-header {
        display: none;
    }
    .tab-navigation {
        display: none;
    }

    .main-content {
        height: 100%; 
        padding-top: 60px; /* Beri ruang di atas konten agar tidak tertutup header fixed */
        padding-bottom: 0; 
        display: flex; 
        flex-direction: column; 
    }

    .content-wrapper {
        flex: 1; 
        padding: 0; /* Changed from 15px 10px to 0 */
        overflow-y: auto; 
        flex-grow: 1; 
        padding-bottom: 95px; /* Padding untuk footer di sini */
    }

    .card {
        padding: 15px;
        margin-bottom: 15px;
    }

    /* Semua grid menjadi satu kolom di mobile */
    .input-grid, .denomination-grid, .note-tables-grid, .upload-grid, .signature-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    /* Sesuaikan ukuran font untuk elemen form di mobile */
    label, input[type="text"], input[type="number"], input[type="date"], input[type="time"], textarea {
        font-size: 12px; /* Font size for mobile */
        padding: 10px;
    }

    .currency-prefix {
        font-size: 12px; /* Font size for mobile */
    }

    .btn-generate {
        font-size: 15px; /* Tetap default */
        padding: 10px 15px;
    }

    .note-table th, .note-table td {
        font-size: 11px; /* Font size for mobile tables (specific request) */
        padding: 6px;
    }

    .denomination-table th, .denomination-table td {
        font-size: 11px; /* Font size for mobile tables (specific request) */
    }

    .denomination-table input {
        font-size: 11px; /* Font size for mobile */
    }

    .result-row {
        font-size: 13px; /* Slightly smaller for mobile results */
    }

    .bold-result {
        font-size: 14px; /* Slightly smaller for mobile bold results */
    }

    /* Style untuk indikator aktif di atas ikon pada Bottom Nav Mobile */
    .nav-item {
        position: relative; /* Menjadi konteks untuk pseudo-element */
        /* Hapus border-left yang tidak diinginkan di mobile */
        border-left: none !important; 
    }

    .nav-item.active {
        /* Hapus border-left yang tidak diinginkan di mobile */
        border-left: none !important; 
    }

    .nav-item.active i {
        position: relative; /* Diperlukan agar pseudo-element diposisikan relatif terhadap ikon */
    }

    .nav-item.active i::before {
        content: '';
        position: absolute;
        top: -4px; /* Sesuaikan posisi vertikal di atas ikon */
        left: 50%;
        transform: translateX(-50%); /* Pusatkan horizontal */
        width: 30px; /* Lebar garis */
        height: 4px; /* Ketebalan garis */
        background-color: #e84393; /* Warna indikator */
        border-radius: 2px; /* Sedikit melengkung */
    }

    /* Sesuaikan tampilan modal untuk mobile */
    .modal-content {
        width: 95%; 
        margin: 0 10px;
    }
}

/* --- Gaya untuk Wrapper Waktu dan Zona Waktu --- */
.time-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0; /* Tidak ada jarak antar elemen */
}

.time-input-wrapper input[type="time"] {
    /* Hapus border-radius di sisi kanan agar menyatu */
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    /* Hapus border kanan agar tidak ada garis ganda */
    border-right: none;
}

#opnameTimezone {
    display: inline-flex;
    align-items: center;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    background-color: #ecf0f1; /* Warna latar abu-abu muda */
    border: 1px solid #bdc3c7;
    border-left: 1px solid #e0e0e0; /* Garis pemisah tipis */
    color: #2c3e50;
    /* Hapus border-radius di sisi kiri agar menyatu */
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-top-right-radius: 6px;
    border-bottom-right-radius: 6px;
    white-space: nowrap; /* Mencegah teks turun baris */
}

/* Penyesuaian untuk mobile agar padding dan font-size konsisten */
@media (max-width: 767px) {
    .time-input-wrapper input[type="time"],
    #opnameTimezone {
        padding: 10px;
        font-size: 12px;
    }
}