/* public/assets/css/style.css
   Desain baru: sidebar gelap + kartu, mengikuti mockup yang sudah disetujui.
   Tidak memengaruhi hasil PDF sama sekali (PDF punya style sendiri di lib/pdf/). */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
    --surface-0: #f4f5f7;
    --surface-1: #f3f4f6;
    --surface-2: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --border-accent: #b91c1c;
    --fill-danger: #b91c1c;
    --fill-danger-hover: #991b1b;
    --on-danger: #ffffff;
    --bg-danger: #fee2e2;
    --text-danger: #b91c1c;
    --bg-accent: #dbeafe;
    --text-accent: #1d4ed8;
    --bg-success: #dcfce7;
    --text-success: #166534;
    --border-success: #bbf7d0;
    --radius: 8px;
    --sidebar-bg: #1f2937;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--surface-0);
    color: var(--text-primary);
}

body { display: flex; min-height: 100vh; }

a { color: var(--text-danger); }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    padding: 20px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    font-weight: 500;
    font-size: 15px;
    color: #ffffff;
    padding: 0 20px 18px;
    border-bottom: 0.5px solid rgba(255,255,255,0.15);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.sidebar-brand i { font-size: 18px; color: var(--fill-danger); }

.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}
.sidebar a i { font-size: 17px; flex-shrink: 0; }
.sidebar a:hover { background: rgba(255,255,255,0.08); color: #ffffff; }
.sidebar a.active { background: var(--fill-danger); color: var(--on-danger); }

/* ---------- Main content ---------- */
.main { flex: 1; padding: 24px 28px 60px; min-width: 0; }
.wrap { max-width: 900px; margin: 0 auto; }
.wrap-narrow { max-width: 780px; margin: 0 auto; }

.breadcrumb { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; font-size: 12px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text-danger); }
.breadcrumb .sep { color: var(--text-muted); font-size: 11px; }
.breadcrumb .current { color: var(--text-secondary); }

h1 { margin: 0 0 2px; font-size: 22px; font-weight: 500; }
h2 { font-size: 16px; font-weight: 500; margin: 0 0 4px; }
h3 { margin: 24px 0 10px; font-size: 15px; font-weight: 500; }

.subtitle { color: var(--text-secondary); margin: 0 0 20px; font-size: 13px; }
.hint { color: var(--text-secondary); font-size: 12px; margin: 4px 0 12px; font-weight: 400; }
.hint a { color: var(--text-danger); }

.notice {
    background: #fef3c7;
    border: 0.5px solid #fde68a;
    color: #92400e;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 18px;
}
.notice-success { background: var(--bg-success); border-color: var(--border-success); color: var(--text-success); }

/* ---------- Card sections (pengganti fieldset) ---------- */
.card {
    background: var(--surface-2);
    border: 0.5px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 14px;
}
.card-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0 0 12px;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.card label { margin-bottom: 12px; }
.card label > input, .card label > select, .card label > textarea { margin-top: 4px; }

.row { display: flex; gap: 16px; }
.row > label, .row > div { flex: 1; }

input[type="text"],
input[type="date"],
input[type="number"],
textarea,
select {
    display: block;
    width: 100%;
    padding: 9px 10px;
    font-size: 14px;
    border: 0.5px solid var(--border-strong);
    border-radius: var(--radius);
    font-weight: 400;
    color: var(--text-primary);
    background: var(--surface-2);
}
input[type="file"] { font-size: 13px; font-weight: 400; }
textarea { resize: vertical; }

input[readonly] {
    background: var(--surface-1);
    color: var(--text-secondary);
    cursor: default;
}

/* ---------- Input tanggal format Indonesia (dd/mm/yyyy) ---------- */
.date-field { position: relative; }
.date-field .date-display { padding-right: 40px; }
.date-pick-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border-radius: var(--radius);
}
.date-pick-btn:hover { background: var(--surface-1); color: var(--text-primary); }
.date-native {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
    left: 0;
    top: 0;
}

/* ---------- Preset chips (saran lokasi) ---------- */
.preset-chips { margin: -4px 0 4px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.preset-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-right: 4px; }
.chip {
    background: var(--bg-accent);
    color: var(--text-accent);
    border: none;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
}
.chip:hover { filter: brightness(0.95); }

/* ---------- Dropdown multi-pilih (karyawan / alat / kendaraan) ---------- */
.ms-dropdown { position: relative; margin-bottom: 6px; }

.ms-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border: 0.5px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    cursor: pointer;
    font-size: 14px;
    text-align: left;
    color: var(--text-primary);
}
.ms-trigger:hover { background: var(--surface-1); }
.ms-trigger-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-trigger-text.placeholder { color: var(--text-muted); }
.ms-trigger i { font-size: 15px; color: var(--text-muted); flex-shrink: 0; transition: transform 0.15s; }
.ms-dropdown.open .ms-trigger i { transform: rotate(180deg); }

.ms-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface-2);
    border: 0.5px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    z-index: 50;
    max-height: 260px;
    overflow-y: auto;
}

