* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', sans-serif; background: #f4f6f9; display: flex; }
.sidebar {
    width: 230px; background: #1e293b; color: #fff; min-height: 100vh;
    padding: 20px 0; position: fixed;
}
.sidebar h2 { padding: 0 20px 20px; font-size: 18px; border-bottom: 1px solid #334155; }
.sidebar a { display: block; color: #cbd5e1; text-decoration: none; padding: 12px 20px; }
.sidebar a:hover { background: #334155; color: #fff; }
main { margin-left: 230px; padding: 25px; width: calc(100% - 230px); }
h1 { color: #1e293b; margin-bottom: 20px; }
.flash { padding: 12px; border-radius: 6px; margin-bottom: 15px; }
.flash.success { background: #d1fae5; color: #065f46; }
.flash.error { background: #fee2e2; color: #991b1b; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 15px; margin-bottom: 25px; }
.card { background: #fff; padding: 20px; border-radius: 10px; box-shadow: 0 2px 6px rgba(0,0,0,.05); }
.card h3 { font-size: 13px; color: #64748b; font-weight: 500; }
.card p { font-size: 28px; font-weight: 700; color: #1e293b; margin-top: 8px; }
table { width: 100%; background: #fff; border-collapse: collapse; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,.05); }
th, td { padding: 12px 15px; text-align: left; border-bottom: 1px solid #e2e8f0; font-size: 14px; }
th { background: #f8fafc; color: #475569; font-size: 12px; text-transform: uppercase; }
tr:hover { background: #f8fafc; }
.btn { display: inline-block; padding: 9px 16px; background: #2563eb; color: #fff; border-radius: 6px; text-decoration: none; font-size: 14px; border: none; cursor: pointer; }
.btn:hover { background: #1d4ed8; }
.btn-danger { background: #dc2626; } .btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
form.inline { display: inline; }
.form-box { background: #fff; padding: 25px; border-radius: 10px; max-width: 750px; box-shadow: 0 2px 6px rgba(0,0,0,.05); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 13px; color: #475569; margin-bottom: 5px; font-weight: 500; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #2563eb; }
.badge { padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge-tersedia { background: #d1fae5; color: #065f46; }
.badge-dipinjam { background: #dbeafe; color: #1e40af; }
.badge-rusak { background: #fee2e2; color: #991b1b; }
.badge-maintenance { background: #fef3c7; color: #92400e; }
.badge-disposal { background: #e5e7eb; color: #374151; }
.toolbar { display: flex; justify-content: space-between; margin-bottom: 15px; gap: 10px; align-items: center; }
.toolbar form { display: flex; gap: 10px; }
.toolbar input, .toolbar select { padding: 8px 12px; }
/* ===== Accordion Menu Group ===== */
.menu-group .menu-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.menu-group .menu-toggle .arrow {
    transition: transform 0.2s;
    font-size: 12px;
    color: #94a3b8;
}
.menu-group.open .menu-toggle .arrow {
    transform: rotate(90deg);
    color: #e2e8f0;
}

/* Submenu default: tertutup */
.menu-group .submenu {
    display: none;
    background: #0f172a;
    border-left: 3px solid #2563eb;
    margin-left: 12px;
}
.menu-group.open .submenu {
    display: block;
}

/* Link submenu (indent lebih dalam) */
.menu-group .submenu a {
    padding: 10px 20px 10px 28px;
    font-size: 13px;
    color: #cbd5e1;
    display: block;
}
.menu-group .submenu a:hover {
    background: #1e293b;
    color: #fff;
}

/* Link yang sedang aktif */
.menu-group .submenu a.active {
    background: #1e40af;
    color: #fff;
    font-weight: 600;
    border-left: 3px solid #60a5fa;
    padding-left: 25px;
}

/* =========================================
   RESPONSIVE DESIGN (MOBILE & TABLET)
   ========================================= */

/* Tombol Hamburger untuk HP */
.mobile-header {
    display: none;
    background: #1e293b;
    color: #fff;
    padding: 15px;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1000;
}
.mobile-header h1 { font-size: 16px; margin: 0; color: #fff; }
.btn-hamburger {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

/* Penyesuaian saat layar HP (< 768px) */
@media (max-width: 768px) {
    /* 1. Tampilkan Header HP */
    .mobile-header { display: flex; }

    /* 2. Sembunyikan sidebar ke samping (geser kiri) */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1001;
        padding-top: 60px; /* Beri ruang untuk tombol close */
    }

    /* Class bantuan untuk JS membuka sidebar */
    .sidebar.show {
        transform: translateX(0);
    }

    /* 3. Sesuaikan area konten utama */
    main {
        margin-left: 0;
        width: 100%;
        padding: 15px;
        padding-top: 70px; /* Beri jarak agar tidak tertutup header HP */
    }

    /* 4. Ubah Tabel menjadi Card (agar tidak terpotong) */
    table, thead, tbody, th, td, tr { 
        display: block; 
    }
        thead {
        display: none !important;
    }
    tr { 
        border: 1px solid #cbd5e1; 
        border-radius: 8px;
        margin-bottom: 15px;
        background: #fff;
        box-shadow: 0 2px 4px rgba(0,0,0,.05);
    }
    td { 
        border: none;
        border-bottom: 1px solid #e2e8f0; 
        position: relative;
        padding: 10px 10px 10px 40% !important; 
        text-align: left;
    }
    td:last-child { border-bottom: none; }
    td:before { 
        position: absolute;
        top: 10px;
        left: 10px;
        width: 35%; 
        padding-right: 10px; 
        white-space: nowrap;
        font-weight: 600;
        color: #64748b;
        font-size: 12px;
    }

    /* Beri label pada tabel (sesuaikan dengan aplikasi kamu) */
    /* Contoh untuk tabel barang: */
    td:nth-of-type(1):before { content: "QR"; }
    td:nth-of-type(2):before { content: "Kode"; }
    td:nth-of-type(3):before { content: "Nama"; }
    td:nth-of-type(4):before { content: "Kategori"; }
    td:nth-of-type(5):before { content: "Lokasi"; }
    td:nth-of-type(6):before { content: "Status"; }
    td:nth-of-type(7):before { content: "Kondisi"; }
    td:nth-of-type(8):before { content: "Aksi"; }

    /* 5. Form Grid jadi 1 Kolom */
    .form-grid { grid-template-columns: 1fr; }
    
    /* 6. Filter Bar (jika ada) */
    .filter-bar input,
    .filter-bar select { min-width: 100%; }
    
    /* 7. Sembunyikan tombol text panjang, jadikan ikon saja (opsional) */
    .btn { font-size: 13px; padding: 8px 12px; }
}

/* Khusus untuk kolom Aksi di mode HP */
@media (max-width: 768px) {
    /* 1. Matikan nowrap agar tombol boleh turun ke bawah */
    table td:last-child {
        white-space: normal !important;
    }

    /* 2. Ubah isi kolom aksi menjadi flexbox agar rapi */
    table td:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        justify-content: flex-start; /* <-- Ubah agar mulai dari kiri */
        align-items: center;
    }

    /* 3. Sesuaikan ukuran tombol agar tidak terlalu besar */
    table td:last-child .btn {
        flex: 1 1 auto; /* Biarkan tombol melebar otomatis */
        text-align: center;
        padding: 8px 10px;
    }
    
    /* 4. Sembunyikan label "Aksi" palsu di sebelah kiri */
    table td:last-child::before {
        display: none;
    }
}

/* Palu Godam: Sembunyikan Header Tabel di HP */
@media screen and (max-width: 768px) {
    /* Targetkan ke semua sel terakhir di tabel */
    table td:last-child {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        justify-content: center !important; /* Rata tengah agar seimbang */
        align-items: center !important;
        padding: 10px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Sembunyikan tulisan "AKSI" di kiri */
    table td:last-child::before {
        display: none !important;
    }

    /* Paksa semua link/tombol di dalamnya untuk melebar */
    table td:last-child .btn, 
    table td:last-child a {
        flex: 1 1 30% !important; /* Dibagi rata (sekitar 3 tombol per baris) */
        text-align: center !important;
        justify-content: center !important;
        padding: 10px 5px !important;
        font-size: 13px !important;
        margin: 0 !important;
        display: inline-flex !important;
        align-items: center;
    }
}

@media screen and (max-width: 768px) {
    .header-pc {
        display: none !important;
    }
        /* --- Perbaikan Tombol Aksi Atas (Filter Bar) di HP --- */
    .action-bar-top {
        justify-content: center !important;
    }
    
    .action-bar-top .btn {
        flex: 1 1 45% !important; /* Membagi tombol jadi 2 kolom */
        text-align: center;
        justify-content: center;
        padding: 10px 5px !important;
        font-size: 13px;
    }
}

/* ===== Penyesuaian Ikon Lucide ===== */
.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar a svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    color: #94a3b8; /* Warna ikon default */
    transition: color 0.2s;
}

/* Ikon berubah putih saat menu di-hover atau aktif */
.sidebar a:hover svg,
.sidebar a.active svg {
    color: #fff;
}

/* Khusus menu Master Data */
.menu-group .menu-toggle svg {
    width: 18px;
    height: 18px;
    margin-right: 0; 
}
.menu-group .submenu a svg {
    width: 16px;
    height: 16px;
}

/* Memperbaiki jarak ikon di menu Master Data */
.menu-group .menu-toggle span {
    display: flex;
    align-items: center;
    gap: 12px;
}