/* Upload widget rendered by assets/scripts/utils/file-upload.js. Needs tokens.css. */

.fu-input {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
    opacity: 0 !important;
}

/* Old trigger buttons are replaced by the widget */
.fu-host .upload-click,
.fu-host .btn-group:has(.upload-click),
.fu-host .form-image-upload-preview[src="#"] {
    display: none !important;
}

.fu-host.d-inline {
    display: block !important;
}

.fu-host+.fu-host,
.fu-host .fu+.fu {
    margin-top: 8px;
}

.fu {
    min-width: 230px;
    font-family: var(--font);
    font-size: 14px;
}

.fu-drop {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 10px 14px;
    text-align: left;
    color: var(--ink);
    background: #f8fafc;
    border: 2px dashed var(--field-border);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.fu-drop:hover,
.fu-drop.is-over,
.fu-drop:focus-visible {
    background: var(--brand-50);
    border-color: var(--brand-600);
    outline: none;
}

.fu-drop>i {
    font-size: 22px;
    color: var(--brand-600);
}

.fu-drop b,
.fu-drop small {
    display: block;
}

.fu-drop b {
    font-weight: 700;
    color: var(--brand-700);
}

.fu-drop small {
    font-size: 12px;
    color: var(--muted);
}

.fu.is-filled {
    padding: 10px;
    background: var(--surface);
    border: 1.5px solid #86efac;
    border-radius: 12px;
}

.fu-file {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.fu-thumb {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    overflow: hidden;
    font-size: 22px;
    color: #b91c1c;
    background: #f1f5f9;
    border-radius: 8px;
}

.fu-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fu-meta {
    min-width: 0;
}

.fu-meta b {
    display: block;
    overflow: hidden;
    font-size: 13.5px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.fu-meta small {
    font-size: 12px;
    color: #15803d;
}

.fu-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.fu-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--brand-700);
    background: var(--surface);
    border: 1.5px solid var(--brand-200);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none !important;
}

.fu-btn:hover {
    color: var(--brand-800);
    background: var(--brand-50);
}

.fu-btn--danger {
    color: #b91c1c;
    border-color: #fecaca;
}

.fu-btn--danger:hover {
    color: #991b1b;
    background: #fef2f2;
}

.fu-stored {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--muted);
}

.fu-link {
    padding: 0;
    font-weight: 700;
    color: var(--brand-700);
    text-decoration: underline;
    background: none;
    border: 0;
    cursor: pointer;
}

/* Preview overlay */
.fu-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(15, 23, 42, .6);
}

.fu-overlay__box {
    display: flex;
    flex-direction: column;
    width: min(960px, 100%);
    max-height: calc(100vh - 32px);
    overflow: hidden;
    background: var(--surface);
    border-radius: 14px;
    box-shadow: 0 24px 60px -20px rgba(15, 23, 42, .5);
}

.fu-overlay__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
}