.ms-search {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    padding: 8px;
    border-bottom: 0.5px solid var(--border);
}
.ms-search input {
    width: 100%;
    padding: 7px 9px;
    font-size: 13px;
    border: 0.5px solid var(--border-strong);
    border-radius: var(--radius);
}

.ms-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 0.5px solid var(--border);
}
.ms-option:last-child { border-bottom: none; }
.ms-option:hover { background: var(--surface-1); }
.ms-option input[type="checkbox"] { margin: 0; flex-shrink: 0; }
.ms-option label { margin: 0; flex: 1; font-size: 13px; font-weight: 400; color: var(--text-primary); cursor: pointer; }
.ms-option-empty { padding: 14px 12px; text-align: center; font-size: 12px; color: var(--text-muted); }

.btn-view-photo-mini {
    font-size: 11px;
    padding: 3px 8px;
    border: 0.5px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}
.btn-view-photo-mini:hover { background: var(--surface-1); color: var(--text-primary); }

.ms-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ms-tag {
    display: flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-danger);
    color: var(--text-danger);
    font-size: 12px;
    font-weight: 500;
    padding: 4px 6px 4px 10px;
    border-radius: 999px;
}
.ms-tag button {
    border: none;
    background: none;
    color: var(--text-danger);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    display: flex;
}

.no-photo-label { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

.btn-view-photo {
    font-size: 11px;
    padding: 4px 9px;
    border: 0.5px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-view-photo:hover { background: var(--surface-1); color: var(--text-primary); }

.picker-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.tag { font-size: 10px; background: var(--surface-1); color: var(--text-secondary); padding: 1px 6px; border-radius: 999px; }

/* Kartu di halaman Pengaturan: foto langsung terlihat, klik untuk perbesar */
.settings-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 4px; }
.settings-card {
    width: 150px;
    flex: 0 0 150px;
    border: 0.5px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    text-align: center;
}
.settings-card-photo {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    position: relative;
}
.settings-card-photo:hover img { filter: brightness(0.88); }
.settings-card-photo::after {
    content: '🔍';
    position: absolute;
    bottom: 12px;
    right: 4px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.15s;
}
.settings-card-photo:hover::after { opacity: 1; }
.settings-card img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 8px;
    background: var(--surface-1);
    display: block;
}

/* Kartu kendaraan lebih lebar & bisa menampung sampai 3 foto (angle berbeda) berdampingan */
.settings-card-wide { width: 230px; flex: 0 0 230px; }
.settings-card-photo-row { display: flex; gap: 4px; margin-bottom: 8px; }
.settings-card-photo-row .settings-card-photo { flex: 1; min-width: 0; }
.settings-card-photo-row img { height: 80px; margin-bottom: 0; }

/* Form edit inline di dalam kartu Pengaturan (dibuka lewat <details>) */
.card-edit-toggle { margin: 8px 0; }
.card-edit-toggle summary {
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-accent);
    text-align: left;
}
.inline-edit-form {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--surface-1);
    border-radius: var(--radius);
    padding: 8px;
}
.inline-edit-form input[type="text"] { font-size: 12px; padding: 6px 8px; }
.inline-edit-file-label { font-size: 10px; color: var(--text-muted); font-weight: 400; margin: 0; text-align: left; }
.inline-edit-file-label input[type="file"] { font-size: 10px; margin-top: 3px; width: 100%; }
.inline-edit-jobtypes { justify-content: flex-start; gap: 6px 10px; }
.inline-edit-jobtypes .inline-checkbox { font-size: 11px; }
.settings-card-noimg {
    width: 100%;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-1);
    color: var(--text-muted);
    font-size: 11px;
    border-radius: var(--radius);
    margin-bottom: 8px;
}
.settings-card-label { font-size: 13px; font-weight: 500; margin: 0 0 6px; }
.settings-card .picker-tags { justify-content: center; margin-bottom: 8px; }
.settings-card form { margin: 0; }

/* ---------- Modal lihat foto ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal-content {
    background: var(--surface-2);
    border-radius: 12px;
    padding: 14px;
    max-width: 520px;
    width: 100%;
    position: relative;
}
.modal-content img { width: 100%; border-radius: var(--radius); display: block; image-rendering: -webkit-optimize-contrast; }
.modal-content p { text-align: center; font-size: 13px; font-weight: 500; margin: 10px 0 0; color: var(--text-primary); }
.modal-close {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--fill-danger);
    color: var(--on-danger);
    border: none;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---------- Quick-add ---------- */
.quick-add { margin-top: 10px; border-top: 0.5px dashed var(--border); padding-top: 10px; }
.quick-add summary { cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-danger); }
.quick-add .row { margin-top: 10px; }

/* ---------- Buttons ---------- */
.btn-primary {
    padding: 12px 18px;
    background: var(--fill-danger);
    color: var(--on-danger);
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}
.btn-primary:hover { background: var(--fill-danger-hover); }
.btn-primary i { margin-right: 4px; }

.btn-outline {
    padding: 12px 18px;
    background: var(--surface-2);
    color: var(--text-primary);
    border: 0.5px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}
