/* =========================================
   1. RESET & WARNA DASAR
   ========================================= */
:root {
    --primary-blue: #0056b3;
    --light-blue: #e6f0fa;
    --accent-red: #d90429;
    --white: #ffffff;
    --bg-color: #f4f7fb;
    --text-dark: #2b2d42;
    --text-muted: #8d99ae;
}

* {
    box-sizing: border-box; margin: 0; padding: 0;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-dark);
    display: flex; flex-direction: column; align-items: center;
    padding: 20px; min-height: 100vh;
}

/* =========================================
   2. MAIN CONTAINER & HEADER
   ========================================= */
.main-container {
    background-color: var(--white);
    width: 100%; max-width: 450px;
    border-radius: 24px;
    box-shadow: 0 15px 35px rgba(0, 86, 179, 0.1);
    padding: 30px 25px;
    margin-top: 10px;
    position: relative;
    border-top: 6px solid var(--primary-blue);
}

h1 {
    color: var(--primary-blue);
    text-align: center; font-size: 24px; font-weight: 700;
}
p.subtitle {
    text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 20px;
}

/* =========================================
   3. CUSTOM TOGGLE BUTTON
   ========================================= */
.toggle-container {
    display: flex;
    background-color: var(--light-blue);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
    position: relative;
}
.toggle-btn {
    flex: 1; text-align: center; padding: 10px 0;
    font-size: 14px; font-weight: 600;
    color: var(--primary-blue);
    background: transparent; border: none;
    border-radius: 8px; cursor: pointer;
    transition: all 0.3s ease;
    z-index: 2;
}
.toggle-btn.active {
    background-color: var(--primary-blue);
    color: var(--white);
    box-shadow: 0 4px 10px rgba(0, 86, 179, 0.3);
}

/* =========================================
   4. SCANNER & FILE UPLOAD AREA
   ========================================= */
.scan-area {
    width: 100%; min-height: 250px;
    border: 2px dashed var(--primary-blue);
    border-radius: 16px; overflow: hidden;
    margin-bottom: 25px; background: #fafbfc;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    position: relative;
}

#reader { width: 100%; display: block; }

#file-upload-area { display: none; width: 100%; text-align: center; padding: 30px 20px; }
.upload-icon { font-size: 40px; margin-bottom: 10px; }
.file-label {
    display: inline-block;
    background-color: var(--primary-blue); color: var(--white);
    padding: 10px 20px; border-radius: 50px;
    font-weight: 600; cursor: pointer; font-size: 14px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0, 86, 179, 0.3);
}
.file-label:hover { background-color: #004494; transform: translateY(-2px); }
input[type="file"] { display: none; }

/* =========================================
   5. LIST DATA (ARRAY)
   ========================================= */
.result-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 15px;
}
.result-header h2 { font-size: 16px; font-weight: 600; color: var(--text-dark); }
.count-badge {
    font-size: 12px; font-weight: 600;
    color: var(--white); background: var(--primary-blue);
    padding: 4px 10px; border-radius: 12px;
}

ul { list-style-type: none; max-height: 220px; overflow-y: auto; padding-right: 5px; }

li {
    background: var(--white);
    border: 1px solid #e2e8f0;
    border-left: 5px solid var(--accent-red);
    margin-bottom: 10px; padding: 12px 15px;
    border-radius: 10px;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    animation: fadeIn 0.3s ease forwards;
}

.scanned-text { font-weight: 500; font-size: 14px; word-break: break-all; margin-right: 10px; }

.badge {
    background-color: var(--accent-red); color: var(--white);
    padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700;
}

.empty-state { text-align: center; color: var(--text-muted); font-size: 13px; border: none; padding: 20px 0; }

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

/* =========================================
   6. TOAST NOTIFICATION
   ========================================= */
#toast {
    visibility: hidden; min-width: 250px;
    color: #fff; text-align: center; border-radius: 50px;
    padding: 12px 24px; position: fixed; z-index: 1000;
    bottom: 30px; left: 50%; transform: translateX(-50%);
    font-size: 13px; font-weight: 600;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    opacity: 0; transition: opacity 0.3s, bottom 0.3s;
}
#toast.show { visibility: visible; opacity: 1; bottom: 50px; }
#toast.success { background-color: #06d6a0; }
#toast.warning { background-color: var(--accent-red); }

ul::-webkit-scrollbar { width: 5px; }
ul::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* =========================================
   7. HALAMAN LOGIN
   ========================================= */