.fu-overlay__head b {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.fu-overlay__body {
    display: grid;
    place-items: center;
    min-height: 0;
    overflow: auto;
    background: #f1f5f9;
}

.fu-overlay__body img {
    max-width: 100%;
    max-height: calc(100vh - 110px);
    object-fit: contain;
}

.fu-overlay__body iframe {
    width: 100%;
    height: calc(100vh - 110px);
    border: 0;
}

/* Image fields: show the stored image as a small "current" thumbnail; hide it once a new file is picked */
.fu-host .form-image-upload-preview {
    display: block;
    max-width: 160px;
    max-height: 120px;
    margin-top: 8px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.fu-host .form-image-upload-preview[src*="placeholder-image"],
.fu-host:has(.fu.is-filled) .form-image-upload-preview {
    display: none !important;
}

.fu-btn--solid {
    color: #fff;
    background: var(--brand-600);
    border-color: var(--brand-600);
}

.fu-btn--solid:hover {
    color: #fff;
    background: var(--brand-700);
}

/* ---------- Downloadable forms (<x-doc.list> / <x-doc.file>) ---------- */
.docs {
    padding: 16px;
    background: var(--brand-50);
    border: 1px solid var(--brand-200);
    border-radius: 14px;
}

.docs__head {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.docs__badge {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    color: #fff;
    background: var(--brand-600);
    border-radius: 12px;
}

.docs h3.docs__title {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    color: var(--ink);
}

.docs__intro {
    margin: 2px 0 0;
    font-size: 13.5px;
    line-height: 1.5;
    color: #334155;
}

.docs__list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.doc {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 12px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
}

.doc__icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    font-size: 18px;
    border-radius: 10px;
}

.doc__icon--pdf { color: #b91c1c; background: #fee2e2; }
.doc__icon--word { color: #1d4ed8; background: #dbeafe; }
.doc__icon--excel { color: #15803d; background: #dcfce7; }
.doc__icon--image { color: #7e22ce; background: #f3e8ff; }
.doc__icon--other { color: #475569; background: #f1f5f9; }

.doc__info {
    flex: 1 1 160px;
    min-width: 0;
}

.doc__name,
.doc__info small {
    display: block;
}

.doc__name {
    font-size: 14px;
    line-height: 1.35;
    color: var(--ink);
}

.doc__info small {
    font-size: 12px;
    color: var(--muted);
}

.doc__actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
}

/* Step-by-step box for documents that must be printed, signed and scanned */
.doc-steps {
    padding: 14px 16px;
    font-size: 13.5px;
    line-height: 1.55;
    color: #334155;
    background: #f8fafc;
    border: 1px dashed var(--field-border);
    border-radius: 12px;
}

.doc-steps ol {
    margin: 0;
    padding-left: 20px;
}

.doc-steps li+li {
    margin-top: 4px;
}

/* ---------- Signed requirement (<x-doc.signed-form>) ---------- */
.signed {
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--brand-200);
    border-radius: 14px;
}

.signed__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin-bottom: 4px;
}

.signed__head b {
    font-size: 15px;
    color: var(--ink);
}

.signed__tag {
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 700;
    color: #92400e;
    background: #fef3c7;
    border-radius: 999px;
}

.signed .message-error:empty {
    display: none;
}

.signed__steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.signed__step {
    display: flex;
    gap: 10px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.signed__n {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    background: var(--brand-600);
    border-radius: 50%;
}

.signed__body {
    flex: 1 1 auto;
    min-width: 0;
}

.signed__body>b {
    display: block;
    font-size: 14px;
}

.signed__body p {
    margin: 2px 0 10px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--muted);
}

.signed__body .upload-persyaratan {
    margin-top: 8px;
}

.signed__body .fu {
    min-width: 0;
}

@media (max-width: 900px) {
    .signed__steps {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------- Compact trigger (persyaratan rows) + upload modal ---------- */
.fu--mini {
    display: inline-block;
    min-width: 0;
    vertical-align: middle;
}

/* the two uploaders of one row sit next to each other, not stacked */
.fu-host+.fu-host:has(.fu--mini),
.f106-action .btn+.fu-host {
    margin-top: 0;
    margin-left: 6px;
}

.fu-mini {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 170px;
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--brand-700);
    background: var(--brand-50);
    border: 1.5px dashed var(--brand-200);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.fu-mini:hover,
.fu-mini:focus-visible {
    border-color: var(--brand-600);
    outline: none;
}

.fu-mini span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.fu-mini.is-filled {
    color: #15803d;
    background: #f0fdf4;
    border: 1.5px solid #86efac;
}

.fu-modal {
    width: min(460px, 100%);
}

.fu-modal__body {
    padding: 16px;
}

.fu-modal__for {
    margin: 0 0 12px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
}

.fu-drop--lg {
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    min-height: 150px;
    text-align: center;
}

.fu-drop--lg>i {
    font-size: 34px;
}

.fu-file--lg .fu-thumb {
    width: 64px;
    height: 64px;
    font-size: 30px;
}

.fu-modal__err {
    margin: 10px 0 0;
    font-size: 13px;
    color: #b91c1c;
}

.fu-modal__err:empty {
    display: none;
}

.fu-modal__hint {
    margin: 10px 0 0;
    font-size: 12px;
    color: var(--muted);
}

.fu-modal__foot {
    display: flex;
    justify-content: flex-end;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
}

/* phone: the label takes its own line, the small buttons sit under it */
@media (max-width: 767px) {
    .list-persyaratan-data .row>.col-auto {
        flex: 0 0 100%;
        max-width: 100%;
        margin-top: .5rem;
    }
}

/* ---------- NIK lookup field (.biodata-penduduk-state, markup comes from form_input.form_html) ----------
   One field instead of three boxes: [ NIK number | Manual switch | search ].
   The checkbox is turned into a labelled switch with CSS only, so the markup and
   the JS that reads `input[type=checkbox]` / `.btn` stay as they are. */
.input-group.biodata-penduduk-state {
    flex-wrap: nowrap;
    align-items: center;
    padding-right: 6px;
    background: var(--surface);
    border: 1.5px solid var(--field-border);
    border-radius: 12px;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.input-group.biodata-penduduk-state:focus-within {
    border-color: var(--brand-600);
    box-shadow: 0 0 0 3px var(--focus);
}

.input-group.biodata-penduduk-state:has(>input[readonly]) {
    background: #f8fafc;
}

.input-group.biodata-penduduk-state>input.form-control {
    min-height: 48px;
    font-weight: 600;
    letter-spacing: .06em;
    font-variant-numeric: tabular-nums;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.biodata-penduduk-state>input.form-control::-webkit-inner-spin-button,
.biodata-penduduk-state>input.form-control::-webkit-outer-spin-button {
    margin: 0;
    -webkit-appearance: none;
}

.biodata-penduduk-state .input-group-append {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 0;
}

.biodata-penduduk-state .input-group-append .input-group-text {
    display: flex;
    align-items: center;
    height: auto;
    min-height: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.biodata-penduduk-state input[type="checkbox"] {
    position: relative;
    flex: 0 0 auto;
    width: 94px;
    height: 32px;
    margin: 0;
    background: #e2e8f0;
    border-radius: 999px;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    transition: background-color .2s ease;
}

.biodata-penduduk-state input[type="checkbox"]::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 24px;
    height: 24px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .3);
    transition: transform .2s ease;
}

.biodata-penduduk-state input[type="checkbox"]::after {
    content: "Manual";
    position: absolute;
    top: 0;
    left: 36px;
    font: 700 12px/32px var(--font);
    color: var(--muted);
    transition: left .2s ease, color .2s ease;
}

.biodata-penduduk-state input[type="checkbox"]:checked {
    background: var(--brand-600);
}

.biodata-penduduk-state input[type="checkbox"]:checked::before {
    transform: translateX(62px);
}

.biodata-penduduk-state input[type="checkbox"]:checked::after {
    left: 13px;
    color: #fff;
}

.biodata-penduduk-state input[type="checkbox"]:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.input-group.biodata-penduduk-state .input-group-append .btn {
    display: grid;
    place-items: center;
    width: 38px;
    min-height: 38px;
    height: 38px;
    padding: 0;
    color: #fff;
    background: var(--brand-600);
    border: 0;
    border-radius: 9px;
    transition: background-color .15s ease;
}

.input-group.biodata-penduduk-state .input-group-append .btn:hover:not(:disabled) {
    background: var(--brand-700);
}

.input-group.biodata-penduduk-state .input-group-append .btn:disabled {
    color: #94a3b8;
    background: #e2e8f0;
    cursor: not-allowed;
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {

    .biodata-penduduk-state input[type="checkbox"],
    .biodata-penduduk-state input[type="checkbox"]::before,
    .biodata-penduduk-state input[type="checkbox"]::after {
        transition: none;
    }
}

/* ---------- Persyaratan table on the citizen form (masyarakat/dynamic*/{create,edit,ulang}) ----------
   Same markup as before (striped table, label | empty | attachments); this only changes how it looks:
   a bordered list, label on the left, the two compact upload buttons side by side on the right. */
.content-form div:has(> table.table .persyaratan-input-file) {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
}

.content-form table.table:has(.persyaratan-input-file) {
    margin: 0;
    border-collapse: collapse;
}

.content-form table.table:has(.persyaratan-input-file) thead th {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    color: var(--muted-2);
    background: #f8fafc;
    border: 0;
    border-bottom: 1px solid var(--line);
}

.content-form table.table:has(.persyaratan-input-file) thead th:last-child {
    width: 1%;
    text-align: right;
}

.content-form table.table:has(.persyaratan-input-file) tbody tr,
.content-form table.table-striped:has(.persyaratan-input-file) tbody tr:nth-of-type(odd) {
    background: transparent;
    border-top: 1px solid var(--line);
}

.content-form table.table:has(.persyaratan-input-file) tbody tr:first-child {
    border-top: 0;
}

.content-form table.table:has(.persyaratan-input-file) tbody tr:hover {
    background: #fafbff;
}

.content-form table.table:has(.persyaratan-input-file) tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--ink);
}

.content-form table.table:has(.persyaratan-input-file) tbody td:empty {
    padding: 0;
}

.content-form table.table:has(.persyaratan-input-file) tbody td:last-child:not([colspan]) {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}

/* the two uploaders of a row: one line, even gap (they were stacked and offset) */
.content-form table.table:has(.persyaratan-input-file) .upload-persyaratan.fu-host {
    display: inline-block !important;
    margin: 0 0 0 8px;
    vertical-align: middle;
}

.content-form table.table:has(.persyaratan-input-file) .upload-persyaratan.fu-host:first-of-type {
    margin-left: 0;
}

.content-form table.table:has(.persyaratan-input-file) .btn-download-f106 {
    margin-right: 8px;
}

@media (max-width: 767px) {

    .content-form table.table:has(.persyaratan-input-file) thead {
        display: none;
    }

    .content-form table.table:has(.persyaratan-input-file) tbody tr {
        display: block;
        padding: 12px 14px;
    }

    .content-form table.table:has(.persyaratan-input-file) tbody td {
        display: block;
        width: auto !important;
        padding: 0;
        text-align: left !important;
    }

    .content-form table.table:has(.persyaratan-input-file) tbody td:empty {
        display: none;
    }

    .content-form table.table:has(.persyaratan-input-file) tbody td:last-child {
        margin-top: 10px;
    }
}

/* ---------- Image slot: one preview card that is also the picker (logo, banner, popup, icon) ---------- */
.card.image-preview,
.card.logo-preview,
.card.foto-profile-card {
    position: relative;
    margin-bottom: 8px;
    overflow: hidden;
    cursor: pointer;
    background: var(--brand-50);
    border: 2px dashed var(--field-border);
    border-radius: 14px;
    box-shadow: none;
    transition: border-color .15s, background-color .15s;
}

.card.image-preview:hover,
.card.logo-preview:hover,
.card.foto-profile-card:hover {
    background: #fff;
    border-color: var(--brand-600);
    transform: none;
}

.card.image-preview .card-body,
.card.logo-preview .card-body,
.card.foto-profile-card .card-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    padding: 16px 16px 48px;
}

.card.image-preview img,
.card.logo-preview img,
.card.foto-profile-card img {
    max-width: 100%;
    object-fit: contain;
}

.card.logo-preview img {
    height: 96px;
}

/* hover caption doubles as the "how do I change it" hint */
.card.image-preview::after,
.card.logo-preview::after,
.card.foto-profile-card::after {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 9px 12px;
    font: 600 13px/1.2 var(--font);
    color: var(--brand-700);
    text-align: center;
    content: "Klik untuk ganti gambar";
    background: rgba(255, 255, 255, .92);
    border-top: 1px solid var(--line);
}

.card.image-preview.is-empty::after,
.card.logo-preview.is-empty::after,
.card.foto-profile-card.is-empty::after {
    content: "Klik untuk pilih gambar";
}

/* image missing on disk: hide the broken-image glyph, show a neutral icon instead */
.card.is-empty img {
    display: none;
}

.card.is-empty .card-body::before {
    font: 900 40px/1 "Font Awesome 5 Free";
    color: var(--muted);
    content: "\f03e";
}

/* Bootstrap custom-file pairs (video panduan, formulir): the widget replaces the native label */
.custom-file.fu-host {
    height: auto;
}

.custom-file.fu-host .custom-file-label {
    display: none;
}