.btn-outline:hover { background: var(--surface-1); }
.btn-outline i { margin-right: 4px; }

.download-buttons { display: flex; gap: 12px; margin-top: 8px; }
.download-buttons button { flex: 1; padding: 13px; font-size: 14px; }

.btn-delete {
    background: var(--bg-danger);
    color: var(--text-danger);
    border: none;
    border-radius: var(--radius);
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
}
.btn-delete:hover { filter: brightness(0.95); }

.btn-install {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 11px;
    margin-bottom: 20px;
    background: var(--sidebar-bg);
    color: #ffffff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}
.btn-install:hover { background: #111827; }

/* ---------- Dashboard ---------- */
.stat-grid { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card { background: var(--surface-1); border-radius: var(--radius); padding: 1rem; flex: 1 1 140px; }
.stat-card p:first-child { font-size: 13px; color: var(--text-secondary); margin: 0 0 6px; }
.stat-card p:last-child { font-size: 24px; font-weight: 500; margin: 0; }

.section-label { font-size: 13px; font-weight: 500; margin: 0 0 10px; color: var(--text-primary); }

.job-grid { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.job-card {
    background: var(--surface-2);
    border: 0.5px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    text-decoration: none;
    color: inherit;
    display: block;
    flex: 1 1 200px;
}
.job-card:hover { border-color: var(--border-strong); background: var(--surface-1); }
.job-card i { font-size: 20px; color: var(--text-danger); }
.job-card p:first-of-type { font-size: 14px; font-weight: 500; margin: 10px 0 2px; color: var(--text-primary); }
.job-card p:last-of-type { font-size: 12px; color: var(--text-secondary); margin: 0; }

.riwayat-table { background: var(--surface-2); border: 0.5px solid var(--border); border-radius: 12px; overflow: hidden; }
.riwayat-row {
    display: flex;
    padding: 10px 14px;
    font-size: 13px;
    border-bottom: 0.5px solid var(--border);
    align-items: center;
    gap: 8px;
}
.riwayat-row > span { flex: 1 1 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.riwayat-row > span:last-child { flex: 0 0 auto; }
.riwayat-row:last-child { border-bottom: none; }
.riwayat-row.head { font-size: 11px; color: var(--text-muted); padding: 8px 14px; }
.riwayat-row span:nth-child(2), .riwayat-row span:nth-child(3) { color: var(--text-secondary); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: var(--radius); width: fit-content; font-weight: 500; }
.badge-sib { background: var(--bg-danger); color: var(--text-danger); }
.badge-jsa { background: var(--bg-accent); color: var(--text-accent); }
.badge-xlsx { background: var(--bg-success); color: var(--text-success); }
.empty-riwayat { padding: 24px 14px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ---------- Settings tabs & table ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 0.5px solid var(--border); margin-bottom: 20px; }
.tabs a {
    padding: 9px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tabs a.active { color: var(--text-danger); border-bottom-color: var(--text-danger); }
.tabs a:hover { color: var(--text-danger); }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 10px; }
.data-table th, .data-table td { text-align: left; padding: 9px 10px; border-bottom: 0.5px solid var(--border); }
.data-table th { color: var(--text-secondary); font-weight: 500; font-size: 12px; }
.data-table .col-action { width: 90px; }
.data-table .empty { color: var(--text-muted); text-align: center; padding: 20px; }

.add-form { max-width: 480px; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.inline-checkbox { display: flex; align-items: center; gap: 5px; font-weight: 400; font-size: 13px; color: var(--text-primary); }
.inline-checkbox input { width: auto; margin: 0; }

.empty { color: var(--text-muted); font-size: 13px; }

.add-form-wide { max-width: 700px; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checkbox-grid .inline-checkbox { flex: 0 0 auto; }

.btn-small { font-size: 12px; padding: 6px 10px; }

.jsa-steps-section { border-top: 0.5px solid var(--border); padding-top: 12px; margin-top: 8px; }
.jsa-step-block {
    border: 0.5px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12px;
    background: var(--surface-1);
}
.jsa-step-header { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.jsa-step-header input { flex: 1; margin: 0; font-weight: 500; }
.jsa-step-rows { display: flex; flex-direction: column; gap: 8px; }
.jsa-row-block {
    background: var(--surface-2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
}
.jsa-row-block label { font-size: 11px; margin-bottom: 6px; }
.jsa-row-block input { margin-top: 3px; }
.jsa-step-rows .btn-outline { margin-top: 8px; }
#btnAddStep { margin-top: 4px; }

template { display: none; }

@media (max-width: 720px) {
    body { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; display: flex; padding: 10px; overflow-x: auto; }
    .sidebar-brand { display: none; }
    .sidebar a { padding: 8px 14px; white-space: nowrap; }
    .main { padding: 20px 14px; }
    .row { flex-direction: column; gap: 0; }
    .download-buttons { flex-direction: column; }
    .stat-card { flex: 1 1 45%; }
    .job-card { flex: 1 1 100%; }
    .riwayat-row { font-size: 12px; }
    .riwayat-row span:nth-child(2) { display: none; }
}