.login-container {
    max-width: 400px;
    padding: 40px 30px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.logo-circle {
    font-size: 45px;
    background: var(--light-blue);
    width: 80px; height: 80px;
    line-height: 80px;
    border-radius: 50%;
    margin: 0 auto 15px auto;
    box-shadow: 0 4px 15px rgba(0, 86, 179, 0.15);
}

.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.input-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    font-family: 'Poppins', sans-serif;
    transition: all 0.3s ease;
    outline: none;
}

.input-group input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

.btn-primary {
    width: 100%;
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    padding: 14px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 86, 179, 0.2);
    margin-top: 10px;
}

.btn-primary:hover {
    background: #004494;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 86, 179, 0.3);
}

.login-footer {
    text-align: center;
    margin-top: 25px;
    font-size: 13px;
    color: var(--text-muted);
}

.login-footer a {
    color: var(--accent-red);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}

.login-footer a:hover {
    color: #b00320;
    text-decoration: underline;
}

/* =========================================
   8. ADMIN DASHBOARD STYLES
   ========================================= */
.admin-container {
    width: 100%;
    max-width: 1000px;
    margin: 20px auto;
    padding: 0 15px;
    box-sizing: border-box;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    background: var(--white);
    padding: 20px 30px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

/* =========================================
   ADMIN NAVIGATION TABS
   ========================================= */
.admin-nav-bar {
    display: flex;
    gap: 10px;
    background: var(--white);
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    margin-bottom: 25px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-tab {
    padding: 10px 20px;
    background: #f4f7fb;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #5a6a85;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.nav-tab:hover { background: #e2e8f0; }

.nav-tab.active {
    background: var(--primary-blue);
    color: var(--white);
    box-shadow: 0 4px 10px rgba(0, 86, 179, 0.2);
}

.table-header-admin {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.header-icon-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-icon-title h2 { margin: 0; font-size: 18px; color: var(--text-dark); }
.icon-box-blue { font-size: 24px; }

.btn-logout {
    background: var(--accent-red);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

/* Statistik */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--white);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    border-bottom: 4px solid var(--primary-blue);
}

.stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-blue);
}

/* Tabel Styling */
.table-container {
    background: var(--white);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.table-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 600px;
}

th {
    text-align: left;
    background: var(--light-blue);
    padding: 12px;
    color: var(--primary-blue);
}

.admin-section { display: none; animation: fadeIn 0.3s ease; }
.admin-section.active { display: block; }

td {
    padding: 15px 12px;
    border-bottom: 1px solid #eee;
}

.segment-tag {
    background: #f0f4f8;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 12px;
}

.segment-tag.blue { color: var(--primary-blue); border: 1px solid var(--light-blue); }
.segment-tag.red { color: var(--accent-red); border: 1px solid #fee2e2; }
.btn-refresh {
    background: none; border: 1px solid #ddd; padding: 5px 15px; border-radius: 5px; cursor: pointer;
}

/* Styling Form Format Barcode */
.format-form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Otomatis dibagi 3 kolom sama rata */
    gap: 15px;
    background: #f8fbff;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
    border: 1px solid #e1e9f5;
    box-sizing: border-box;
}

.input-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-field label {
    font-size: 12px;
    font-weight: 600;
    color: #5a6a85;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-field input {
    padding: 12px 15px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.input-field input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
    outline: none;
}

/* Tombol Tambah Format */
.btn-add-format {
    background-color: var(--primary-blue);
    color: white;
    border: none;
    padding: 0 20px; /* Padding kiri-kanan saja */
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px; /* Samakan persis dengan tinggi input box */
    white-space: nowrap; /* KUNCI: Mencegah teks terlipat jadi 2 baris */
    transition: all 0.2s ease;
}

.btn-add-format:hover {
    background-color: #004494;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 86, 179, 0.2);
}

.plus-icon {
    font-size: 18px;
    font-weight: bold;
}

/* Penyesuaian Tabel */
.modern-table th {
    padding: 15px;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.text-center { text-align: center; }
.text-right { text-align: right; }

.modern-table {
    min-width: 900px;
}

/* --- Responsif untuk Layar Laptop Kecil / Tablet --- */
@media (max-width: 1024px) {
    .format-form-grid {
        /* Jika layar agak sempit, jadikan 2 baris */
        grid-template-columns: 1fr 1fr !important; 
    }
}

/* --- Responsif untuk HP --- */
@media (max-width: 768px) {
    .format-form-grid {
        grid-template-columns: 1fr !important; /* Susun vertikal penuh di HP */
    }
    .btn-add-format {
        width: 100%;
        margin-top: 10px;
    }
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .btn-logout {
        width: 100%;
    }
    .table-header, .table-header-admin {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    #csv-stats-bar {
        flex-direction: column !important;
    }
    #csv-stats-bar > div {
        border-right: none !important;
        border-bottom: 1px solid #e5e7eb;
    }
}


/* Badge Delimiter */
.delimiter-badge {
    padding: 4px 10px;
    background: #e9ecef;
    border-radius: 6px;
    font-family: monospace;
    font-weight: bold;
    color: var(--primary-blue);
}


/* =========================================
   9. MODAL KONFIRMASI
   ========================================= */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--white);
    padding: 30px; border-radius: 20px;
    width: 90%; max-width: 400px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-content h3 { margin-bottom: 20px; color: var(--text-dark); text-align: center; }

