:root {
    --primary: #00875a;
    --primary-dark: #004d40;
    --primary-light: #e6f4ea;
    --accent: #0284c7;
    --accent-hover: #0369a1;
    --dark: #0f172a;
    --slate: #475569;
    --light-bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --radius-lg: 16px;
    --radius-md: 10px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 30px -5px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--light-bg);
    color: var(--dark);
    min-height: 100vh;
    padding-bottom: 40px;
    overflow-x: hidden;
}

/* ==========================================================================
   1. APP HEADER & NAV
   ========================================================================== */
.app-header {
    background: linear-gradient(135deg, #004d40 0%, #00796b 100%);
    color: white;
    padding: 16px 20px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(0, 77, 64, 0.15);
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-wrapper {
    background: rgba(255,255,255,0.15);
    padding: 6px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.brand-logo {
    height: 36px;
    width: auto;
}

.brand h1 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.brand p {
    font-size: 12px;
    opacity: 0.85;
}

.nav-menu {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 10px;
    flex-shrink: 0;
}

.nav-link {
    border: none;
    background: transparent;
    color: white;
    padding: 8px 16px;
    font-size: 12.5px;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.nav-link.active {
    background: white;
    color: var(--primary-dark);
}

/* ==========================================================================
   2. LAYOUT CONTAINERS & TABS
   ========================================================================== */
.tab-page {
    display: none !important;
}

.tab-page.active {
    display: flex !important;
}

.main-wrapper {
    flex-wrap: wrap;
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

.main-wrapper.single-column {
    max-width: 760px;
}

.form-section, .preview-section {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
}

.card-box {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    width: 100%;
}

.sticky-box {
    position: static;
}

.box-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.header-with-tabs {
    justify-content: space-between;
}

.header-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.header-icon.green { background: #e6f4ea; }
.header-icon.blue { background: #e0f2fe; }

.box-header h2 {
    font-size: 16px;
    font-weight: 800;
    color: var(--dark);
}

.box-header p {
    font-size: 12px;
    color: var(--slate);
}

.card-tabs {
    display: flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 8px;
    gap: 2px;
}

.tab-btn {
    border: none;
    background: transparent;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--slate);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab-btn.active {
    background: white;
    color: var(--primary-dark);
    box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   3. FORM ELEMENTS
   ========================================================================== */
.form-row {
    display: flex;
    gap: 12px;
}

.form-row .input-group {
    flex: 1;
}

.input-group {
    margin-bottom: 14px;
}

.input-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    margin-bottom: 6px;
}

.input-group input[type="text"],
.input-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 13.5px;
    color: var(--dark);
    background-color: #f8fafc;
    transition: all 0.2s ease;
}

.input-group input[type="text"]:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 135, 90, 0.12);
}

.file-upload-wrapper {
    position: relative;
    overflow: hidden;
}

.file-upload-wrapper input[type="file"] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    z-index: 2;
}

.upload-btn-custom {
    padding: 10px 14px;
    background: #f1f5f9;
    border: 1.5px dashed #cbd5e1;
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 12.5px;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.help-text {
    display: block;
    font-size: 11px;
    color: var(--slate);
    margin-top: 4px;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.action-buttons.single-col {
    margin-top: 8px;
}

button[class^="btn-"] {
    flex: 1;
    padding: 12px 14px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    min-height: 40px;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 3px 10px rgba(0, 135, 90, 0.2);
}

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--slate);
}

.btn-outline {
    background-color: transparent;
    border: 1.5px solid var(--border) !important;
    color: var(--slate);
}

.btn-accent {
    background-color: var(--accent);
    color: white;
    box-shadow: 0 3px 10px rgba(2, 132, 199, 0.2);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.status-box {
    font-size: 12px;
    margin-top: 8px;
    font-weight: 600;
    color: var(--primary);
}

/* ==========================================================================
   4. STAGE PRATINJAU KARTU
   ========================================================================== */
.preview-stage {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0f172a;
    padding: 16px 10px;
    border-radius: 12px;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
    overflow: hidden;
    width: 100%;
}

.card-scaler {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 180px;
}

.card-frame {
    box-shadow: var(--shadow-lg);
    border-radius: 8px;
    flex-shrink: 0;
    transform: scale(0.5);
    transform-origin: center center;
}

.card-nisn-kemenag {
    width: 500px;
    height: 325px;
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
}

.card-front { background-image: url('template_kartu.png'); }
.card-back { background-image: url('template_belakang.png'); }

.photo-overlay {
    position: absolute;
    top: 134px;
    left: 19px;
    width: 90px;
    height: 120px;
    background-color: #ffffff;
    border-radius: 3px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.photo-overlay img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bio-overlay {
    position: absolute;
    top: 124px;
    left: 123px;
    width: 340px;
    display: block;
    text-align: left;
}

.bio-table {
    width: 100%;
    border-collapse: collapse;
    color: var(--primary-dark);
    font-size: 11.5px;
    line-height: 1.4;
}

.bio-table td {
    padding: 5px 0;
    vertical-align: middle;
}

.bio-table td.label {
    width: 110px;
    font-weight: 600;
    white-space: nowrap;
}

.bio-table td.separator { width: 15px; }

.bio-table td.value {
    text-transform: uppercase;
    word-break: break-word;
}

.bio-table td.bold {
    font-weight: 800;
    color: #002d26;
}

.qrcode-overlay {
    position: absolute;
    bottom: 22px;
    right: 22px;
    background: #ffffff;
    padding: 5px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
}

.qrcode-overlay img:not(.qr-logo), 
.qrcode-overlay canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
    image-rendering: pixelated;
}

.qr-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 15px !important;
    height: 15px !important;
    background-color: #ffffff;
    border-radius: 50%;
    padding: 1.5px;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.2);
    object-fit: contain;
    z-index: 10;
}

.preview-footer {
    margin-top: 10px;
    text-align: center;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    background: #f1f5f9;
    color: var(--slate);
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

/* ==========================================================================
   5. OPTIMASI TAMPILAN DESKTOP (LARGE SCREEN)
   ========================================================================== */
@media (min-width: 993px) {
    .main-wrapper {
        flex-wrap: nowrap;
        gap: 28px;
        padding: 0 20px;
    }
    
    .form-section, .preview-section {
        flex: 1;
        width: 50%;
    }

    .sticky-box {
        position: sticky;
        top: 24px;
    }

    .card-box {
        padding: 24px;
    }

    .card-scaler {
        height: 280px; /* Diperbesar agar pas di desktop */
    }

    .card-frame {
        transform: scale(0.82); /* Kartu terlihat besar & jelas */
    }

    .box-header h2 {
        font-size: 17px;
    }

    .box-header p {
        font-size: 13px;
    }

    .input-group label {
        font-size: 13px;
    }

    .input-group input[type="text"],
    .input-group select {
        padding: 11px 14px;
        font-size: 14px;
    }

    button[class^="btn-"] {
        min-height: 44px;
        font-size: 13.5px;
    }
}