/* ================= RESET ================= */
*,
*::before,
*::after{
    box-sizing:border-box;
    margin:0;
    padding:0;
}

/* ================= THEME ================= */
:root{
    --bg:#f7f9fc;
    --surface:#ffffff;
    --surface-2:#f8fafc;
    --border:#e5e7eb;
    --border-strong:#cbd5e1;
    --text:#0f172a;
    --muted:#475569;
    --primary:#1d4ed8;
    --primary-700:#1e40af;
    --success:#16a34a;
    --shadow-1:0 10px 30px rgba(15,23,42,.08);
    --shadow-2:0 8px 20px rgba(15,23,42,.06);
    --radius-lg:14px;
    --radius-md:12px;
    --radius-sm:10px;
}

/* ================= BASE ================= */
body{
    background:var(--bg);
    font-family:ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
    font-size:14px;
    line-height:1.5;
    color:var(--text);
}

.container{
    max-width:820px;
    margin:24px auto;
    padding:0 14px 28px;
}

:focus-visible{
    outline:3px solid rgba(29,78,216,.22);
    outline-offset:2px;
}

/* ================= PANEL ================= */
.panel{
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:var(--radius-lg);
    box-shadow:var(--shadow-1);
    overflow:hidden;
}

.panel-heading{
    font-size:16px;
    font-weight:600;
    padding:12px;
    color:var(--text);
    border-bottom:1px solid var(--border);
    background:linear-gradient(180deg, #ffffff 0%, var(--surface-2) 100%);
}

.panel-body{
    padding:15px;
}

/* ================= FORM ================= */
.form-group{
    margin-bottom:15px;
    position:relative;
}

label{
    display:block;
    margin-bottom:5px;
    font-weight:600;
    font-size:13px;
    color:var(--muted);
}

.form-control{
    width:100%;
    border-radius:var(--radius-sm);
    border:1px solid var(--border-strong);
    padding:10px 12px;
    background:var(--surface);
    color:var(--text);
    line-height:1.25;
    transition:all .2s ease;
}

select.form-control{
    /* Avoid clipped text in native select rendering */
    min-height:42px;
    padding-top:9px;
    padding-bottom:9px;
}

.paket-select-row{
    display:grid;
    grid-template-columns:auto minmax(0, 1fr);
    gap:10px;
    align-items:start;
}

.paket-type-filter{
    display:flex;
    flex-direction:column;
    gap:6px;
    min-width:178px;
    padding:7px;
    border:1px solid var(--border-strong);
    border-radius:var(--radius-sm);
    background:var(--surface-2);
}

.paket-kind-radio-wrap{
    display:flex;
    align-items:center;
    gap:7px;
    min-height:28px;
    margin:0;
    color:#334155;
    font-size:12px;
    font-weight:700;
    line-height:1.2;
    cursor:pointer;
    white-space:nowrap;
}

.paket-kind-radio-wrap input{
    margin:0;
}

.paket-kind-radio-wrap.is-active{
    color:var(--primary);
}

.hidden{
    display:none !important;
}

.paket-biaya{
    margin-top:10px;
    border:1px solid #cfe8cf;
    border-radius:10px;
    background:#f7fff7;
    padding:12px;
}

.paket-biaya-title{
    margin-bottom:8px;
    font-size:13px;
    font-weight:700;
    color:#166534;
}

.paket-biaya-row,
.paket-biaya-total{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    padding:5px 0;
    font-size:13px;
}

.paket-biaya-row span{
    color:#475569;
}

.paket-biaya-total{
    margin-top:6px;
    border-top:1px solid #cfe8cf;
    font-size:14px;
    font-weight:700;
}

.form-control::placeholder{
    color:rgba(71,85,105,.75);
}

.form-control:focus{
    border-color:var(--primary);
    box-shadow:0 0 0 4px rgba(29,78,216,.14);
}

/* ================= BUTTON ================= */
.btn{
    border-radius:var(--radius-sm);
    font-weight:600;
    border:1px solid var(--primary);
    background:var(--primary);
    color:#fff;
    padding:10px 14px;
    cursor:pointer;
    transition:all .2s ease;
}

.btn:hover{
    background:var(--primary-700);
    border-color:var(--primary-700);
    transform:translateY(-1px);
}

.btn:active{
    transform:translateY(0);
}

/* ================= LOKASI (🔥 FIX HORIZONTAL) ================= */
.lokasi-group{
    display:flex;
    gap:8px;
    align-items:center;
    width:100%;
}

.lokasi-group input{
    flex:1;
    min-width:0;
}

.lokasi-group button{
    flex:0 0 auto;
    white-space:nowrap;
    padding:10px 12px;
}

/* ================= MAP ================= */
#map{
    height:320px;
    margin-top:10px;
    border-radius:var(--radius-md);
    border:1px solid var(--border);
    background:var(--surface);
    z-index:1;
}

