/* WAJIB: Sembunyikan elemen Alpine sebelum JS dimuat sempurna */
[x-cloak] { 
    display: none !important; 
}


/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Aturan Khusus Cetak Kartu Direct-to-Printer */
@media print {
    body * {
        visibility: hidden !important;
    }
    #printable-cr80, #printable-cr80 * {
        visibility: visible !important;
    }
    #printable-cr80 {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }
}

/* ---------- Iconsax ---------- */
.isax { line-height: 1; display: inline-block; vertical-align: middle; }

/* ---------- Form field ---------- */
.fld {
    width: 100%;
    padding: .55rem .75rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: .5rem;
    font-size: .75rem;
    color: #0f172a;
    outline: none;
    transition: box-shadow .15s, background .15s, border-color .15s;
}
.fld:focus { box-shadow: 0 0 0 2px #3b82f6; background: #fff; }
.fld.err { border-color: #f43f5e; background: #fff1f2; }
.err-msg { color: #e11d48; font-size: 10px; margin-top: 3px; font-weight: 600; }

/* ---------- QR & kartu ---------- */
#qrcode-target img, #qrcode-target canvas {
    width: 100% !important; height: 100% !important; image-rendering: pixelated;
}
#qrcode-target canvas { display: none; }
#qrcode-target img[style*="display: none"] { display: none !important; }
.cr80-card, .cr80-card * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

/* ---------- Pemindai kamera ---------- */
.scan-frame::before, .scan-frame::after {
    content: ""; position: absolute; width: 28px; height: 28px; border: 3px solid #34d399;
}
.scan-frame::before { top: 14px; left: 14px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.scan-frame::after { bottom: 14px; right: 14px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }

/* ---------- Date picker ---------- */
.dp-day {
    height: 36px; border-radius: 9999px; font-size: 12px; font-weight: 600; color: #334155;
    display: flex; align-items: center; justify-content: center; transition: background .12s, color .12s;
}
.dp-day:hover:not(:disabled) { background: #e2e8f0; }
.dp-day.is-today { box-shadow: inset 0 0 0 1.5px #2563eb; color: #2563eb; }
.dp-day.is-selected { background: #2563eb !important; color: #fff; box-shadow: 0 4px 10px rgba(37,99,235,.35); }
.dp-day:disabled { color: #cbd5e1; cursor: not-allowed; }


/* ================= Kartu CR80 (85.6 x 53.98 mm) ================= */
.cr80-scale { width: 324px; height: 204px; }
.cr80-card {
    width: 324px; height: 204px; box-sizing: border-box; position: relative; overflow: hidden;
    display: flex; flex-direction: column; background: #fff; color: #0f172a;
    border: 1.5px solid #059669; border-radius: 12px; box-shadow: 0 10px 25px rgba(15,23,42,.18);
}
.cr80-head { height: 32px; flex: none; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-bottom: 1px solid #e2e8f0; background: linear-gradient(#fff, #f8fafc); }
.cr80-brand { display: flex; align-items: center; gap: 5px; color: #047857; font-weight: 800; font-size: 11px; letter-spacing: .04em; }
.cr80-brand i { font-size: 15px; }
.cr80-co { font-weight: 800; font-size: 10px; color: #1e3a8a; letter-spacing: .06em; }
.cr80-body { flex: 1; min-height: 0; display: flex; gap: 10px; padding: 9px 12px; }
.cr80-photo { width: 62px; height: 83px; flex: none; object-fit: cover; border-radius: 6px; border: 1px solid #cbd5e1; background: #e2e8f0; }
.cr80-photo-ph { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #94a3b8; font-size: 7px; font-weight: 800; letter-spacing: .08em; }
.cr80-photo-ph i { font-size: 24px; }
.cr80-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cr80-name { font-size: 11.5px; font-weight: 800; line-height: 1.15; text-transform: uppercase; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.cr80-nik { font-family: ui-monospace, monospace; font-size: 9px; font-weight: 700; color: #2563eb; margin: 2px 0 0; }
.cr80-dept { font-size: 8.5px; font-weight: 700; color: #334155; margin: 2px 0 0; line-height: 1.2; }
.cr80-pos { font-size: 8px; color: #64748b; margin: 0; line-height: 1.2; }
.cr80-dates { margin: auto 0 0; padding-top: 3px; border-top: 1px solid #e2e8f0; display: grid; gap: 1px; }
.cr80-dates div { display: flex; justify-content: space-between; font-size: 8px; line-height: 1.25; }
.cr80-dates dt { color: #64748b; }
.cr80-dates dd { margin: 0; font-weight: 700; }
.cr80-qr-col { width: 68px; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: space-between; }
#qrcode-target { width: 68px; height: 68px; padding: 2px; box-sizing: border-box; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; }
.cr80-qr-col span { font-size: 6.5px; font-weight: 800; color: #64748b; letter-spacing: .06em; text-align: center; }
.cr80-foot { height: 22px; flex: none; background: #059669; color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; font-size: 8.5px; font-weight: 800; letter-spacing: .05em; }
@media (max-width: 420px) { .cr80-scale { zoom: .8; } }

@page { size: 85.6mm 53.98mm; margin: 0; }
@media print { .cr80-scale { zoom: 1 !important; } .cr80-card { box-shadow: none !important; } }

/* ===================== Page Loader ===================== */
.page-loader {
    position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
    background: rgba(7,10,16,.96); backdrop-filter: blur(14px); opacity: 1; transition: opacity .3s ease, visibility .3s ease;
}
.page-loader.is-done { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-card { width: min(330px, calc(100vw - 48px)); text-align: center; color: #fff; }
.loader-ring { width: 58px; height: 58px; margin: 0 auto 18px; border-radius: 50%; border: 3px solid rgba(255,255,255,.12); border-top-color: #60a5fa; animation: hsseSpin .8s linear infinite; position: relative; }
.loader-ring span { position: absolute; inset: 9px; border-radius: 50%; border: 2px solid transparent; border-right-color: #34d399; animation: hsseSpin 1.25s linear infinite reverse; }
.loader-title { font-size: 14px; font-weight: 800; letter-spacing: .14em; }
.loader-sub { color: #94a3b8; font-size: 11px; margin-top: 5px; }
.loader-progress { height: 4px; margin: 18px auto 0; max-width: 230px; background: rgba(255,255,255,.09); border-radius: 99px; overflow: hidden; }
.loader-progress span { display: block; width: 45%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#3b82f6,#22c55e,#8b5cf6); animation: hsseProgress 1.15s ease-in-out infinite; }
@keyframes hsseSpin { to { transform: rotate(360deg); } }
@keyframes hsseProgress { 0% { transform: translateX(-120%); } 50% { transform: translateX(90%); } 100% { transform: translateX(260%); } }

/* Premium mobile popups */
@media (max-width: 640px) {
    .fld { min-height: 44px; }
}

.cr80-logo { width: 16px; height: 16px; border-radius: 4px; object-fit: cover; }
.cr80-ike { height: 24px; width: auto; max-width: 120px; object-fit: contain; }
.cr80-foot span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr80-foot span:last-child { flex: none; margin-left: 8px; }
