/* Kartu Santri — ukuran fisik CR80 (85,6 × 54 mm), satu sisi.
   Hierarki: nama pemegang kartu adalah fokus; judul kartu hanya label dokumen.
   Ditulis manual (bukan Tailwind) karena ukuran cetak harus dalam mm. */

.ks-stage {
    width: 100%;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.ks-preview-panel {
    box-sizing: border-box;
    padding: 4.5mm 4mm;
    border-radius: 4mm;
    background: #eef2f7;
    border: 0.25mm solid #dde5ef;
}

@media (min-width: 640px) {
    .ks-preview-panel {
        padding: 7mm 8mm;
    }
}

.ks-scaler {
    transform-origin: top center;
    flex: 0 0 auto;
}

.ks-stage--print {
    display: block;
    overflow: visible;
    height: auto;
}

.ks-card {
    box-sizing: border-box;
    position: relative;
    width: 85.6mm;
    height: 54mm;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 2.4mm;
    border: 0.22mm solid rgba(255, 255, 255, 0.14);
    background:
        radial-gradient(circle at 0% 100%, rgba(56, 132, 190, 0.22), transparent 52%),
        linear-gradient(135deg, #08182d 0%, #0f2b4d 55%, #173f6b 100%);
    color: #f4f8fd;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    line-height: 1.2;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    break-inside: avoid;
}

.ks-stage:not(.ks-stage--print) .ks-card {
    box-shadow: 0 18px 34px -22px rgba(8, 24, 45, 0.55);
}

/* ---------- Ornamen: motif geometris, satu tempat, dosis rendah ---------- */

.ks-ornament {
    position: absolute;
    pointer-events: none;
}

.ks-ornament--rings {
    right: -13mm;
    top: -10mm;
    width: 44mm;
    height: 44mm;
    border-radius: 50%;
    border: 0.25mm solid rgba(242, 199, 92, 0.18);
    box-shadow:
        0 0 0 4.4mm rgba(242, 199, 92, 0.055),
        0 0 0 8.8mm rgba(242, 199, 92, 0.03);
}

/* ---------- Header ---------- */

.ks-head {
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    flex: 0 0 10mm;
    height: 10mm;
    display: flex;
    align-items: center;
    gap: 2.4mm;
    padding: 0 4.2mm;
    border-bottom: 0.18mm solid rgba(242, 199, 92, 0.34);
}

.ks-logo {
    box-sizing: border-box;
    width: 7mm;
    height: 7mm;
    flex: 0 0 7mm;
    object-fit: contain;
}

.ks-head-text {
    flex: 1 1 auto;
    min-width: 0;
}

.ks-inst {
    margin: 0;
    font-size: 2.35mm;
    font-weight: 800;
    letter-spacing: 0.03em;
    line-height: 1.08;
    text-transform: uppercase;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ks-inst-address {
    margin: 0.45mm 0 0;
    font-size: 1.55mm;
    font-weight: 500;
    letter-spacing: 0.01em;
    line-height: 1.15;
    color: #b9cce0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ks-kind {
    flex: 0 0 auto;
    font-size: 1.75mm;
    font-weight: 800;
    letter-spacing: 0.14em;
    line-height: 1.1;
    text-transform: uppercase;
    color: #f2c75c;
    white-space: nowrap;
}

/* ---------- Body ---------- */

.ks-body {
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    gap: 3.6mm;
    padding: 1.5mm 4.2mm 1.5mm;
}

/* Area foto 1:1 + badge QR menumpuk 1/3 di bawah simetris */
.ks-media-wrap {
    position: relative;
    width: 18mm;
    flex: 0 0 18mm;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ks-media {
    box-sizing: border-box;
    width: 18mm;
    height: 18mm;
    overflow: hidden;
    border-radius: 1.6mm;
    border: 0.35mm solid rgba(255, 255, 255, 0.7);
    background: #e7edf6;
    box-shadow: 0 1.4mm 3.5mm -1.6mm rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ks-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ks-avatar-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #d8e2ee 0%, #b8c8dc 100%);
    color: #64748b;
}

.ks-avatar-icon {
    width: 11mm;
    height: 11mm;
    opacity: 0.85;
}

/* Badge QR: menumpuk 1/3 bagian bawah foto 18mm (tinggi 9.5mm, overlap 4.2mm) */
.ks-qr-badge {
    box-sizing: border-box;
    position: relative;
    margin-top: -4.2mm;
    z-index: 2;
    width: 9.5mm;
    height: 9.5mm;
    padding: 0.55mm;
    background: #ffffff;
    border-radius: 1mm;
    border: 0.22mm solid rgba(8, 24, 45, 0.2);
    box-shadow: 0 1mm 2.2mm -0.6mm rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ks-qr-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.ks-fields {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.ks-name {
    margin: 0;
    font-size: 3.6mm;
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.008em;
    color: #ffffff;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ks-rule {
    flex: 0 0 auto;
    height: 0.18mm;
    margin: 2.3mm 0 1.9mm;
    background: rgba(255, 255, 255, 0.14);
}

.ks-rows {
    display: flex;
    flex-direction: column;
    gap: 1.35mm;
    min-height: 0;
}

.ks-row {
    display: flex;
    align-items: flex-start;
    gap: 1.4mm;
    min-width: 0;
}

.ks-row--nis {
    align-items: baseline;
}

.ks-label {
    flex: 0 0 9.2mm;
    padding-top: 0.22mm;
    font-size: 1.55mm;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.15;
    text-transform: uppercase;
    color: #9fb6cd;
}

.ks-row--nis .ks-label {
    padding-top: 0;
}

.ks-nis {
    min-width: 0;
    font-size: 2.95mm;
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: 0.02em;
    color: #f2c75c;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.ks-angkatan {
    margin-left: auto;
    padding-left: 2mm;
    font-size: 1.7mm;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1.15;
    color: #9fb6cd;
    white-space: nowrap;
}

.ks-value {
    min-width: 0;
    font-size: 2.05mm;
    font-weight: 500;
    line-height: 1.22;
    color: #dfeaf6;
}

.ks-value--nik {
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

.ks-hijri {
    font-size: 1.85mm;
    font-weight: 600;
    color: #b9cce0;
    white-space: nowrap;
}

.ks-value--address {
    font-size: 1.95mm;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- Footer ---------- */

.ks-foot {
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    flex: 0 0 7.2mm;
    height: 7.2mm;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3mm;
    padding: 0 4.2mm;
    border-top: 0.18mm solid rgba(255, 255, 255, 0.13);
    background: rgba(3, 12, 25, 0.3);
}

.ks-foot-wali {
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 1.4mm;
}

.ks-foot-wali .ks-label {
    flex: 0 0 auto;
    padding-top: 0;
}

.ks-foot-name {
    min-width: 0;
    font-size: 2.1mm;
    font-weight: 600;
    color: #dfeaf6;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ks-foot-phone {
    flex: 0 0 auto;
    font-size: 2.1mm;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #ffffff;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---------- Cetak ---------- */

.ks-print-sheet {
    display: none;
}

@media print {
    html,
    body {
        height: auto !important;
        overflow: visible !important;
        background: #ffffff !important;
    }

    body.ks-printing #app {
        display: none !important;
    }

    body.ks-printing .ks-print-sheet {
        display: block !important;
    }

    body.ks-printing .ks-print-sheet .ks-card {
        box-shadow: none !important;
    }
}

@page {
    size: A4 portrait;
    margin: 12mm;
}