:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --accent: #0ea5e9;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.15);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #e0e7ff 0%, #f1f5f9 50%, #fef3c7 100%);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    padding: 30px 15px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 1100px;
    margin: 0 auto;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== HEADER (glassmorphism) ===== */
.form-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 28px 32px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.form-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.form-header::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -5%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    background: #fff;
    border-radius: 50%;
    padding: 6px;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    position: relative;
    z-index: 1;
}

.logo:hover { transform: scale(1.08) rotate(-3deg); }
.logo:active { transform: scale(0.95); }

.header-text {
    position: relative;
    z-index: 1;
    flex: 1;
}

.header-text h1 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    line-height: 1.3;
    text-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header-text p {
    font-size: 0.85rem;
    opacity: 0.92;
    margin: 4px 0 8px;
}

.header-text h2 {
    font-size: 0.9rem;
    font-weight: 700;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    display: inline-block;
    padding: 6px 16px;
    border-radius: 30px;
    margin-top: 5px;
    border: 1px solid rgba(255,255,255,0.3);
}

/* ===== FORM SECTIONS ===== */
.form-section {
    padding: 28px 32px;
    border-bottom: 1px solid var(--border);
}

.form-section:last-of-type { border-bottom: none; }

.form-section h3 {
    font-size: 1.15rem;
    color: var(--primary-dark);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
    font-weight: 700;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.form-group.full { grid-column: 1 / -1; }

.form-group label {
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.form-group label small {
    font-weight: 400;
    color: var(--muted);
    font-size: 0.75rem;
    margin-left: 3px;
}

/* 🔴 TANDA WAJIB ISI 🔴 */
.wajib {
    color: #dc2626; /* Warna merah */
    font-weight: bold;
    font-size: 1.1em;
    margin-left: 4px;
    vertical-align: middle;
}

.form-group input,
.form-group select {
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: all var(--transition);
    background: #fafbfc;
    color: var(--text);
    width: 100%;
}

.form-group input:hover,
.form-group select:hover {
    border-color: #cbd5e1;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

/* Efek merah jika input tidak valid/kosong */
.form-group input:invalid:not(:placeholder-shown):not(:focus),
.form-group select:invalid:not(:focus) {
    border-color: #fca5a5;
    background-color: #fef2f2;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* Field status (cek NIK) */
.field-status {
    margin-top: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    min-height: 18px;
}
.field-status.loading { color: var(--muted); }
.field-status.ok { color: var(--success); }
.field-status.error { color: var(--danger); }

/* ===== BUTTONS ===== */
.form-actions {
    padding: 28px 32px;
    text-align: center;
    background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
}

.btn {
    display: inline-block;
    padding: 14px 36px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    font-family: inherit;
    letter-spacing: 0.3px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    box-shadow: 0 4px 16px rgba(37,99,235,0.35);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(37,99,235,0.45);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-cancel {
    background: #e2e8f0;
    color: var(--text);
}
.btn-cancel:hover { background: #cbd5e1; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-box {
    background: #fff;
    border-radius: var(--radius);
    padding: 32px 28px;
    max-width: 440px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    text-align: center;
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes slideUp {
    from { transform: translateY(30px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-box h3 {
    color: var(--primary-dark);
    margin-bottom: 10px;
    font-size: 1.35rem;
    font-weight: 700;
}

.modal-box > p {
    color: var(--muted);
    font-size: 0.92rem;
    margin-bottom: 20px;
    line-height: 1.6;
}

.modal-box input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    margin-bottom: 18px;
    font-family: inherit;
}

.modal-box input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37,99,235,0.12);
}

.modal-actions {
    display: flex;
    gap: 10px;
}
.modal-actions .btn {
    flex: 1;
    padding: 12px;
    font-size: 0.92rem;
}

/* Success & warning */
.success-modal .success-icon,
.warning-modal .success-icon {
    font-size: 4.5rem;
    margin-bottom: 18px;
    animation: pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: inline-block;
}

@keyframes pop {
    0% { transform: scale(0) rotate(-180deg); }
    80% { transform: scale(1.15) rotate(10deg); }
    100% { transform: scale(1) rotate(0); }
}

.success-modal h3 { color: var(--success); }
.warning-modal h3 { color: var(--warning); }

.success-note {
    font-size: 0.82rem !important;
    color: var(--muted) !important;
    margin-top: 10px !important;
    font-style: italic;
    background: #f8fafc;
    padding: 10px;
    border-radius: 8px;
}

.success-modal .btn,
.warning-modal .btn {
    width: 100%;
    margin-top: 18px;
}

.error-msg {
    margin-top: 14px;
    padding: 12px;
    background: #fee2e2;
    color: #991b1b;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
}

/* ===== ADMIN ===== */
.admin-container { max-width: 1400px; }

.admin-header {
    padding: 28px 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    position: relative;
    overflow: hidden;
}

.admin-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.admin-header h1 {
    font-size: 1.5rem;
    position: relative;
    z-index: 1;
    font-weight: 800;
}

.admin-header p {
    margin: 10px 0 0;
    opacity: 0.95;
    position: relative;
    z-index: 1;
}

.table-wrapper {
    overflow-x: auto;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    min-width: 800px;
}

.data-table th {
    background: var(--primary-dark);
    color: #fff;
    padding: 14px 12px;
    text-align: left;
    font-weight: 700;
    white-space: nowrap;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.data-table tbody tr {
    transition: background var(--transition);
}
.data-table tbody tr:hover { background: #f8fafc; }

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-muted { background: #e2e8f0; color: #64748b; }

/* =============================================
   RESPONSIVE — TABLET (max-width: 768px)
   ============================================= */
@media (max-width: 768px) {
    body {
        padding: 15px 10px;
        font-size: 15px;
    }

    .container {
        border-radius: 12px;
    }

    .form-header {
        padding: 22px 20px;
        gap: 14px;
    }

    .logo {
        width: 65px;
        height: 65px;
    }

    .header-text h1 { font-size: 1.1rem; }
    .header-text p { font-size: 0.78rem; }
    .header-text h2 {
        font-size: 0.8rem;
        padding: 5px 12px;
    }

    .form-section {
        padding: 22px 20px;
    }

    .form-section h3 {
        font-size: 1.05rem;
        margin-bottom: 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .form-group label {
        font-size: 0.85rem;
    }

    .form-group input,
    .form-group select {
        padding: 12px 14px;
        font-size: 16px; /* Mencegah zoom otomatis di iOS */
    }

    .form-actions {
        padding: 22px 20px;
    }

    .btn {
        padding: 13px 28px;
        font-size: 0.95rem;
    }

    .btn-primary {
        width: 100%;
    }

    .modal-box {
        padding: 26px 22px;
    }

    .modal-box h3 { font-size: 1.2rem; }

    .admin-header {
        padding: 22px 20px;
    }

    .admin-header h1 { font-size: 1.25rem; }

    .table-wrapper { padding: 16px; }
}

/* =============================================
   RESPONSIVE — MOBILE KECIL (max-width: 480px)
   ============================================= */
@media (max-width: 480px) {
    body {
        padding: 10px 6px;
    }

    .form-header {
        flex-direction: column;
        text-align: center;
        padding: 20px 16px;
    }

    .logo {
        width: 70px;
        height: 70px;
    }

    .header-text h1 {
        font-size: 1rem;
        line-height: 1.4;
    }

    .header-text p {
        font-size: 0.72rem;
    }

    .header-text h2 {
        font-size: 0.75rem;
        padding: 4px 10px;
    }

    .form-section {
        padding: 18px 16px;
    }

    .form-section h3 {
        font-size: 1rem;
        margin-bottom: 14px;
        padding-bottom: 8px;
    }

    .form-group label {
        font-size: 0.82rem;
    }

    .form-group input,
    .form-group select {
        padding: 11px 13px;
        font-size: 16px; /* Wajib 16px di HP agar tidak auto-zoom */
        border-radius: 9px;
    }

    .form-actions {
        padding: 18px 16px;
    }

    .btn {
        padding: 12px 22px;
        font-size: 0.92rem;
        border-radius: 9px;
    }

    .modal-box {
        padding: 22px 18px;
    }

    .modal-box h3 { font-size: 1.1rem; }
    .modal-box > p { font-size: 0.85rem; }

    .success-modal .success-icon,
    .warning-modal .success-icon {
        font-size: 3.5rem;
    }

    .modal-actions {
        flex-direction: column;
    }
}

/* =============================================
   AKSESIBILITAS & SCROLLBAR CUSTOM
   ============================================= */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Fokus jelas untuk keyboard navigation */
*:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}