/* ================= INFO CABANG ================= */
#infoCabang{
    margin-top:10px;
    padding:10px;
    background:var(--surface-2);
    border-radius:var(--radius-md);
    font-size:13px;
    border:1px solid var(--border);
    border-left:4px solid var(--success);
}

/* ================= SEARCH ================= */
.search-wrapper{
    position:relative;
}

#searchResult{
    position:absolute;
    top:100%;
    left:0;
    width:100%;
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:var(--radius-md);
    max-height:220px;
    overflow:auto;
    z-index:999;
    box-shadow:var(--shadow-2);
}

#searchResult div{
    padding:10px;
    cursor:pointer;
    font-size:13px;
    color:var(--text);
    border-bottom:1px solid var(--border);
}

#searchResult div:last-child{
    border-bottom:0;
}

#searchResult div:hover{
    background:var(--surface-2);
}

/* ================= KTP PREVIEW ================= */
#previewKTP{
    display:none;
    margin-top:10px;
    width:100%;
    border-radius:var(--radius-md);
    border:1px solid var(--border);
    background:var(--surface);
}

/* ================= SIGNATURE (FIX FINAL) ================= */
#signature-pad{
    display:block;
    width:100%;
    height:220px;

    background:var(--surface);
    border:2px dashed var(--border-strong);
    border-radius:var(--radius-md);

    cursor:crosshair;

    /* 🔥 WAJIB */
    touch-action:none;
    pointer-events:auto;

    position:relative;
    z-index:5;
}

/* ================= MODAL ================= */
.modal-custom{
    display:none;
    position:fixed;
    inset:0;
    background:rgba(0,0,0,0.6);
    z-index:99999;
    pointer-events:auto;
    overflow:auto;
    padding:24px;
}

/* Center modal box while keeping overflow support */
.modal-box{
    background:var(--surface);
    max-width:420px;
    margin:10vh auto;
    padding:20px;
    border-radius:var(--radius-lg);
    border:1px solid var(--border);
    box-shadow:0 18px 55px rgba(15,23,42,.22);
    animation:fadeIn .25s ease;
    position:relative;
    z-index:100000;
    pointer-events:auto;
    max-height:calc(100vh - 48px);
    overflow:auto;
}

.notif-box{
    max-width:460px;
}

.notif-box .modal-header h4{
    margin:0;
    font-size:18px;
    font-weight:700;
    color:#b91c1c;
}

.notif-box .modal-body{
    padding:14px 0;
}

.notif-box .modal-body p{
    margin:0;
    color:#334155;
    font-size:14px;
    line-height:1.55;
}

.notif-box .modal-footer{
    display:flex;
    justify-content:flex-end;
    gap:10px;
}

@keyframes fadeIn{
    from{
        opacity:0;
        transform:translateY(-10px);
    }
    to{
        opacity:1;
        transform:translateY(0);
    }
}

/* ================= RESPONSIVE ================= */
@media (max-width:600px){

    .container{
        margin:14px auto;
        padding-left:12px;
        padding-right:12px;
        padding-bottom:calc(96px + env(safe-area-inset-bottom));
    }

    /* 🔥 lokasi tetap horizontal tapi wrap */
    .lokasi-group{
        flex-wrap:wrap;
    }

    .lokasi-group button{
        width:100%;
    }

    #map{
        height:260px;
    }

    #signature-pad{
        height:180px;
    }

    .paket-select-row{
        grid-template-columns:1fr;
    }

    .paket-type-filter{
        min-width:0;
    }

    .paket-kind-radio-wrap{
        white-space:normal;
    }

    .panel{
        border-radius:10px;
    }

    .panel-body{
        padding:14px 12px;
    }

    #btnDaftarMain{
        min-height:46px;
    }
}