@keyframes scaleUp { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* =========================================
   10. HALAMAN DRIVER
   ========================================= */
.driver-container {
    max-width: 480px;
    padding: 25px 20px;
}

.driver-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.driver-header h1 {
    text-align: left;
    font-size: 22px;
}

.btn-logout-sm {
    background: var(--accent-red);
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

/* Step Container */
.step-container {
    background: var(--white);
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
}

.step-container.active {
    border-color: var(--primary-blue);
    box-shadow: 0 4px 15px rgba(0, 86, 179, 0.1);
}

.step-container.completed {
    border-color: #06d6a0;
    background: #fafffe;
}

.step-container.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Step Header */
.step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.step-badge {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    transition: background 0.3s ease;
}

.step-badge.completed {
    background: #06d6a0;
}

.step-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
}

/* Step Result */
.step-result {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    padding: 12px 15px;
    margin-top: 10px;
    animation: fadeIn 0.3s ease;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}

.result-label {
    color: #666;
    font-weight: 500;
}

.result-value {
    color: var(--text-dark);
    font-weight: 600;
}

.btn-reset {
    display: inline-block;
    margin-top: 10px;
    background: none;
    border: 1px solid #e2e8f0;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    color: var(--accent-red);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-reset:hover {
    background: #fff5f5;
    border-color: var(--accent-red);
}

/* Scan area dalam driver page */
.driver-container .scan-area {
    min-height: 200px;
}

/* Status badges di admin tabel driver */
.status-aktif {
    color: #06d6a0;
    font-weight: 600;
    font-size: 12px;
}

.status-dipindahkan {
    color: #aaa;
    font-weight: 600;
    font-size: 12px;
}

/* Role badges di admin user management */
.role-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-admin { background: #ede9fe; color: #7c3aed; }
.role-user { background: var(--light-blue); color: var(--primary-blue); }
.role-driver { background: #fef3c7; color: #d97706; }

/* Admin stats grid 4 kolom */
.stats-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

@media (max-width: 1024px) {
    .stats-grid-4 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid-4 {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   11. MODAL CHECKLIST KENDARAAN
   ========================================= */
.modal-checklist {
    max-height: 85vh;
    overflow-y: auto;
    width: 95%;
    max-width: 520px;
}

/* Vehicle Info Grid (dalam modal) */
.vehicle-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 15px;
    background: #f0f4ff;
    padding: 12px 15px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 13px;
}

.vinfo-label {
    color: #888;
    font-size: 11px;
}

.vinfo-value {
    font-weight: 600;
    color: var(--text-dark);
}

/* Checklist Grid (dalam modal scan) */
.checklist-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    max-height: 220px;
    overflow-y: auto;
    padding: 10px;
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 12px;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.checklist-item label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #555;
    font-weight: 500;
    font-size: 10px;
}

.checklist-item input {
    width: 50px;
    padding: 3px 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 11px;
    text-align: center;
    background: white;
}

.checklist-item input:focus {
    border-color: var(--primary-blue);
    outline: none;
}

/* =========================================
   12. ADMIN — CHECKLIST DEFAULTS GRID
   ========================================= */
.admin-checklist-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.admin-checklist-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-checklist-item label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #555;
    font-weight: 500;
    font-size: 11px;
}

.admin-checklist-item input {
    width: 55px;
    padding: 4px 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 11px;
    text-align: center;
    background: white;
}

.admin-checklist-item input:focus {
    border-color: var(--primary-blue);
    outline: none;
}

@media (max-width: 768px) {
    .checklist-grid {
        grid-template-columns: 1fr;
    }
    .admin-checklist-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    .modal-checklist {
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    .admin-checklist-grid {
        grid-template-columns: 1fr !important;
    }
}

/* =========================================
   13. EXPORT MODAL STYLES
   ========================================= */
.export-date-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
}

.export-date-input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.btn-cancel {
    flex: 1;
    padding: 12px;
    border: none;
    background: #e2e8f0;
    color: #333;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-cancel:hover { background: #cbd5e1; }

.btn-confirm {
    flex: 1;
    padding: 12px;
    border: none;
    background: var(--primary-blue);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-confirm:hover { background: #004494; }
