/* ===================================================================
Optimized CSS for All Screens (Desktop & Mobile) - FINAL ALIGNMENT FIX V3
=================================================================== */

/* Body background */
body {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    font-family: 'Inter', sans-serif;
    color: #333;
    margin: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================= Navbar & Header ================= */
.glass-navbar {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(12px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
    
.glass-header {
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(12px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.navbar-nav .nav-link, .header-nav .nav-link {
    transition: all 0.3s ease;
    color: #495057;
    font-weight: 500;
}

.navbar-nav .nav-link.active,
.header-nav .nav-link.active {
    background-color: #198754 !important;
    color: white !important;
    box-shadow: 0 4px 8px rgba(25, 135, 84, 0.3);
    transform: translateY(-2px);
}

.navbar-nav .nav-link:hover,
.header-nav .nav-link:hover {
    background-color: rgba(25, 135, 84, 0.1);
    color: #198754;
}
    
/* Border-radius yang lebih besar untuk semua tombol dan input */
.btn, .form-control, .dataTables_wrapper .dt-buttons .btn {
    border-radius: 0.75rem !important;
}

/* ================= Card ================= */
.glass-card {
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    animation: cardFadeIn 0.4s ease-in-out;
}

@keyframes cardFadeIn {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
        .card {
            border-radius: 0.75rem;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        }
    
/* ================= Table ================= */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.table thead th {
    background: #198754 !important;
    color: #fff !important;
    border-bottom: 2px solid #146c43;
    font-weight: 600;
}
    
.table tbody tr:hover {
    background: rgba(25, 135, 84, 0.1);
}
    
/* DataTable Specifics */
.dataTables_wrapper {
    /* FIX 1: Memperlambat Animasi menjadi 1.2s */
    animation: fadeIn 1.2s ease-out; 
}

/* KRITIS: Menimpa Konflik Grid/Float bawaan */
.dataTables_wrapper .dt-buttons,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    float: none !important; /* Nonaktifkan float yang konflik */
    padding: 0 !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* KRITIS: Aturan untuk kolom Bootstrap (Col-md-6) yang membungkus Paging dan Search */
.dataTables_wrapper .row:first-child > div {
    width: auto !important; /* KRITIS: Jangan ambil 50% lebar */
    max-width: none !important;
    flex-grow: 0 !important;
    padding: 0 !important; /* Hapus padding kolom bawaan */
    margin: 0 !important;
}

/* ------------------ Layout Containers (Top & Bottom) ------------------ */

/* Baris Atas (Length/Filter) - Mengatur sejajar horizontal secara default */
.dataTables_wrapper .row:first-child {
    display: flex;
    justify-content: space-between; /* Memisahkan elemen ke kiri dan kanan */
    align-items: center; /* KRITIS: Sejajar vertikal di tengah */
    flex-wrap: wrap; 
    padding: 0 0.75rem; 
    margin: 0;
}

/* Baris Bawah (Info/Paging) - Mengatur sejajar horizontal secara default */
.dataTables_wrapper .row:last-child {
    display: flex;
    justify-content: space-between; /* Memisahkan elemen ke kiri dan kanan */
    align-items: center;
    flex-wrap: wrap;
    padding: 0 0.75rem;
    margin: 0;
}

/* ------------------ Element Styling and Ordering ------------------ */

/* PAGING/LENGTH (KIRI) */
.dataTables_wrapper .dataTables_length {
    order: 1; /* KIRI ATAS */
    text-align: left !important;
    margin-right: 1rem; /* Jarak dari elemen berikutnya */
}

/* SEARCH/FILTER (KANAN) */
.dataTables_wrapper .dataTables_filter {
    order: 3; /* KANAN ATAS */
    text-align: right !important; /* Penting untuk meratakan input ke kanan */
    width: auto !important;
    margin-left: auto; /* KRITIS: Mendorong ke sisi kanan */
}

/* Info (KIRI BAWAH) */
.dataTables_wrapper .dataTables_info {
    order: 1; /* KIRI BAWAH */
    text-align: left;
}

/* Paging Control (KANAN BAWAH) */
.dataTables_wrapper .dataTables_paginate {
    order: 2; /* KANAN BAWAH */
    text-align: right;
}


/* Styling elemen detail (Penting untuk Vertikal Alignment) */
.dataTables_wrapper .dataTables_filter input {
    max-width: 250px;
    margin-left: .5rem;
    border-radius: 0.75rem !important; /* Ganti dari 50rem agar seragam dengan tombol/select */
    display: inline-block;
    height: calc(1.5em + 0.75rem + 2px); /* KRITIS: Memastikan tinggi sama dengan elemen select/button */
}

.dataTables_wrapper .dataTables_filter label {
    display: flex;
    align-items: center; /* Sejajar vertikal */
    gap: 0.5rem;
    justify-content: flex-end; /* Memastikan search box rata kanan */
    margin-bottom: 0;
}
    
.dataTables_length label {
    margin-bottom: 0;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.dataTables_length select {
    display: inline-block;
    width: auto;
}

/* Tombol Ekspor (Jika ada) */
.dataTables_wrapper .dt-buttons {
    order: 2; /* Tengah, di antara Paging dan Search */
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.dataTables_wrapper .dt-buttons .btn {
    background-color: #f8f9fa !important;
    color: #495057 !important;
    border: 1px solid #ced4da !important;
}
    
.dataTables_wrapper .dt-buttons .btn:hover {
    background-color: #e2e6ea !important;
}

/* Penyesuaian tata letak tombol Insert */
#insertBtn {
    order: -1; /* Paling kiri/atas, di luar wrapper .row */
    margin-bottom: 1rem;
    display: flex;
    justify-content: flex-start;
}

/* ================= Mobile Optimizations ================= */
@media (max-width: 767.98px) {
    
    /* Mengatur ulang layout header DataTables di mobile (STACKED) */
    .dataTables_wrapper .row:first-child {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start; /* Rata kiri di mobile */
    }
    
    /* Tombol Insert (Urutan 1) */
    #insertBtn {
        order: 1; 
        width: 100%;
        margin-bottom: 0;
        justify-content: center;
    }

    /* Search (Urutan 2) */
    .dataTables_wrapper .dataTables_filter {
        order: 2;
        width: 100%;
        margin-bottom: 0;
        text-align: left !important;
    }
    
    /* Search input di mobile */
    .dataTables_wrapper .dataTables_filter label {
        justify-content: flex-start;
    }

    /* Length (Urutan 3) */
    .dataTables_wrapper .dataTables_length {
        order: 3;
        width: 100%;
        text-align: left !important;
        margin-bottom: 0.5rem;
    }

    /* Tombol Ekspor (Urutan 4) */
    .dataTables_wrapper .dt-buttons {
        order: 4;
        justify-content: center;
        margin-top: 0.5rem;
        margin-bottom: 0;
    }

    /* Card View Fixes (DIJAGA) */
    .table thead { display: none; }
    .table tbody { display: block; width: 100%; }
    .table tr {
        display: block; width: 100%; margin-bottom: 1rem; border-radius: 0.5rem; 
        border: 1px solid #e0e0e0; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        padding: 0.75rem 1rem; background: white;
    }
        
    .table td {
        display: block; text-align: right; border: none; position: relative;
        padding-left: 45% !important; padding-top: 0.25rem; padding-bottom: 0.25rem;
    }

    .table td::before {
        content: attr(data-label); position: absolute; left: 1rem; top: 0.25rem;
        font-weight: bold; text-align: left; white-space: nowrap; color: #6c757d;
        width: 40%; overflow: hidden; text-overflow: ellipsis;
    }
        
    /* Gaya khusus untuk tombol di mobile */
    .table td:last-child {
        display: flex; justify-content: center; gap: 0.5rem; margin-top: 1rem;
        padding-left: 1rem !important; border-top: 1px solid #eee; 
        padding-top: 0.75rem !important; 
    }
    
    .table td:last-child .btn span { display: none; }
    .table td:last-child .btn i { margin-right: 0 !important; }
    
    /* Layout Bottom Row (Info & Paging) - Stacked */
    .dataTables_wrapper .row:last-child { flex-direction: column; }
    
    .dataTables_wrapper .dataTables_info {
        order: 1; width: 100%; margin-bottom: 0.5rem; text-align: left;
    }
    
    .dataTables_wrapper .dataTables_paginate {
        order: 2; width: 100%; text-align: center;
    }
}