/* =========================================
   1. GLOBAL STYLE (DASAR)
   ========================================= */
* { 
    box-sizing: border-box; 
    font-family: 'Segoe UI', Poppins, sans-serif; 
}

body { 
    background-color: #eef2f5; 
    margin: 0; 
    /* Jarak atas untuk Navbar */
    padding-top: 90px; 
    padding-bottom: 40px;
    
    /* --- PERBAIKAN UTAMA DI SINI --- */
    display: flex; 
    flex-direction: column; /* Menyusun elemen dari Atas ke Bawah */
    align-items: center;    /* Membuat elemen berada di Tengah (Center) */
    min-height: 100vh;
}

/* =========================================
   2. NAVBAR (MENU ATAS)
   ========================================= */
.toolbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: white;
    height: auto;
    min-height: 60px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 30px;
    z-index: 1000;
}

.toolbar-title {
    font-weight: bold;
    color: #333;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Style Tombol */
button, .btn {
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    white-space: nowrap; /* Teks tombol tidak turun baris */
}

.btn-back { background: #f1f3f5; color: #333; }
.btn-back:hover { background: #e9ecef; }

.btn-print { background: #17a2b8; color: white; }
.btn-print:hover { background: #138496; }

.btn-save { background: #28a745; color: white; }
.btn-save:hover { background: #218838; }

/* =========================================
   3. KERTAS KERJA (LAYOUT UTAMA)
   ========================================= */
.paper {
    background: white;
    width: 210mm;       /* Lebar A4 Standar */
    min-height: 297mm;  /* Tinggi A4 Standar */
    padding: 20mm;      /* Margin Kertas */
    box-shadow: 0 0 20px rgba(0,0,0,0.08);
    border-radius: 8px;
    position: relative;
}

/* Header Kop Surat */
.agenda-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 3px double #333;
    padding-bottom: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.agenda-header h1 { margin: 0; font-size: 24px; text-transform: uppercase; color: #2c3e50; }
.agenda-header h2 { margin: 5px 0 0; font-size: 16px; color: #7f8c8d; }

.info-table td {
    padding: 3px 10px;
    font-size: 13px;
    border: none !important;
    text-align: left;
}

/* Judul Per Bagian */
.section-title {
    font-size: 15px;
    font-weight: bold;
    color: #2c3e50;
    border-left: 4px solid #007bff;
    padding-left: 10px;
    margin: 20px 0 10px 0;
    text-transform: uppercase;
}

/* =========================================
   4. TABEL & INPUT
   ========================================= */
/* Wrapper ini agar tabel bisa di-scroll di HP */
.table-responsive {
    width: 100%;
    overflow-x: auto; 
    margin-bottom: 10px;
}

table.main-table {
    width: 100%;
    border-collapse: collapse;
    /* PENTING: Di Desktop jangan pakai min-width agar tidak gepeng */
}

.main-table th {
    background-color: #f8f9fa;
    color: #495057;
    font-weight: 600;
    font-size: 12px;
    padding: 10px 5px;
    border: 1px solid #dee2e6;
    white-space: nowrap;
}

.main-table td {
    border: 1px solid #dee2e6;
    padding: 5px;
    vertical-align: middle;
}

/* Inputan agar terlihat bersih */
.input-plain {
    width: 100%;
    min-width: 60px; /* Minimal lebar input */
    border: 1px solid transparent;
    padding: 6px;
    border-radius: 4px;
    font-size: 13px;
    transition: 0.2s;
}

.input-plain:hover { background-color: #f8f9fa; }
.input-plain:focus { 
    border-color: #80bdff; 
    background-color: white; 
    outline: none; 
}

/* =========================================
   5. LAYOUT BAWAH (SPLIT KIRI - KANAN)
   ========================================= */
.split-section { 
    display: flex; 
    gap: 30px;      /* Jarak antar kolom kiri dan kanan */
    margin-top: 20px; 
}

.left-panel { flex: 6; } /* Panel Kiri (Absen) mengambil 60% lebar */
.right-panel { flex: 4; display: flex; flex-direction: column; gap: 20px; } /* Panel Kanan 40% */

/* Kotak Tanda Tangan */
.sig-box {
    border: 1px dashed #ccc;
    background: #fafafa;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}
.sig-box p { margin: 0 0 5px; font-weight: bold; font-size: 13px; color: #555; }

canvas { 
    border: 1px solid #ddd !important; 
    background: white; 
    border-radius: 4px;
    cursor: crosshair;
    width: 100% !important; /* Agar canvas pas dengan kotak */
}

/* Tombol Kecil Tambahan */
.btn-clear {
    background: white;
    border: 1px solid #dc3545;
    color: #dc3545;
    font-size: 11px;
    padding: 3px 8px;
    margin-top: 5px;
}
.btn-clear:hover { background: #dc3545; color: white; }

.btn-add-row {
    width: 100%;
    background: #e9ecef;
    color: #495057;
    padding: 8px;
    margin-top: 5px;
    border: 1px dashed #ced4da;
}
.btn-add-row:hover { background: #dee2e6; }

/* =========================================
   6. RESPONSIF HP (MEDIA QUERY)
   ========================================= */
@media screen and (max-width: 768px) {
    body { padding-top: 100px; padding-bottom: 20px; }

    /* Navbar jadi susun bawah */
    .toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 15px;
    }
    .toolbar-actions { width: 100%; justify-content: space-between; }
    .toolbar-actions .btn { flex: 1; justify-content: center; }

    /* Kertas menyesuaikan layar HP */
    .paper {
        width: 95%;       /* Lebar hampir penuh layar */
        height: auto;
        min-height: auto;
        padding: 15px;    /* Padding diperkecil */
        box-shadow: none;
    }

    .agenda-header { flex-direction: column; gap: 10px; }

    /* Layout Bawah jadi Susun Bawah (Stack) */
    .split-section { 
        flex-direction: column; 
        gap: 40px; 
    }
    .left-panel, .right-panel { width: 100%; flex: none; }

    /* KHUSUS HP: Tabel dipaksa lebar agar bisa discroll */
    table.main-table {
        min-width: 600px; 
    }
}

/* =========================================
   8. KHUSUS MODE CETAK (PRINT) - REVISI
   ========================================= */
@media print {
    /* 1. Sembunyikan Elemen Pengganggu */
    .toolbar,             /* Menu Atas */
    .filter-container,    /* Kotak Pilih Tanggal */
    .filter-bar,
    .btn, button,         /* Semua Tombol */
    .no-print {           /* Elemen bertanda no-print */
        display: none !important;
    }

    /* 2. Reset Halaman Putih Bersih */
    body, html {
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100%;
        height: auto;
        /* Hilangkan padding top body yang dipakai navbar */
        padding-top: 0 !important; 
    }

    /* 3. Atur Kertas agar Pas A4 */
    .paper {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important; /* Hilangkan padding agar muat banyak */
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
    }

    /* 4. Pertegas Garis Tabel (Agar Jelas saat dicetak) */
    .table-responsive {
        overflow: visible !important;
    }

    table.main-table {
        width: 100% !important;
        border: 2px solid #000; /* Garis luar lebih tebal */
    }

    .main-table th, 
    .main-table td {
        border: 1px solid #000 !important; /* Paksa garis hitam pekat */
        color: #000 !important;            /* Teks hitam pekat */
        padding: 4px !important;           /* Hemat tempat */
    }

    /* 5. Layout Bawah Tetap Sejajar (Kiri Kanan) */
    .split-section {
        display: flex !important;
        flex-direction: row !important; /* Paksa jejer ke samping */
        gap: 20px !important;
        margin-top: 10px !important;
        page-break-inside: avoid;       /* Jangan potong halaman di tengah */
    }
    
    .left-panel { flex: 6 !important; width: 60%; }
    .right-panel { flex: 4 !important; width: 40%; }

    /* 6. Rapikan Input & Tanda Tangan */
    .input-plain {
        border: none !important; /* Hilangkan kotak input */
        padding: 0 !important;
    }
    
    .badge {
        border: 1px solid #000; /* Tambah garis pinggir di status absen */
        color: #000 !important; /* Warna teks hitam biar hemat tinta */
        background: transparent !important; /* Hilangkan warna background */
    }

    canvas, img {
        border: 1px solid #000 !important; /* Kotak TTD tetap ada garisnya */
    }
    
    /* Hilangkan background kotak TTD */
    .sig-box {
        background: none !important;
        border: none !important;
    }
}
/* --- TAMBAHAN KHUSUS RIWAYAT (Letakkan di paling bawah style.css) --- */

.filter-container {
    width: 100%;
    max-width: 210mm; /* Maksimal selebar kertas A4 */
    margin: 0 auto 20px auto; /* Posisi tengah */
}

.filter-bar {
    background: #fff;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border: 1px solid #dfe6e9;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap; /* Agar elemen turun ke bawah jika layar sempit */
}

.filter-bar label { font-weight: 600; color: #2d3436; }

.filter-bar input[type="date"] {
    padding: 8px 12px;
    border: 1px solid #b2bec3;
    border-radius: 6px;
    font-size: 14px;
    color: #2d3436;
    outline: none;
    transition: border 0.3s;
}
.filter-bar input[type="date"]:focus { border-color: #0984e3; }

.filter-hint { font-size: 13px; color: #636e72; font-style: italic; }

/* Status Label di Tabel Riwayat */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}
.badge-hadir { background: #e3fcef; color: #00b894; }
.badge-sakit { background: #fff7d6; color: #fdcb6e; }
.badge-izin  { background: #e0f7fa; color: #00cec9; }
.badge-alpha { background: #ffeaa7; color: #d63031; background: #ffe6e6; }

/* FIX RESPONSIVE KHUSUS RIWAYAT */
@media screen and (max-width: 768px) {
    .filter-container {
    width: 100%;
    max-width: 210mm; /* Samakan lebarnya dengan kertas A4 */
    margin-bottom: 20px; /* Beri jarak dengan kertas di bawahnya */
    box-sizing: border-box;
}
    
    .filter-bar { 
        flex-direction: column; 
        align-items: flex-start; 
        width: 100%; 
    }
    
    .filter-bar input[type="date"] { width: 100%; }
}